diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index fed73d7b002..f112ea0523b 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -56,7 +56,7 @@ You can add it to your git configuration using: git config --local commit.template .gitmessage ``` -where +where #### Keyword In uppercase if you want to have the log comment appears into the generated ChangeLog file. @@ -101,7 +101,7 @@ Long description (Can span accross multiple lines). ### Pull Requests -Pull Request (PR) process is the process to submit a change (enhancement, bug fix, ...) into the code of the project. There is some rules to know and +Pull Request (PR) process is the process to submit a change (enhancement, bug fix, ...) into the code of the project. There is some rules to know and a process to follow to optimize the chance to have PRs merged efficiently... * A PR must be atomic. It means it must contains the lower possible changes for 1 need (1 bug fix or 1 new feature) without breaking usability of code. If a PR can be split into several PRs, it often means your PR is not atomic. @@ -120,7 +120,7 @@ Once a PR has been submitted, you may need to wait for its integration. It is co If the label of PR start with "Draft" or "WIP" (Work In Progress), it will not be analyzed for merging until you change the label of PR (but it can be analyzed for discussion). -If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration. +If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration. If the PR is valid, and is kept open for a long time, a tag will also be added on the PR to describe the status of your PR and why the PR is kept open. By putting your mouse on the tag, you will get a full explanation of the tag/status that explain why your PR has not been integrated yet. In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the tag ask you. The majority of open PR are waiting an action of the author of the PR. @@ -141,7 +141,7 @@ Translations done on transifex are available in the next major release. Note: Sometimes, the source text (english) is modified. In such a case, the translation is reset. Transifex assume that if the original source has changed, the translation is surely no more correct so must be done again. But old translation is not lost and you can use the tab "History" -to retreive all old translation of a source text, and restore the translation in one click with no need to retranslate it if there is no need to. +to retrieve all old translation of a source text, and restore the translation in one click with no need to retranslate it if there is no need to. ### Resources diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml index 861f6ccd4b0..3cfc4f8ba23 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml @@ -13,5 +13,5 @@ jobs: - name: Exakat uses: docker://exakat/exakat-ga with: - ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/WrongNumberOfArguments,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/RepeatedPrint,Structures/UselessParenthesis,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UseConstant' - ignore_dirs: '/htdocs/includes,/htdocs/build,/htdocs/dev,/htdocs/doc,/htdocs/scripts,/htdocs/test' \ No newline at end of file + ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/RepeatedPrint,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' + ignore_dirs: '/htdocs/includes,/build,/dev,/doc,/scripts,/test' \ No newline at end of file diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 6dbf39bde26..3cffed355fa 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -17,8 +17,10 @@ filter: - build/* - dev/* - doc/* - - test/* + - documents/* - htdocs/includes/* + - node_modules/* + - test/* paths: - htdocs/* - scripts/* diff --git a/.travis.yml b/.travis.yml index 16d3403f554..639183de6ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,10 +35,6 @@ addons: php: - '5.6' -- '7.0' -- '7.1' -- '7.2' -- '7.3' - '7.4' - nightly @@ -112,33 +108,48 @@ install: echo "Updating Composer" rm $TRAVIS_BUILD_DIR/composer.json rm $TRAVIS_BUILD_DIR/composer.lock + composer -V composer self-update - # To have composer making parallel downloads - composer global require hirak/prestissimo composer -n init composer -n config vendor-dir htdocs/includes + composer -n config -g vendor-dir htdocs/includes echo - | echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION" - if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \ - [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then + if [ "$TRAVIS_PHP_VERSION" = '5.6' ]; then composer -n require phpunit/phpunit ^5 \ - php-parallel-lint/php-parallel-lint ^0 \ + php-parallel-lint/php-parallel-lint ^1 \ php-parallel-lint/php-console-highlighter ^0 \ 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 \ + squizlabs/php_codesniffer ^3 + fi + if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then + composer -n require phpunit/phpunit ^7 \ + php-parallel-lint/php-parallel-lint ^1.2 \ + php-parallel-lint/php-console-highlighter ^0 \ + squizlabs/php_codesniffer ^3 + fi + # phpunit 9 is required for php 8 if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then - composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \ - php-parallel-lint/php-parallel-lint ^1 \ + composer -n require --ignore-platform-reqs phpunit/phpunit ^7 \ + php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ squizlabs/php_codesniffer ^3 - fi + fi echo - | echo "Adding path of binaries tools installed by composer to the PATH" - export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" + export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$TRAVIS_BUILD_DIR/vendor/bin:$TRAVIS_BUILD_DIR/htdocs/includes:$PATH" + echo $PATH + ls $TRAVIS_BUILD_DIR/vendor + ls $TRAVIS_BUILD_DIR/htdocs/includes/bin echo @@ -165,15 +176,20 @@ before_script: - | echo "Versions information" + echo # Check PHP echo "PHP version" php -i | head - - # Check PHP CodeSniffer installation + # Check Parallel-lint version + echo "Parallel-lint version" + which parallel-lint + parallel-lint -V + # Check PHP CodeSniffer version echo "PHPCS version" which phpcs phpcs --version | head - phpcs -i | head - - # Check PHPUnit installation + # Check PHPUnit version echo "PHPUnit version" which phpunit phpunit --version | head - @@ -287,12 +303,13 @@ script: echo - | - echo "Checking coding style (excluding Pull Requests builds)" + echo "Checking coding style (excluding Pull Requests builds to not overload travis, excluding also some jobs to avoid duplicate tests)" # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - #phpcs -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 . - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -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 .; fi + if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4" ] && [ "$DB" = "mysql" ]; then + phpcs -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 .; + fi set +e echo @@ -409,7 +426,7 @@ script: php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log # Enable modules not enabled into original dump - php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log echo $? cd - set +e @@ -428,7 +445,7 @@ script: after_script: - | - echo "After script - Output lines of dolibarr.log" + echo "After script - Output last lines of dolibarr.log" ls $TRAVIS_BUILD_DIR/documents #cat $TRAVIS_BUILD_DIR/documents/dolibarr.log sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log diff --git a/COPYRIGHT b/COPYRIGHT index d8cefedcd65..d43f4d506f1 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -21,6 +21,7 @@ Mobiledetect 2.8.34 MIT License Yes NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency ParseDown 1.6 MIT License Yes Markdown parser +PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files PHPSpreadSheet ? LGPL-2.1+ Yes Read/Write XLS files, read ODS files diff --git a/ChangeLog b/ChangeLog index 60aa376f96d..516bc270321 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,25 +7,242 @@ English Dolibarr ChangeLog For users: NEW: Add module "Credit transfer SEPA" to manage payment of vendors using bank credit transfer SEPA files. NEW: Module Reception (for a more accurate management of your receptions) moved from experimental to stable. +NEW: Several security issues after a private bug bounty campaign. +NEW: #15065 Put the product label in bold in the PDF templates if configured +NEW: Accountancy - Add chart of sub accounts +NEW: Accountancy - Add options to disable binding on sales, purchases & expense reports independently of the modules +NEW: Accountancy balance - Add a menu entry to show subtotal by group +NEW: Accountancy - Move to real ledger, real journals, menu disposition +NEW: Accountancy - On transfers, select the periodicity by default +NEW: New currency rate editor. +NEW: Add 2 rules for emailcollector: Message send/not sent from Dolibarr +NEW: Add a counter of number of words for pages in website module +NEW: add alert before changing thirdparty in takepos +NEW: Add a page to list Stock at a given date in the past. +NEW: Add a start date to begin binding in accountancy +NEW: Add a statistics page to list popularity of products on invoices +NEW: Add calendar selection for agenda view +NEW: Support documents generation for ticket edition (pdf or odt) +NEW: Add column payment term into list of supplier invoices. +NEW: Add column quantity in product margin page +NEW: Add column vat rate in page to define accounting account on product/service +NEW: Add common list function for available app/module page +NEW: add costprice in fields of products list +NEW: Added an import profile for CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE +NEW: Added incoterms dara into the substitution array +NEW: Add employee link in expense report binding page +NEW: Add export for various payment +NEW: add extra fields labels and values in mail on create ticket +NEW: Add extrafields support on ECM module +NEW: Add filter rules "is answer" and "is not answer" in email collector +NEW: Add focus when editing on product/stock/product.php Close #14548 +NEW: add formConfirm hook on product page +NEW: add free text on each terminal of cash desk +NEW: Add function dolButtonToOpenUrlInDialogPopup() to be able to open +NEW: Add global search for customer payments and vendor payments +NEW: Add global search for miscellaneous payments +NEW: Add helper function for table headers with numbers +NEW: add hooks on stats pages +NEW: Add link to edit property from search result of website pages +NEW: Add link to reset qty on supplier dispatch page +NEW: add MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const to remove header stored by email collector +NEW: Add Manufacturing Orders attached files into the automatic ECM view +NEW: add margin info in invoice list +NEW: Add mass action to set category on a list of website pages. +NEW: Add mass deletion for events +NEW: Add mass deletion for draft invoices +NEW: Add __MEMBER_TYPE__ substitution key +NEW: Add a message in error_log after detection of SQL or script injection +NEW: Add module Credit transfer SEPA to manage payment of supplier using +NEW: Add more filters on monthly statement list +NEW: Add option TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT +NEW: Add option to define a default warehouse at user level +NEW: Add option to include products without alert in replenish +NEW: add order by lastname and firstname by default in get sales representatives +NEW: Add param to not show links when output tags +NEW: Add PDF document templates for warehouses (list of stock) +NEW: Add property cssview when declaring fields of an object +NEW: Add prospect status managment for the contact with managment of custom icon +NEW: Add public note on products. This also partially fix the #14342 +NEW: Add quick dropdown menu in top right menu (MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN) +NEW: add region in export companies and contacts +NEW: add rights on margin info on invoice list +NEW: Add search param for close date on order list +NEW: add send context for ticket +NEW: Add show preview for mail attachement on form mail +NEW: add state origin for product +NEW: add State/Province origin for products +NEW: Add the workflow interaction close intervention on closing ticket +NEW: Add third order printer to TakePOS +NEW: add tracking number in list and search_all items +NEW: add two hooks printFieldListFrom and printFieldSearchParam +NEW: Add __TYPE__ substitution key +NEW: Add validation of MX domain for emails +NEW: add vcard for aderent and user +NEW: add week number for month view in agenda +NEW: Algeria data (tva and forme_juridique) +NEW: Allow click on all header numbers on commerce area +NEW: Allow to reopen interventions (green button) +NEW: Allow zero quality on supplier/vendor order line +NEW: Appearance tab in TakePOS with more visual parameters +NEW: Better currency rate editor +NEW: Calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') ) +NEW: Can add event to log into blockedlog module with a constant. +NEW: Can build vendor invoice from vendor orders +NEW: Can change a product in line of recurring invoice or contract +NEW: Can change size of logo on PDF documents +NEW: Can change VAT rate of all lines of a draft object in one step. +NEW: Can define date range of validity of a login during creation +NEW: Can disable, from edit page, the whole web site +NEW: can edit and set sales representatives directly on thirdparty card +NEW: Can edit the list of sending email profiles. +NEW: Can enable/disable users in bulk actions +NEW: Can filter on accounting system ref in export of chart of account +NEW: Can filter on container type, language and tags in the list of pages +NEW: Can force the antivirus from conf file or autoprepend ini setup. +NEW: Can hide eatby, sellby dates with option PRODUCT_DISABLE_SELLBY and PRODUCT_DISABLE_EATBY +NEW: Can import proposals, sales orders, supplier invoices +NEW: can set a dedicated SMTP config for sending email from public ticket interface +NEW: Can set tags/categories to website pages. +NEW: Can set type of price without tax per default for new sale price creation +NEW: Can use desired stock of a given warehouse for replenishment +NEW: Can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode +NEW: change thirdparty with barcode scan in takepos +NEW: Common behavior for monthly leave list view +NEW: conf to allow show full arbo in warehouse getnomurl +NEW: convert all subscription in datetime +NEW: create thirdparty customer from TAKEPOS +NEW: Date shipment from order accepts hours +NEW: Declinaison price level compatibility +NEW: Delayed payment in TakePOS +NEW: Development of module Recruitment +NEW: display date range if exist in takepos +NEW: display resiliate status in takepos for member +NEW: display stat for BOM on "object referent"/linked Object product tab +NEW: edit and update a ticket +NEW: edit or delete dispatched lines +NEW: Email configuration - Allow auto signed certificat when smtp ssl activated +NEW: enable free emails input with select2 +NEW: endpoint getContacts and Clean results +NEW: Events in agenda for contact +NEW: Field to link website page to an other object +NEW: Fill ECM src object fields in dol_add_file_process +NEW: filter on progress column in task list +NEW: filter product list by country and/or state/province +NEW: format tickets sent by mail in public interface +NEW: add juridical status for Algeria +NEW: form to add customer/supplier into categories +NEW: Framework is ready for CSRF token protection on explicit GET URLs. +NEW: get all child recursively +NEW: Get contacts list of a given order +NEW: helper functions for export with phpspreadsheet +NEW: hide closed contract lines +NEW: hide label in pdf for variants +NEW: Hook on propal card +NEW: If specific help page is available, we change color of icon +NEW: Include the tag editor of page as a popup into website editor +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: Module Intracomm report +NEW: More filter for "View change logs" +NEW: multicurrency total in takepos +NEW: multiselect type and date to date filter +NEW: Nature of product is now a dictionay +NEW: new line template: hidden conf to fill service dates from the last service line +NEW: PDF model storm for delivery +NEW: possibilty to group payments by mode and show their subtotal +NEW: Print payment method and change in TakePOS +NEW: Priority and transparency from external calendar events +NEW: Products Import/Export 'default warehouse' and 'use batch number' fields +NEW: Purchase price table: Added filterable table columns +NEW: rate editor for multicurrency +NEW: ref_ext field for Commande lines, order lines, Attributes and Combinations, Invoice lines, payments, order lines +NEW: remove new lines in mail on add ticket message +NEW: restrict thirdparty to customer in takepos +NEW: Allow to edit "demand reason" field though API +NEW: Rule "email to" accept wildcard * +NEW: Save filter of the project homepage +NEW: Select-able columns on customer invoice paymnet list +NEW: Select-able columns on miscellaneous payments + more data columns +NEW: Select-able columns on social taxes list +NEW: Select-able columns on supplier invoice payment list +NEW: send context and remove new lines on create ticket +NEW: set entity when creating invoice on takepos +NEW: Show available stock in TakePOS +NEW: Show category filter on lists only when user have rights to read categories +NEW: Show header number and make it clickable in warehouse arean, payment area, shipment area +NEW: Show image of user in the combo select of users +NEW: Show label on batch card +NEW: Show line number on intervention card (via MAIN_VIEW_LINE_NUMBER) +NEW: show links for select and multi-select in category extra field +NEW: Show module and permission ids on user/group rights (only admin) +NEW: Show place from events on import calender +NEW: Show references in contract form on interventions +NEW: Show tags and status in search list of website pages +NEW: Show user on external calender events (when found) +NEW: subject title with company name instead of application title in ticket message +NEW: Support for Samba4 AD +NEW: TakePOS connector compatibility with RECEIPT PRINTERS module +NEW: TakePOS Gift Receipt +NEW: TakePOS Multicurrency compatibility +NEW: The global header of a website can also have dynamic content +NEW: Third-Party Import new fields: mother company,outstanding debt limit,bank account,incoterms +NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding amount late +NEW: ticket classification on create from email collector +NEW: Ticket message notifications when edited from public interface +NEW: translate classification labels in ticket +NEW: triggers create, modify, delete +NEW: VAT for Algeria +NEW: Use preselect third-party from list on new card +NEW: Vat report - Invert constant to show by default zero vat in reports +NEW: website page fields selection +NEW: Weighing Scale compatibility with TakePOS connector +NEW: When creating a user from a member linked to a thirdparty, you can choose to create if as external or internal user +NEW: Add clone functionality on miscellaneous payment +For developers: +NEW: Can use dynamic code into the 'enabled' property of DAO fields +NEW: API Can update a payment +NEW: api get member by thirdparty +NEW: API get thirdparty by barcode +NEW: API get users by email / login +NEW: fetch contact by email with REST API +NEW: field ref_ext in llx_commandedet +NEW: fields ref_ext for Attributes and Combinations +NEW: get state by REST API +NEW: get state dictionnary by REST API +NEW: Improve Product API for variant products +NEW: Oauth SCOPE for Admin SDK +NEW: Retrieve discount from invoice from API +NEW: standardizes API thirdparties by email like other object +NEW: thirdparty REST API: endpoint to set price level +NEW: Use new category API for project list view +NEW: Triggers Attributes and Attributes values +NEW: Add hooks on newpayment page to allow external payment modules WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* Properties ->contactid have been renamed into ->contact_id -* Properties ->titre have been renamed into ->title -* Property $paiementid in API 'api_supplier_invoices.php' has been renamed into into $payment_mode_id (english) -* The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you used the old syntax in - your email templates. -* The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom - days of holiday. +* The object "livraison" has been renamed into "delivery" (directory, class, keys, methods with livraison in name ...). +* All properties ->contactid have been renamed into ->contact_id +* All properties ->titre have been renamed into ->title +* Property $paiementid in API 'api_supplier_invoices.php' has been renamed into into $payment_mode_id * Property 'num_paiement' has been renamed 'num_payment' everywhere for better code consistency. +* The deprecated subsitution key __SIGNATURE__ has been removed. Use __USER_SIGNATURE__ if you used the old syntax in your email templates. +* The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom days of holiday. * If you build a class that implement CommonObject to use the incoterm properties or methods (->fk_incoterm, ->label_incoterm, ->location_incoterm), - you must now also include declaration of the Trait 'CommonIncoterm' in your class. All incoterm functions were moved into this Trait. + you must now also include declaration of the Trait 'CommonIncoterm' in your class. All incoterm functions were moved into this Trait. * The GETPOST(..., 'alpha') has now the same behaviour than GETPOST(..., 'alphanohtml') so no html will be allowed. Use GETPOST(..., 'restricthtml') to accept HTML. -* If you have links in your code with '&action=delete' as a parameter, you must also add '&token='.newToken() as another parameter to avoid CSRF protection errors. -* The API addPayment for api_invoice has evolved to accept amount into a foreign currency. You must provide array(amount=>X,mutlicurrency_ammount=>Y) instead of amount. +* If you have links in your code with '&action=add', '&action=update', '&action=delete' as a parameter, you must also add '&token='.newToken() as another parameter to avoid CSRF protection errors. +* The API addPayment for api_invoice has evolved to accept amount into a foreign currency. You must provide array(amount=>X,mutlicurrency_ammount=>Y) instead of simple amount. * The method select_thirdparty(), deprecated since 3.8, into html.form.class.php has been removed. +* Depreciate all methods with name ->valide(). Use instead methods ->validate(). + ***** ChangeLog for 12.0.3 compared to 12.0.2 ***** FIX: 10.0 - when the mime file name is different from the filesystem name, the attachment name should be the mime filename @@ -383,28 +600,28 @@ Following changes may create regressions for some external modules, but were nec * Default mode for GETPOST function is now 'alphanohtml' instead of 'none'. So check when you make POST or GET requests with HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing the HTML code of content (in such a case, sanitize data later) -* Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless. -* Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced - by a "_" automatically when a reference (with a custom numbering mask that use it) is generated. +* Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless. +* Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced + by a "_" automatically when a reference (with a custom numbering mask that use it) is generated. * Library jflot (replace with chartjs) was removed. -* Library geoip (replaced with geoip2) was removed. +* Library geoip (replaced with geoip2) was removed. * Hidden constant COMMANDE_VALID_AFTER_CLOSE_PROPAL was renamed into ORDER_VALID_AFTER_CLOSE_PROPAL. * Object field ref_int is deprecated and set to 'not used', method to fetch object by only ref_int is not supported anymore. * UserGroup class has been refactored with new architecture. Triggers of class UserGroup are now USERGROUP_CREATE, USERGROUP_MODIFY, USERGROUP_DELETE * A new way to navigate between pages in list is available. To use it (not mandatory), you must: - - replace line $page = GETPOST('page', 'int') with $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); + - replace line $page = GETPOST('page', 'int') with $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - remove input field in form '';' - add parameter $pagenavastextinput to value 1 when calling print_barre_liste() WARNING FOR DOLIWAMP USERS ONLY: Only people that installed Dolibarr using the all-in-one auto-installer for Windows called "DoliWAMP" are concerned by the following warnings: - + * DoliWAMP auto-installer for Windows is no more available on 32 bits systems. Use standard package if you need to use such architecture. -* It is not possible to migrate from an installation done with the old DoliWAMP auto-installer for Windows by using this new one. - You must make a backup of your database, make a fresh installation using the new installer and reload your backup. - Don't forget that DoliWAMP is a good solution to make a quick test of Dolibarr on your local computer but is not recommended as a production - solution on a local desktop since a local desktop computer has often no backup and security policy, or not as good as on a server (when there is one). +* It is not possible to migrate from an installation done with the old DoliWAMP auto-installer for Windows by using this new one. + You must make a backup of your database, make a fresh installation using the new installer and reload your backup. + Don't forget that DoliWAMP is a good solution to make a quick test of Dolibarr on your local computer but is not recommended as a production + solution on a local desktop since a local desktop computer has often no backup and security policy, or not as good as on a server (when there is one). DoliWAMP remains a solution for fast test or demo purposes. Prefer using standard packages for production. @@ -568,7 +785,7 @@ FIX: #13118 FIX: #13124 FIX: #13131 FIX: #13135 -FIX: #13146 +FIX: #13146 FIX: #13198 FIX: #13175 FIX: #13182 @@ -635,7 +852,7 @@ FIX: Confusion between 'bank reconciled' and 'accounted'. Show both data. FIX: Count of Stripe payment mode must take test/live into account FIX: Creation of Stripe card from backoffice must return a clean message FIX: CVE-2019–17223 -FIX: CVE-2019–17223 +FIX: CVE-2019–17223 FIX: CVE-2020-7994 FIX: CVE Need permission to be able to develop modules FIX: #13053 @@ -835,7 +1052,7 @@ NEW: #4301 For Developers or integrators: -NEW: Compatible with PHP 7.4 +NEW: Compatible with PHP 7.4 NEW: Code for extrafields uses the new array $extrafields->attributes NEW: Can set a filter on object linked in modulebuilder. NEW: Can defined a position of numbering submodules for thirdparties @@ -902,9 +1119,9 @@ Following changes may create regressions for some external modules, but were nec * Removed function dol_micro_time. Use native PHP microtime instead. * The trigger BON_PRELEVEMENT_CREATE has been renamed into DIRECT_DEBIT_ORDER_CREATE. * The constant INVOICE_SHOW_POS_IN_EXPORT has been renamed into INVOICE_SHOW_POS. -* If your logo is no more visible on the menu bar, you must upload a new logo into 'Home-Setup-Company/Organization' to have it visible again. -* All properties 'libstatut', 'labelstatut', 'labelstatus' were renamed into 'labelStatus'. -* All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'. +* If your logo is no more visible on the menu bar, you must upload a new logo into 'Home-Setup-Company/Organization' to have it visible again. +* All properties 'libstatut', 'labelstatut', 'labelstatus' were renamed into 'labelStatus'. +* All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'. * All properties 'type_libelle' were renamed into 'type_label'. * Renamed property of thirdparty "statut_commercial" into "status_prospect_label" * The jquery plugin/dependency multiselect has been removed. It was not used by Dolibarr core. @@ -1054,11 +1271,11 @@ FIX: wrong invoice id for fetchObjetctLinked ***** ChangeLog for 10.0.3 compared to 10.0.2 ***** IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card. -The unit were not saved correctly in database making calculation on shipments wrong. +The unit were not saved correctly in database making calculation on shipments wrong. Update to this version must be done if you use them and have installed version 10.0.0, 10.0.1 or 10.0.2 and set some products after installing or upgrading to one of this version. Once update is done you must then edit (manually) the product that has bad unit to set the correct unit to have features restored. -FIX: #11702 +FIX: #11702 FIX: #11861 No consistent code to manage measuring units FIX: #11942 FIX: #12026 @@ -1120,7 +1337,7 @@ FIX: wrong test FIX: XSS FIX: Payment from POS ware not recorded. FIX: Can validate invoice with amount including tax of zero for the case of having a final invoice with - VAT that includes a deposit without vat. + VAT that includes a deposit without vat. ***** ChangeLog for 10.0.2 compared to 10.0.1 ***** FIX: #10460 compatibility with MariaDB 10.4 @@ -1223,14 +1440,14 @@ FIX: Wrong variable. Must be PROJECT_HIDE_UNSELECTABLES ***** ChangeLog for 10.0.1 compared to 10.0.0 ***** FIX: #10930 -FIX: #10984 +FIX: #10984 FIX: reposition on "Build backup" button FIX: #11400 FIX: #11412 -FIX: #11460 +FIX: #11460 FIX: #11463 FIX: #11466 -FIX: #11492 +FIX: #11492 FIX: #11498 FIX: #11505 FIX: #11506 @@ -1239,7 +1456,7 @@ FIX: #11509 FIX: #11537 FIX: #11543 FIX: #11553 -FIX: #11576 +FIX: #11576 FIX: #11584 FIX: #11590 FIX: accounting mode must be taken from global conf, because there's no way to choose a mode with interface @@ -1332,14 +1549,14 @@ FIX: wrong path sociales/index.php doesnt exist anymore ***** ChangeLog for 10.0.1 compared to 10.0.0 ***** FIX: #10930 -FIX: #10984 +FIX: #10984 FIX: reposition on "Build backup" button FIX: #11400 FIX: #11412 -FIX: #11460 +FIX: #11460 FIX: #11463 FIX: #11466 -FIX: #11492 +FIX: #11492 FIX: #11498 FIX: #11505 FIX: #11506 @@ -1348,7 +1565,7 @@ FIX: #11509 FIX: #11537 FIX: #11543 FIX: #11553 -FIX: #11576 +FIX: #11576 FIX: #11584 FIX: #11590 FIX: accounting mode must be taken from global conf, because there's no way to choose a mode with interface @@ -1517,7 +1734,7 @@ NEW: Manage account sell_intra & sell_export in page accoutancy admin default pr NEW: Manage loan schedule. NEW: Manage status of member types. NEW: Mass action "create bills" for validated reception -NEW: Measuring unit are now defined into an editable dictionary. Add product size/unit into product import. +NEW: Measuring unit are now defined into an editable dictionary. Add product size/unit into product import. NEW: Template pdf 'canelle_reception' displays linked reception lines. NEW: Moral/physic status can be defined at member type level NEW: Pagination into list of time spent. @@ -1580,7 +1797,7 @@ NEW: Enhance management of webhooks NEW: Generation of doc by modulebuilder can include README and CHANGELOG NEW: massfilesarea feature is possible for external modules NEW: Show list of enabled modules in dol_print_error(). -NEW: Simplification of CSS styles of default themes. +NEW: Simplification of CSS styles of default themes. NEW: Clean code of a lot of deprecated code. NEW: Add hidden option to set a search entry to the top NEW: add hidden option DISPLAY_DISCOUNTED_SUPPLIER_PRICE @@ -1600,8 +1817,8 @@ Following changes may create regressions for some external modules, but were nec * The PHP extension php-intl is not mandatory and must be installed to have new features working correctly. * Method GetUrlTrackingStatus were renamed into getUrlTrackingStatus for consistency with naming rules. * API getListOfCivility has been renamed into getListOfCivilities for consistency with naming rules. -* Deprecated function img_phone as been removed. You can use img_picto(..., 'call|call_out') instead.; -* Files for variables of themes were renamed from graph-color.php into theme_vars.inc.php to match naming +* Deprecated function img_phone as been removed. You can use img_picto(..., 'call|call_out') instead.; +* Files for variables of themes were renamed from graph-color.php into theme_vars.inc.php to match naming convention of extension .inc.php for files to be included. * All methods set_draft() were renamed into setDraft(). * Signatures of methods createFromClone() has been standardized. All methods requires the object User as first parameter. @@ -1613,7 +1830,7 @@ Following changes may create regressions for some external modules, but were nec * Deprecated property ->fk_departement is now ->state_id everywhere. * Removed the method 4 of GETPOST (to get $_COOKIE). It was not used and not recommanded to use in Dolibarr. * Column llx_facture.facnumber change to llx_facture.ref -* Variable $dolibarr_main_cookie_cryptkey is no more created at install (it was not used by Dolibarr). A new variable +* Variable $dolibarr_main_cookie_cryptkey is no more created at install (it was not used by Dolibarr). A new variable called $dolibarr_main_instance_unique_id is now generated at each installation. It will be used by some future features. @@ -3385,7 +3602,7 @@ Following changes may create regression for some external modules, but were nece entities and to review completely the rights of the groups and the users. * Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx') * Some other change were done in the way we read permission of a user when module multicompany is enabled. You can - retreive the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1. + retrieve the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1. * The hook formObjectOptions was not implemented correctly in previous version. Sometimes, you had to return output content by doing a print into function, sometimes by returning content into "resprint". This has been fixed to follow hook specifications so you must return output into "resprint". @@ -6131,7 +6348,7 @@ For users: - Fix: [Bug #958] LocalTax2 for Spain fails on Suppliers - Fix: [ bug #972 ] Auto completion contact field do not take account the min caract number before search - Fix: [ bug #971 ] html.form.class.php select_contact with autocomplete do not exclude id from exclude array -- Fix: Expedition creation, can retreive product from other expedition +- Fix: Expedition creation, can retrieve product from other expedition For translators: - Update language files. diff --git a/README-FR.md b/README-FR.md index bccb7b0143b..77bb5a3e27a 100644 --- a/README-FR.md +++ b/README-FR.md @@ -6,7 +6,7 @@ Dolibarr ERP & CRM est un logiciel moderne pour gérer votre activité (société, association, auto-entrepreneurs, artisans). Il est simple d'utilisation et modulaire, vous permettant de n'activez que les fonctions dont vous avez besoin (contacts, fournisseurs, factures, commandes, stocks, agenda, ...). -![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_1920x1080.jpg) +![ScreenShot](https://www.dolibarr.org/medias/dolibarr_screenshot1_1920x1080.jpg) ## LICENCE diff --git a/README.md b/README.md index 648d5ef003d..ac8f1d06382 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ ![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg) ![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) +[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg?style=flat-square)](https://php.net/) +[![GitHub release](https://img.shields.io/github/v/release/Dolibarr/dolibarr)](https://github.com/Dolibarr/dolibarr) Dolibarr ERP & CRM is a modern software package that helps manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…). @@ -13,7 +15,7 @@ You can use it as a standalone application or as a web application to access it Dolibarr has a large community ready to help you, free forums and [oficially preferred partners ready to offer commercial support should you need it](https://partners.dolibarr.org) -![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_1920x1080.jpg) +![ScreenShot](https://www.dolibarr.org/medias/dolibarr_screenshot1_1920x1080.jpg) ## LICENSE diff --git a/build/debian/conf.php.install b/build/debian/conf.php.install index 6741d7ea544..c373664deef 100644 --- a/build/debian/conf.php.install +++ b/build/debian/conf.php.install @@ -232,7 +232,7 @@ $dolibarr_main_prod='0'; # Examples: # $dolibarr_mailing_limit_sendbycli='0'; -# dolibarr_distrib +# dolibarr_main_distrib # A key to identify the distribution used for first installation -$dolibarr_distrib = 'deb'; +$dolibarr_main_distrib = 'debian'; diff --git a/build/debian/install.forced.php.install b/build/debian/install.forced.php.install index e55ffae138e..0cb02c2342d 100644 --- a/build/debian/install.forced.php.install +++ b/build/debian/install.forced.php.install @@ -24,6 +24,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='444'; +$force_install_distrib='debian'; // Value to overwrite path to use shared libraries/fonts instead of embedded one. // If during install, we enable/disable declaration to use non embedded libraries, we must also check they are diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 2be287c2db9..dca74e9e720 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -20,6 +20,9 @@ RUN apt-get update -y \ unzip \ curl \ apt-utils \ + msmtp \ + msmtp-mta \ + mailutils \ && apt-get autoremove -y \ && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ @@ -44,7 +47,17 @@ RUN echo 'xdebug.remote_port=9000' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_connect_back=1' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini -#RUN echo '172.17.0.1 docker.host' >> /etc/hosts +#RUN echo 'localhost docker.host' >> /etc/hosts + +# set up sendmail config, to use maildev +RUN echo "account default" > /etc/msmtprc +RUN echo "auth off" >> /etc/msmtprc +RUN echo "port 25" >> /etc/msmtprc +RUN echo "host mail" >> /etc/msmtprc +RUN echo "from local@localdomain.com" >> /etc/msmtprc +RUN echo "domain localhost.localdomain" >> /etc/msmtprc +RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini +RUN echo "localhost localhost.localdomain" >> /etc/hosts EXPOSE 80 diff --git a/build/docker/README.md b/build/docker/README.md index 2fd278a531f..d469c7c7aae 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -16,7 +16,7 @@ And then, you can run : docker-compose up -This will run 3 container Docker : Dolibarr, MariaDB and PhpMyAdmin. +This will run 4 containers Docker : Dolibarr, MariaDB, PhpMyAdmin and MailDev. The URL to go to the Dolibarr is : @@ -25,7 +25,10 @@ The URL to go to the Dolibarr is : The URL to go to PhpMyAdmin is (login/password is root/root) : http://0.0.0.0:8080 + +In Dolibarr configuration Email let PHP mail function, To see all mail send by Dolibarr go to maildev -Setup the database connection during the installation process, please use mariad -b (name of the database container) as database host. + http://0.0.0.0:8081 + +Setup the database connection during the installation process, please use mariadb (name of the database container) as database host. Setup documents folder, during the installation process, to /var/documents diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index 7e4ceda902e..2167f069f25 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -52,3 +52,6 @@ services: ports: - "8081:80" - "25:25" + networks: + - internal-pod + - external-pod diff --git a/build/exe/doliwamp/install.forced.php.install b/build/exe/doliwamp/install.forced.php.install index c59b373a7a0..8947154a57b 100644 --- a/build/exe/doliwamp/install.forced.php.install +++ b/build/exe/doliwamp/install.forced.php.install @@ -22,6 +22,7 @@ $force_install_databaserootpass='WAMPMYSQLNEWPASSWORD'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='644'; +$force_install_distrib='doliwamp'; $force_install_module=''; ?> \ No newline at end of file diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 039dafd198f..628ef917c05 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -181,6 +181,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/datapolicy %_datadir/dolibarr/htdocs/dav %_datadir/dolibarr/htdocs/debugbar +%_datadir/dolibarr/htdocs/delivery %_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/emailcollector @@ -198,7 +199,6 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/install %_datadir/dolibarr/htdocs/intracommreport %_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt -%_datadir/dolibarr/htdocs/livraison %_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/margin diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 098a041680a..aefc375d961 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -261,6 +261,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/datapolicy %_datadir/dolibarr/htdocs/dav %_datadir/dolibarr/htdocs/debugbar +%_datadir/dolibarr/htdocs/delivery %_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/emailcollector @@ -278,7 +279,6 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/install %_datadir/dolibarr/htdocs/intracommreport %_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt -%_datadir/dolibarr/htdocs/livraison %_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/margin diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index a3f2d1d8d96..bcccb7c02a4 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -177,6 +177,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/custom %_datadir/dolibarr/htdocs/datapolicy %_datadir/dolibarr/htdocs/dav +%_datadir/dolibarr/htdocs/delivery %_datadir/dolibarr/htdocs/debugbar %_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm @@ -195,7 +196,6 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/install %_datadir/dolibarr/htdocs/intracommreport %_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt -%_datadir/dolibarr/htdocs/livraison %_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/margin diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 5b1b86b28f4..8a55dd84faa 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -189,6 +189,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/datapolicy %_datadir/dolibarr/htdocs/dav %_datadir/dolibarr/htdocs/debugbar +%_datadir/dolibarr/htdocs/delivery %_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/emailcollector @@ -206,7 +207,6 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/install %_datadir/dolibarr/htdocs/intracommreport %_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt -%_datadir/dolibarr/htdocs/livraison %_datadir/dolibarr/htdocs/loan %_datadir/dolibarr/htdocs/mailmanspip %_datadir/dolibarr/htdocs/margin diff --git a/build/rpm/install.forced.php.fedora b/build/rpm/install.forced.php.fedora index a8db3e25c9e..4d25010a533 100644 --- a/build/rpm/install.forced.php.fedora +++ b/build/rpm/install.forced.php.fedora @@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='444'; +$force_install_distrib='rpmfedora'; // Value to overwrite path to use shared libraries/fonts instead of embedded one $force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; diff --git a/build/rpm/install.forced.php.generic b/build/rpm/install.forced.php.generic index 107ef533310..20ec33a1af0 100644 --- a/build/rpm/install.forced.php.generic +++ b/build/rpm/install.forced.php.generic @@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='444'; +$force_install_distrib='rpmgeneric'; // Value to overwrite path to use shared libraries/fonts instead of embedded one // We don't force any external lib with generic package diff --git a/build/rpm/install.forced.php.mandriva b/build/rpm/install.forced.php.mandriva index 927877b59d0..835f5f45570 100644 --- a/build/rpm/install.forced.php.mandriva +++ b/build/rpm/install.forced.php.mandriva @@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='444'; +$force_install_distrib='rpmmandriva'; // Value to overwrite path to use shared libraries/fonts instead of embedded one $force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; diff --git a/build/rpm/install.forced.php.opensuse b/build/rpm/install.forced.php.opensuse index c91836918f4..b3cab5a0e4d 100644 --- a/build/rpm/install.forced.php.opensuse +++ b/build/rpm/install.forced.php.opensuse @@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__'; $force_install_dolibarrlogin='admin'; $force_install_nophpinfo='1'; $force_install_lockinstall='444'; +$force_install_distrib='rpmopensuse'; // Value to overwrite path to use shared libraries/fonts instead of embedded one //$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; diff --git a/dev/examples/zapier/.editorconfig b/dev/examples/zapier/.editorconfig new file mode 100644 index 00000000000..9228bbb156b --- /dev/null +++ b/dev/examples/zapier/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig is awesome: https://editorconfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf + +[*.js] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = false diff --git a/dev/examples/zapier/.gitignore b/dev/examples/zapier/.gitignore index d81e057e6d3..3e9263e351f 100644 --- a/dev/examples/zapier/.gitignore +++ b/dev/examples/zapier/.gitignore @@ -5,3 +5,4 @@ node_modules .environment .env .zapierapprc +package-lock.json diff --git a/dev/examples/zapier/README.md b/dev/examples/zapier/README.md new file mode 100644 index 00000000000..453a5224993 --- /dev/null +++ b/dev/examples/zapier/README.md @@ -0,0 +1,68 @@ +# HOW TO BUILD + + +## ENABLE MODULE ZAPIER ON DOLIBARR + +This should also enable the module API (required for authentication by Zapier service and to execute action in Dolibarr by Zapier). + +Create the Dolibarr login that will be used by Zapier to call APIs. Give the login the permissions on the action you plan to automate. + + +## CREATE A ZAPIER DEVELOPPER ACCOUNT + +At first, you need to have a Zapier developper acoount, create it here [Zapier Platform](https://developer.zapier.com/) + + +## INSTALL ZAPIER COMMAND LINE TOOLS WITH LINK TO ZAPIER ONLINE ACCOUNT + +### Install Node.js + +An easy option to get set up with Node.js is to visit [https://nodejs.org/en/download/](https://nodejs.org/en/download/) and download the official installer for your OS. If you're installing with a package manager it's even easier. + +After installation, confirm that Node.js is ready to use: + `node --version` + +### Install the Zapier CLI + +Next let's install the Zapier CLI tools. The CLI will allow you to build your app, deploy it to the Zapier platform, do local testing, manage users and testers, view remote logs, collaborate with your team, and more: + + `cd dev/examples/zapier` + + `npm install -g zapier-platform-cli` to install the CLI globally + + `zapier --version` to return version of the CLI + +### Run Zapier Login + +Let's configure authentication between your dev environment and the Zapier platform. You'll use the email address and password you use to log in to the Zapier application. + + `zapier login` + +This command will set up a .zapierrc file in your home directory. + +### Install the Project + +In zapier example directory, run: + + `cd dev/examples/zapier` + + `npm install` + +### Deploying your App + +Let's deploy it! When you're ready to try your code out on the Zapier platform use the push command. Only you will be able to see the app until you invite testers. + + `zapier register` (the first time, choose name for example "Dolibarr") + + `zapier push` + +After a push, the Application, with the name you defined during the register step, is available when creating a Zap. + +You will find original tutorial here : [https://zapier.com/developer/start/introduction](https://zapier.com/developer/start/introduction) + + +### Create a Zap + +Create a ZAP that use the application you registered. +For authentication, you must enter the login / pass of account used by Zapier to call APIs. + diff --git a/dev/examples/zapier/authentication.js b/dev/examples/zapier/authentication.js index 1c95c76f9c2..fceedd4ab5f 100644 --- a/dev/examples/zapier/authentication.js +++ b/dev/examples/zapier/authentication.js @@ -1,6 +1,6 @@ /*jshint esversion: 6 */ -const testAuth = (z , bundle) => { - const url = bundle.authData.url+'/api/index.php/login'; +const test = (z , bundle) => { + const url = bundle.authData.url+'/api/index.php/status'; // Normally you want to make a request to an endpoint that is either specifically designed to test auth, or one that // every user will have access to, such as an account or profile endpoint like /me. // In this example, we'll hit httpbin, which validates the Authorization Header against the arguments passed in the URL path @@ -11,67 +11,92 @@ const testAuth = (z , bundle) => { // This method can return any truthy value to indicate the credentials are valid. // Raise an error to show return promise.then((response) => { - if (response.status === 401) { - throw new Error('The Session Key you supplied is invalid'); + if (response.status === 400) { + throw new Error('400 -The Session Key you supplied is invalid'); + } + if (response.status === 403) { + throw new Error('403 -The Session Key you supplied is invalid'); } return response; }); }; -const getSessionKey = (z, bundle) => { +// To include the session key header on all outbound requests, simply define a function here. +// It runs runs before each request is sent out, allowing you to make tweaks to the request in a centralized spot +const includeSessionKeyHeader = (request, z, bundle) => { + if (bundle.authData.sessionKey) { + request.headers = request.headers || {}; + request.headers['DOLAPIKEY'] = bundle.authData.sessionKey; + } + return request; +}; + +// If we get a response and it is a 401, we can raise a special error telling Zapier to retry this after another exchange. +const sessionRefreshIf401 = (response, z, bundle) => { + if (bundle.authData.sessionKey) { + if (response.status === 401) { + throw new z.errors.RefreshAuthError('Session apikey needs refreshing.'); + } + } + return response; +}; + +const getSessionKey = async (z, bundle) => { const url = bundle.authData.url + '/api/index.php/login'; - const promise = z.request({ - method: 'POST', + const response = await z.request({ url: url, + method: 'POST', body: { login: bundle.authData.login, password: bundle.authData.password, - } + }, }); - return promise.then((response) => { - if (response.status === 401) { - throw new Error('The login/password you supplied is invalid'); - } - const json = JSON.parse(response.content); - return { - sessionKey: json.success.token || 'secret' - }; - }); + // if (response.status === 401) { + // throw new Error('The login/password you supplied is invalid'); + // } + const json = JSON.parse(response.content); + return { + sessionKey: json.success.token || '', + }; }; module.exports = { - type: 'session', - // Define any auth fields your app requires here. The user will be prompted to enter this info when - // they connect their account. - fields: [ - { - key: 'url', - label: 'Url of service', - required: true, - type: 'string' + config: { + type: 'session', + sessionConfig: { + perform: getSessionKey }, - { - key: 'login', - label: 'Login', - required: true, - type: 'string' - }, - { - key: 'password', - label: 'Password', - required: true, - type: 'password' - } - ], - // The test method allows Zapier to verify that the credentials a user provides are valid. We'll execute this - // method whenever a user connects their account for the first time. - test: testAuth, - // The method that will exchange the fields provided by the user for session credentials. - sessionConfig: { - perform: getSessionKey + // Define any auth fields your app requires here. The user will be prompted to enter this info when + // they connect their account. + fields: [ + { + key: 'url', + label: 'Url of service without trailing-slash', + required: true, + type: 'string' + }, + { + key: 'login', + label: 'Login', + required: true, + type: 'string' + }, + { + key: 'password', + label: 'Password', + required: true, + type: 'password' + } + ], + // The test method allows Zapier to verify that the credentials a user provides are valid. We'll execute this + // method whenever a user connects their account for the first time. + test, + // The method that will exchange the fields provided by the user for session credentials. + // assuming "login" is a key returned from the test + connectionLabel: '{{login}}' }, - // assuming "login" is a key returned from the test - connectionLabel: '{{login}}' + befores: [includeSessionKeyHeader], + afters: [sessionRefreshIf401], }; diff --git a/dev/examples/zapier/creates/thirdparty.js b/dev/examples/zapier/creates/thirdparty.js index 82cc39f8fab..3e20fd10e41 100644 --- a/dev/examples/zapier/creates/thirdparty.js +++ b/dev/examples/zapier/creates/thirdparty.js @@ -72,7 +72,7 @@ module.exports = { }, outputFields: [ - {key: 'id', label: 'ID'}, + {key: 'id', type: "integer", label: 'ID'}, {key: 'name', label: 'Name'}, {key: 'name_alias', label: 'Name alias'}, {key: 'address', label: 'Address'}, @@ -81,8 +81,8 @@ module.exports = { {key: 'phone', label: 'Phone'}, {key: 'fax', label: 'Fax'}, {key: 'email', label: 'Email'}, - {key: 'client', label: 'Customer/Prospect 0/1/2/3'}, - {key: 'fournisseur', label: 'Supplier 0/1'}, + {key: 'client', type: "integer", label: 'Customer/Prospect 0/1/2/3'}, + {key: 'fournisseur', type: "integer", label: 'Supplier 0/1'}, {key: 'code_client', label: 'Customer code'}, {key: 'code_fournisseur', label: 'Supplier code'} ] diff --git a/dev/examples/zapier/index.js b/dev/examples/zapier/index.js index fc452a196e6..d1897673b39 100644 --- a/dev/examples/zapier/index.js +++ b/dev/examples/zapier/index.js @@ -1,33 +1,39 @@ /*jshint esversion: 6 */ -const triggerThirdparty = require('./triggers/thirdparty'); -const triggerOrder = require('./triggers/order'); const triggerAction = require('./triggers/action'); +const triggerOrder = require('./triggers/order'); +const triggerThirdparty = require('./triggers/thirdparty'); +const triggerTicket = require('./triggers/ticket'); +const triggerUser = require('./triggers/user'); const searchThirdparty = require('./searches/thirdparty'); const createThirdparty = require('./creates/thirdparty'); -const authentication = require('./authentication'); +const { + config: authentication, + befores = [], + afters = [], +} = require('./authentication'); // To include the session key header on all outbound requests, simply define a function here. // It runs runs before each request is sent out, allowing you to make tweaks to the request in a centralized spot -const includeSessionKeyHeader = (request, z, bundle) => { - if (bundle.authData.sessionKey) { - request.headers = request.headers || {}; - request.headers['DOLAPIKEY'] = bundle.authData.sessionKey; - } - return request; -}; +// const includeSessionKeyHeader = (request, z, bundle) => { +// if (bundle.authData.sessionKey) { +// request.headers = request.headers || {}; +// request.headers['DOLAPIKEY'] = bundle.authData.sessionKey; +// } +// return request; +// }; // If we get a response and it is a 401, we can raise a special error telling Zapier to retry this after another exchange. -const sessionRefreshIf401 = (response, z, bundle) => { - if (bundle.authData.sessionKey) { - if (response.status === 401) { - throw new z.errors.RefreshAuthError('Session apikey needs refreshing.'); - } - } - return response; -}; +// const sessionRefreshIf401 = (response, z, bundle) => { +// if (bundle.authData.sessionKey) { +// if (response.status === 401) { +// throw new z.errors.RefreshAuthError('Session apikey needs refreshing.'); +// } +// } +// return response; +// }; // We can roll up all our behaviors in an App. const App = { @@ -40,11 +46,11 @@ const App = { // beforeRequest & afterResponse are optional hooks into the provided HTTP client beforeRequest: [ - includeSessionKeyHeader + ...befores ], afterResponse: [ - sessionRefreshIf401 + ...afters ], // If you want to define optional resources to simplify creation of triggers, searches, creates - do that here! @@ -53,9 +59,11 @@ const App = { // If you want your trigger to show up, you better include it here! triggers: { - [triggerThirdparty.key]: triggerThirdparty, + [triggerAction.key]: triggerAction, [triggerOrder.key]: triggerOrder, - [triggerAction.key]: triggerAction + [triggerThirdparty.key]: triggerThirdparty, + [triggerTicket.key]: triggerTicket, + [triggerUser.key]: triggerUser, }, // If you want your searches to show up, you better include it here! diff --git a/dev/examples/zapier/package-lock.json b/dev/examples/zapier/package-lock.json deleted file mode 100644 index 7483948d5b8..00000000000 --- a/dev/examples/zapier/package-lock.json +++ /dev/null @@ -1,405 +0,0 @@ -{ - "name": "Dolibarr", - "version": "1.0.2", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@types/node": { - "version": "8.10.20", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.20.tgz", - "integrity": "sha512-M7x8+5D1k/CuA6jhiwuSCmE8sbUWJF0wYsjcig9WrXvwUI5ArEoUBdOXpV4JcEMrLp02/QbDjw+kI+vQeKyQgg==", - "optional": true - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "bluebird": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", - "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=" - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "combined-stream": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "content-disposition": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", - "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, - "dotenv": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-5.0.1.tgz", - "integrity": "sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow==" - }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "requires": { - "iconv-lite": "~0.4.13" - } - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "1.0.6", - "mime-types": "^2.1.12" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "json-tryparse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/json-tryparse/-/json-tryparse-1.0.5.tgz", - "integrity": "sha1-Khy6CLTjEjNo+p+2o01GQwBFeyc=" - }, - "jsonschema": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.1.1.tgz", - "integrity": "sha1-PO3o4+QR03eHLu+8n98mODy8Ptk=" - }, - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" - }, - "mime-db": { - "version": "1.38.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", - "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" - }, - "mime-types": { - "version": "2.1.22", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", - "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", - "requires": { - "mime-db": "~1.38.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", - "dev": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "node-fetch": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.1.tgz", - "integrity": "sha512-j8XsFGCLw79vWXkZtMSmmLaOk9z5SQ9bV/tkbZVCqvgwzrjAGq66igobLofHtF63NvMTp2WjytpsNTGKa+XRIQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } - }, - "oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" - }, - "should": { - "version": "13.2.3", - "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", - "integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==", - "dev": true, - "requires": { - "should-equal": "^2.0.0", - "should-format": "^3.0.3", - "should-type": "^1.4.0", - "should-type-adaptors": "^1.0.1", - "should-util": "^1.0.0" - } - }, - "should-equal": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz", - "integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==", - "dev": true, - "requires": { - "should-type": "^1.4.0" - } - }, - "should-format": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz", - "integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=", - "dev": true, - "requires": { - "should-type": "^1.3.0", - "should-type-adaptors": "^1.0.1" - } - }, - "should-type": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz", - "integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=", - "dev": true - }, - "should-type-adaptors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz", - "integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==", - "dev": true, - "requires": { - "should-type": "^1.3.0", - "should-util": "^1.0.0" - } - }, - "should-util": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz", - "integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=", - "dev": true - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "zapier-platform-core": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/zapier-platform-core/-/zapier-platform-core-8.0.1.tgz", - "integrity": "sha512-vuAe7JkFQ88AeQ//NwwNEh8ZjiZr30GRWtwYo7Wo/nx1cqZwq+CRc9zJU2WRrhJfJOtOOTUF6w+pArBTtMOC5A==", - "requires": { - "@types/node": "8.10.20", - "bluebird": "3.5.0", - "content-disposition": "0.5.2", - "dotenv": "5.0.1", - "form-data": "2.3.2", - "lodash": "4.17.11", - "node-fetch": "1.7.1", - "oauth-sign": "0.9.0", - "semver": "5.6.0", - "zapier-platform-schema": "8.0.1" - } - }, - "zapier-platform-schema": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/zapier-platform-schema/-/zapier-platform-schema-8.0.1.tgz", - "integrity": "sha512-97KJ0xVLtpU4BiXVaMTPQpiA0T6CQIEzWfzAWwJAWbu5336+6DMFUzDWN4bANBeD3CIsRHHPcZkP8n/17U05ag==", - "requires": { - "jsonschema": "1.1.1", - "lodash": "4.17.10" - }, - "dependencies": { - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" - } - } - } - } -} diff --git a/dev/examples/zapier/package.json b/dev/examples/zapier/package.json index 8fbd203f962..5b5827b22b2 100644 --- a/dev/examples/zapier/package.json +++ b/dev/examples/zapier/package.json @@ -1,9 +1,9 @@ { - "name": "Dolibarr", - "version": "1.0.0", + "name": "dolibarr", + "version": "1.13.0", "description": "An app for connecting Dolibarr to the Zapier platform.", "repository": "Dolibarr/dolibarr", - "homepage": "https://www.dolibarr.fr/", + "homepage": "https://www.dolibarr.org/", "author": "Frédéric France ", "license": "BSD-3-Clause", "main": "index.js", @@ -15,7 +15,7 @@ "npm": ">=5.6.0" }, "dependencies": { - "zapier-platform-core": "8.0.1" + "zapier-platform-core": "10.1.1" }, "devDependencies": { "mocha": "^5.2.0", diff --git a/dev/examples/zapier/searches/thirdparty.js b/dev/examples/zapier/searches/thirdparty.js index c71c2965789..8f72b9270e5 100644 --- a/dev/examples/zapier/searches/thirdparty.js +++ b/dev/examples/zapier/searches/thirdparty.js @@ -54,13 +54,20 @@ module.exports = { // outputFields: () => { return []; } // Alternatively, a static field definition should be provided, to specify labels for the fields outputFields: [ - {key: 'id', label: 'ID'}, - {key: 'createdAt', label: 'Created At'}, + { + key: 'id', + type: "integer", + label: 'ID' + }, + {key: 'createdAt', type: "integer", label: 'Created At'}, {key: 'name', label: 'Name'}, {key: 'firstname', label: 'Firstname'}, {key: 'directions', label: 'Directions'}, - {key: 'authorId', label: 'Author ID'}, - {key: 'style', label: 'Style'} + {key: 'authorId', type: "integer", label: 'Author ID'}, + { + key: 'style', + label: 'Style' + } ] } }; diff --git a/dev/examples/zapier/triggers/action.js b/dev/examples/zapier/triggers/action.js index d387d88ec1f..0e152473869 100644 --- a/dev/examples/zapier/triggers/action.js +++ b/dev/examples/zapier/triggers/action.js @@ -10,14 +10,14 @@ const subscribeHook = (z, bundle) => { action: bundle.inputData.action }; - const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. const options = { url: url, method: 'POST', - body: JSON.stringify(data) + body: data, }; // You may return a promise or a normal data structure from any perform method. @@ -32,7 +32,7 @@ const unsubscribeHook = (z, bundle) => { // You can build requests and our client will helpfully inject all the variables // you need to complete. You can also register middleware to control this. const options = { - url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, method: 'DELETE', }; @@ -74,7 +74,7 @@ const getFallbackRealAction = (z, bundle) => { // For the test poll, you should get some real data, to aid the setup process. const module = bundle.inputData.module; const options = { - url: bundle.authData.url + '/api/index.php/agendaevents/0', + url: bundle.authData.url + '/api/index.php/agendaevents/0', }; return z.request(options).then((response) => [JSON.parse(response.content)]); @@ -100,7 +100,7 @@ module.exports = { noun: 'Action', display: { label: 'New Agenda', - description: 'Trigger when a new agenda with action is done in Dolibarr.' + description: 'Triggers when a new agenda with action is done in Dolibarr.' }, // `operation` is where the business logic goes. @@ -111,6 +111,7 @@ module.exports = { inputFields: [ { key: 'action', + required: true, type: 'string', helpText: 'Which action of agenda this should trigger on.', choices: { @@ -145,12 +146,33 @@ module.exports = { // outputFields: () => { return []; } // Alternatively, a static field definition should be provided, to specify labels for the fields outputFields: [ - {key: 'id', label: 'ID'}, - {key: 'createdAt', label: 'Created At'}, - {key: 'name', label: 'Name'}, - {key: 'usertodo__name', label: 'UserToDo Name'}, - {key: 'authorId', label: 'Author ID'}, - {key: 'action', label: 'Action'} + { + key: 'id', + type: "integer", + label: 'ID' + }, + { + key: 'createdAt', + type: "integer", + label: 'Created At' + }, + { + key: 'name', + label: 'Name' + }, + { + key: 'usertodo__name', + label: 'UserToDo Name' + }, + { + key: 'authorId', + type: "integer", + label: 'Author ID' + }, + { + key: 'action', + label: 'Action' + } ] } }; diff --git a/dev/examples/zapier/triggers/order.js b/dev/examples/zapier/triggers/order.js index 6262d734edc..061ce218d10 100644 --- a/dev/examples/zapier/triggers/order.js +++ b/dev/examples/zapier/triggers/order.js @@ -17,7 +17,7 @@ const subscribeHook = (z, bundle) => { const options = { url: url, method: 'POST', - body: JSON.stringify(data) + body: data, }; // You may return a promise or a normal data structure from any perform method. @@ -90,7 +90,7 @@ module.exports = { noun: 'Order', display: { label: 'New Order', - description: 'Trigger when a new order with action is done in Dolibarr.' + description: 'Triggers when a new order with action is done in Dolibarr.' }, // `operation` is where the business logic goes. @@ -101,6 +101,7 @@ module.exports = { inputFields: [ { key: 'action', + required: true, type: 'string', helpText: 'Which action of order this should trigger on.', choices: { @@ -136,11 +137,11 @@ module.exports = { // outputFields: () => { return []; } // Alternatively, a static field definition should be provided, to specify labels for the fields outputFields: [ - {key: 'id', label: 'ID'}, - {key: 'createdAt', label: 'Created At'}, + {key: 'id', type: "integer", label: 'ID'}, + {key: 'createdAt', type: "integer", label: 'Created At'}, {key: 'name', label: 'Name'}, {key: 'directions', label: 'Directions'}, - {key: 'authorId', label: 'Author ID'}, + {key: 'authorId', type: "integer", label: 'Author ID'}, {key: 'module', label: 'Module'}, {key: 'action', label: 'Action'} ] diff --git a/dev/examples/zapier/triggers/thirdparty.js b/dev/examples/zapier/triggers/thirdparty.js index 4b13e23ff1c..4656f836e74 100644 --- a/dev/examples/zapier/triggers/thirdparty.js +++ b/dev/examples/zapier/triggers/thirdparty.js @@ -17,7 +17,7 @@ const subscribeHook = (z, bundle) => { const options = { url: url, method: 'POST', - body: JSON.stringify(data) + body: data, }; // You may return a promise or a normal data structure from any perform method. @@ -112,7 +112,7 @@ module.exports = { noun: 'Thirdparty', display: { label: 'New Thirdparty', - description: 'Trigger when a new thirdpaty action is done in Dolibarr.' + description: 'Triggers when a new thirdpaty action is done in Dolibarr.' }, // `operation` is where the business logic goes. @@ -123,6 +123,7 @@ module.exports = { inputFields: [ { key: 'action', + required: true, type: 'string', helpText: 'Which action of thirdparty this should trigger on.', choices: { @@ -159,12 +160,12 @@ module.exports = { // outputFields: () => { return []; } // Alternatively, a static field definition should be provided, to specify labels for the fields outputFields: [ - {key: 'id', label: 'ID'}, + {key: 'id', type: "integer", label: 'ID'}, {key: 'createdAt', label: 'Created At'}, {key: 'name', label: 'Name'}, {key: 'name_alias', label: 'Name alias'}, - {key: 'firstname', label: 'Firstame'}, - {key: 'authorId', label: 'Author ID'}, + {key: 'firstname', label: 'Firstname'}, + {key: 'authorId', type: "integer", label: 'Author ID'}, {key: 'action', label: 'Action'}, {key: 'client', label: 'Customer/Prospect 0/1/2/3'}, {key: 'fournisseur', label: 'Supplier 0/1'}, diff --git a/dev/examples/zapier/triggers/ticket.js b/dev/examples/zapier/triggers/ticket.js new file mode 100644 index 00000000000..c642099bd55 --- /dev/null +++ b/dev/examples/zapier/triggers/ticket.js @@ -0,0 +1,237 @@ +const subscribeHook = (z, bundle) => { + // `z.console.log()` is similar to `console.log()`. + z.console.log('suscribing hook!'); + + // bundle.targetUrl has the Hook URL this app should call when an action is created. + const data = { + url: bundle.targetUrl, + event: bundle.event, + module: 'ticket', + action: bundle.inputData.action + }; + + const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + + // You can build requests and our client will helpfully inject all the variables + // you need to complete. You can also register middleware to control this. + const options = { + url: url, + method: 'POST', + body: data, + }; + + // You may return a promise or a normal data structure from any perform method. + return z.request(options).then((response) => JSON.parse(response.content)); +}; + +const unsubscribeHook = (z, bundle) => { + // bundle.subscribeData contains the parsed response JSON from the subscribe + // request made initially. + z.console.log('unsuscribing hook!'); + + // You can build requests and our client will helpfully inject all the variables + // you need to complete. You can also register middleware to control this. + const options = { + url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + method: 'DELETE', + }; + + // You may return a promise or a normal data structure from any perform method. + return z.request(options).then((response) => JSON.parse(response.content)); +}; + +const getTicket = (z, bundle) => { + // bundle.cleanedRequest will include the parsed JSON object (if it's not a + // test poll) and also a .querystring property with the URL's query string. + const ticket = { + id: bundle.cleanedRequest.id, + track_id: bundle.cleanedRequest.track_id, + subject: bundle.cleanedRequest.subject, + message: bundle.cleanedRequest.message, + lastname: bundle.cleanedRequest.lastname, + firstname: bundle.cleanedRequest.firstname, + address: bundle.cleanedRequest.address, + zip: bundle.cleanedRequest.zip, + town: bundle.cleanedRequest.town, + email_from: bundle.cleanedRequest.email_from, + login: bundle.cleanedRequest.login, + authorId: bundle.cleanedRequest.authorId, + createdAt: bundle.cleanedRequest.createdAt, + action: bundle.cleanedRequest.action + }; + + return [ticket]; +}; + +const getFallbackRealTicket = (z, bundle) => { + // For the test poll, you should get some real data, to aid the setup process. + const module = bundle.inputData.module; + const options = { + url: bundle.authData.url + '/api/index.php/tickets/0', + }; + + return z.request(options).then((response) => [JSON.parse(response.content)]); +}; + +// const getModulesChoices = (z/*, bundle*/) => { +// // For the test poll, you should get some real data, to aid the setup process. +// const options = { +// url: bundle.authData.url + '/api/index.php/zapierapi/getmoduleschoices', +// }; + +// return z.request(options).then((response) => JSON.parse(response.content)); +// }; +// const getModulesChoices = () => { + +// return { +// orders: "Order", +// invoices: "Invoice", +// thirdparties: "Thirdparty", +// users: "User", +// tickets: "Ticket", +// contacts: "Contacts" +// }; +// }; + +// const getActionsChoices = (z, bundle) => { +// // For the test poll, you should get some real data, to aid the setup process. +// const module = bundle.inputData.module; +// const options = { +// url: url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/thirparty`, +// }; + +// return z.request(options).then((response) => JSON.parse(response.content)); +// }; + +// We recommend writing your triggers separate like this and rolling them +// into the App definition at the end. +module.exports = { + key: 'ticket', + + // You'll want to provide some helpful display labels and descriptions + // for tickets. Zapier will put them into the UX. + noun: 'Ticket', + display: { + label: 'New Ticket', + description: 'Triggers when a new ticket action is done in Dolibarr.' + }, + + // `operation` is where the business logic goes. + operation: { + + // `inputFields` can define the fields a ticket could provide, + // we'll pass them in as `bundle.inputData` later. + inputFields: [ + { + key: 'action', + type: 'string', + required: true, + helpText: 'Which action of ticket this should trigger on.', + choices: { + create: "Create", + modify: "Modify", + validate: "Validate", + } + } + ], + + type: 'hook', + + performSubscribe: subscribeHook, + performUnsubscribe: unsubscribeHook, + + perform: getTicket, + performList: getFallbackRealTicket, + + // In cases where Zapier needs to show an example record to the user, but we are unable to get a live example + // from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of + // returned records, and have obviously dummy values that we can show to any user. + sample: { + id: 1, + track_id: 'Xaz123er', + subject: 'Subject', + message: 'Message', + createdAt: 1472069465, + lastname: 'DOE', + firstname: 'John', + email: 'john@doe.com', + address: 'Park Avenue', + zip: '12345', + town: 'NEW-YORK', + email_from: 'doe.john@example;com', + authorId: 1, + action: 'create' + }, + + // If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom + // field definitions. The result will be used to augment the sample. + // outputFields: () => { return []; } + // Alternatively, a static field definition should be provided, to specify labels for the fields + outputFields: [ + { + key: 'id', + type: "integer", + label: 'ID' + }, + { + key: 'track_id', + type: "string", + label: 'TrackID' + }, + { + key: 'subject', + type: "string", + label: 'Subject' + }, + { + key: 'message', + type: "string", + label: 'Message' + }, + { + key: 'createdAt', + type: "integer", + label: 'Created At' + }, + { + key: 'lastname', + label: 'Lastname' + }, + { + key: 'firstname', + label: 'Firstname' + }, + { + key: 'email', + label: 'Email' + }, + { + key: 'address', + label: 'Address' + }, + { + key: 'zip', + label: 'Zip' + }, + { + key: 'town', + label: 'Town' + }, + { + key: 'email_from', + type: 'string', + label: 'Email from' + }, + { + key: 'authorId', + type: "integer", + label: 'Author ID' + }, + { + key: 'action', + type: 'string', + label: 'Action' + } + ] + } +}; diff --git a/dev/examples/zapier/triggers/user.js b/dev/examples/zapier/triggers/user.js new file mode 100644 index 00000000000..92209bb8651 --- /dev/null +++ b/dev/examples/zapier/triggers/user.js @@ -0,0 +1,177 @@ +const subscribeHook = (z, bundle) => { + // `z.console.log()` is similar to `console.log()`. + z.console.log('suscribing hook!'); + + // bundle.targetUrl has the Hook URL this app should call when an action is created. + const data = { + url: bundle.targetUrl, + event: bundle.event, + module: 'user', + action: bundle.inputData.action + }; + + const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; + + // You can build requests and our client will helpfully inject all the variables + // you need to complete. You can also register middleware to control this. + const options = { + url: url, + method: 'POST', + body: data, + }; + + // You may return a promise or a normal data structure from any perform method. + return z.request(options).then((response) => JSON.parse(response.content)); +}; + +const unsubscribeHook = (z, bundle) => { + // bundle.subscribeData contains the parsed response JSON from the subscribe + // request made initially. + z.console.log('unsuscribing hook!'); + + // You can build requests and our client will helpfully inject all the variables + // you need to complete. You can also register middleware to control this. + const options = { + url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, + method: 'DELETE', + }; + + // You may return a promise or a normal data structure from any perform method. + return z.request(options).then((response) => JSON.parse(response.content)); +}; + +const getUser = (z, bundle) => { + // bundle.cleanedRequest will include the parsed JSON object (if it's not a + // test poll) and also a .querystring property with the URL's query string. + const user = { + id: bundle.cleanedRequest.id, + lastname: bundle.cleanedRequest.lastname, + firstname: bundle.cleanedRequest.firstname, + address: bundle.cleanedRequest.address, + zip: bundle.cleanedRequest.zip, + town: bundle.cleanedRequest.town, + email: bundle.cleanedRequest.email, + login: bundle.cleanedRequest.login, + authorId: bundle.cleanedRequest.authorId, + createdAt: bundle.cleanedRequest.createdAt, + action: bundle.cleanedRequest.action + }; + + return [user]; +}; + +const getFallbackRealUser = (z, bundle) => { + // For the test poll, you should get some real data, to aid the setup process. + const module = bundle.inputData.module; + const options = { + url: bundle.authData.url + '/api/index.php/users/0', + }; + + return z.request(options).then((response) => [JSON.parse(response.content)]); +}; + +// const getModulesChoices = (z/*, bundle*/) => { +// // For the test poll, you should get some real data, to aid the setup process. +// const options = { +// url: bundle.authData.url + '/api/index.php/zapierapi/getmoduleschoices', +// }; + +// return z.request(options).then((response) => JSON.parse(response.content)); +// }; +// const getModulesChoices = () => { + +// return { +// orders: "Order", +// invoices: "Invoice", +// thirdparties: "Thirdparty", +// users: "User", +// contacts: "Contacts" +// }; +// }; + +// const getActionsChoices = (z, bundle) => { +// // For the test poll, you should get some real data, to aid the setup process. +// const module = bundle.inputData.module; +// const options = { +// url: url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/thirparty`, +// }; + +// return z.request(options).then((response) => JSON.parse(response.content)); +// }; + +// We recommend writing your triggers separate like this and rolling them +// into the App definition at the end. +module.exports = { + key: 'user', + + // You'll want to provide some helpful display labels and descriptions + // for users. Zapier will put them into the UX. + noun: 'User', + display: { + label: 'New User', + description: 'Triggers when a new user action is done in Dolibarr.' + }, + + // `operation` is where the business logic goes. + operation: { + + // `inputFields` can define the fields a user could provide, + // we'll pass them in as `bundle.inputData` later. + inputFields: [ + { + key: 'action', + required: true, + type: 'string', + helpText: 'Which action of user this should trigger on.', + choices: { + create: "Create", + modify: "Modify", + validate: "Validate", + } + } + ], + + type: 'hook', + + performSubscribe: subscribeHook, + performUnsubscribe: unsubscribeHook, + + perform: getUser, + performList: getFallbackRealUser, + + // In cases where Zapier needs to show an example record to the user, but we are unable to get a live example + // from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of + // returned records, and have obviously dummy values that we can show to any user. + sample: { + id: 1, + createdAt: 1472069465, + lastname: 'DOE', + firstname: 'John', + email: 'john@doe.com', + address: 'Park Avenue', + zip: '12345', + town: 'NEW-YORK', + login: 'doe.john', + authorId: 1, + action: 'create' + }, + + // If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom + // field definitions. The result will be used to augment the sample. + // outputFields: () => { return []; } + // Alternatively, a static field definition should be provided, to specify labels for the fields + outputFields: [ + {key: 'id', type: "integer", label: 'ID'}, + {key: 'createdAt', type: "integer", label: 'Created At'}, + {key: 'lastname', label: 'Lastname'}, + {key: 'firstname', label: 'Firstname'}, + {key: 'email', label: 'Email'}, + {key: 'address', label: 'Address'}, + {key: 'zip', label: 'Zip'}, + {key: 'town', label: 'Town'}, + {key: 'login', label: 'Login'}, + {key: 'authorId', type: "integer", label: 'Author ID'}, + {key: 'action', label: 'Action'} + ] + } +}; diff --git a/dev/initdata/purge-data.php b/dev/initdata/purge-data.php index e6a67aa73c8..18256c33766 100755 --- a/dev/initdata/purge-data.php +++ b/dev/initdata/purge-data.php @@ -120,8 +120,8 @@ $sqls=array( "DELETE FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'", ), 'delivery'=>array( - "DELETE FROM ".MAIN_DB_PREFIX."livraisondet WHERE fk_livraison IN (select rowid FROM ".MAIN_DB_PREFIX."livraison where date_creation < '__DATE__')", - "DELETE FROM ".MAIN_DB_PREFIX."livraison where date_creation < '__DATE__'", + "DELETE FROM ".MAIN_DB_PREFIX."deliverydet WHERE fk_delivery IN (select rowid FROM ".MAIN_DB_PREFIX."delivery where date_creation < '__DATE__')", + "DELETE FROM ".MAIN_DB_PREFIX."delivery where date_creation < '__DATE__'", ), 'contract'=>array( "DELETE FROM ".MAIN_DB_PREFIX."contratdet_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."contratdet WHERE fk_contrat IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__'))", diff --git a/dev/initdemo/mysqldump_dolibarr_12.0.0.sql b/dev/initdemo/mysqldump_dolibarr_12.0.0.sql index 3cc1db1cf34..a05c05c066e 100644 --- a/dev/initdemo/mysqldump_dolibarr_12.0.0.sql +++ b/dev/initdemo/mysqldump_dolibarr_12.0.0.sql @@ -7522,13 +7522,13 @@ INSERT INTO `llx_links` VALUES (1,1,'2018-01-16 16:45:35','http://www.dolicloud. UNLOCK TABLES; -- --- Table structure for table `llx_livraison` +-- Table structure for table `llx_delivery` -- -DROP TABLE IF EXISTS `llx_livraison`; +DROP TABLE IF EXISTS `llx_delivery`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_livraison` ( +CREATE TABLE `llx_delivery` ( `rowid` int(11) NOT NULL AUTO_INCREMENT, `tms` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `ref` varchar(30) COLLATE utf8_unicode_ci NOT NULL, @@ -7554,61 +7554,61 @@ CREATE TABLE `llx_livraison` ( `import_key` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, `extraparams` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`rowid`), - UNIQUE KEY `idx_livraison_uk_ref` (`ref`,`entity`), - KEY `idx_livraison_fk_soc` (`fk_soc`), - KEY `idx_livraison_fk_user_author` (`fk_user_author`), - KEY `idx_livraison_fk_user_valid` (`fk_user_valid`), - CONSTRAINT `fk_livraison_fk_soc` FOREIGN KEY (`fk_soc`) REFERENCES `llx_societe` (`rowid`), - CONSTRAINT `fk_livraison_fk_user_author` FOREIGN KEY (`fk_user_author`) REFERENCES `llx_user` (`rowid`), - CONSTRAINT `fk_livraison_fk_user_valid` FOREIGN KEY (`fk_user_valid`) REFERENCES `llx_user` (`rowid`) + UNIQUE KEY `idx_delivery_uk_ref` (`ref`,`entity`), + KEY `idx_delivery_fk_soc` (`fk_soc`), + KEY `idx_delivery_fk_user_author` (`fk_user_author`), + KEY `idx_delivery_fk_user_valid` (`fk_user_valid`), + CONSTRAINT `fk_delivery_fk_soc` FOREIGN KEY (`fk_soc`) REFERENCES `llx_societe` (`rowid`), + CONSTRAINT `fk_delivery_fk_user_author` FOREIGN KEY (`fk_user_author`) REFERENCES `llx_user` (`rowid`), + CONSTRAINT `fk_delivery_fk_user_valid` FOREIGN KEY (`fk_user_valid`) REFERENCES `llx_user` (`rowid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `llx_livraison` +-- Dumping data for table `llx_delivery` -- -LOCK TABLES `llx_livraison` WRITE; -/*!40000 ALTER TABLE `llx_livraison` DISABLE KEYS */; -/*!40000 ALTER TABLE `llx_livraison` ENABLE KEYS */; +LOCK TABLES `llx_delivery` WRITE; +/*!40000 ALTER TABLE `llx_delivery` DISABLE KEYS */; +/*!40000 ALTER TABLE `llx_delivery` ENABLE KEYS */; UNLOCK TABLES; -- --- Table structure for table `llx_livraison_extrafields` +-- Table structure for table `llx_delivery_extrafields` -- -DROP TABLE IF EXISTS `llx_livraison_extrafields`; +DROP TABLE IF EXISTS `llx_delivery_extrafields`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_livraison_extrafields` ( +CREATE TABLE `llx_delivery_extrafields` ( `rowid` int(11) NOT NULL AUTO_INCREMENT, `tms` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `fk_object` int(11) NOT NULL, `import_key` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`rowid`), - KEY `idx_livraison_extrafields` (`fk_object`) + KEY `idx_delivery_extrafields` (`fk_object`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `llx_livraison_extrafields` +-- Dumping data for table `llx_delivery_extrafields` -- -LOCK TABLES `llx_livraison_extrafields` WRITE; -/*!40000 ALTER TABLE `llx_livraison_extrafields` DISABLE KEYS */; -/*!40000 ALTER TABLE `llx_livraison_extrafields` ENABLE KEYS */; +LOCK TABLES `llx_delivery_extrafields` WRITE; +/*!40000 ALTER TABLE `llx_delivery_extrafields` DISABLE KEYS */; +/*!40000 ALTER TABLE `llx_delivery_extrafields` ENABLE KEYS */; UNLOCK TABLES; -- --- Table structure for table `llx_livraisondet` +-- Table structure for table `llx_deliverydet` -- -DROP TABLE IF EXISTS `llx_livraisondet`; +DROP TABLE IF EXISTS `llx_deliverydet`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_livraisondet` ( +CREATE TABLE `llx_deliverydet` ( `rowid` int(11) NOT NULL AUTO_INCREMENT, - `fk_livraison` int(11) DEFAULT NULL, + `fk_delivery` int(11) DEFAULT NULL, `fk_origin_line` int(11) DEFAULT NULL, `fk_product` int(11) DEFAULT NULL, `description` text COLLATE utf8_unicode_ci DEFAULT NULL, @@ -7617,44 +7617,44 @@ CREATE TABLE `llx_livraisondet` ( `total_ht` double(24,8) DEFAULT 0.00000000, `rang` int(11) DEFAULT 0, PRIMARY KEY (`rowid`), - KEY `idx_livraisondet_fk_expedition` (`fk_livraison`), - CONSTRAINT `fk_livraisondet_fk_livraison` FOREIGN KEY (`fk_livraison`) REFERENCES `llx_livraison` (`rowid`) + KEY `idx_deliverydet_fk_expedition` (`fk_delivery`), + CONSTRAINT `fk_deliverydet_fk_delivery` FOREIGN KEY (`fk_delivery`) REFERENCES `llx_delivery` (`rowid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `llx_livraisondet` +-- Dumping data for table `llx_deliverydet` -- -LOCK TABLES `llx_livraisondet` WRITE; -/*!40000 ALTER TABLE `llx_livraisondet` DISABLE KEYS */; -/*!40000 ALTER TABLE `llx_livraisondet` ENABLE KEYS */; +LOCK TABLES `llx_deliverydet` WRITE; +/*!40000 ALTER TABLE `llx_deliverydet` DISABLE KEYS */; +/*!40000 ALTER TABLE `llx_deliverydet` ENABLE KEYS */; UNLOCK TABLES; -- --- Table structure for table `llx_livraisondet_extrafields` +-- Table structure for table `llx_deliverydet_extrafields` -- -DROP TABLE IF EXISTS `llx_livraisondet_extrafields`; +DROP TABLE IF EXISTS `llx_deliverydet_extrafields`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `llx_livraisondet_extrafields` ( +CREATE TABLE `llx_deliverydet_extrafields` ( `rowid` int(11) NOT NULL AUTO_INCREMENT, `tms` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `fk_object` int(11) NOT NULL, `import_key` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`rowid`), - KEY `idx_livraisondet_extrafields` (`fk_object`) + KEY `idx_deliverydet_extrafields` (`fk_object`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Dumping data for table `llx_livraisondet_extrafields` +-- Dumping data for table `llx_deliverydet_extrafields` -- -LOCK TABLES `llx_livraisondet_extrafields` WRITE; -/*!40000 ALTER TABLE `llx_livraisondet_extrafields` DISABLE KEYS */; -/*!40000 ALTER TABLE `llx_livraisondet_extrafields` ENABLE KEYS */; +LOCK TABLES `llx_deliverydet_extrafields` WRITE; +/*!40000 ALTER TABLE `llx_deliverydet_extrafields` DISABLE KEYS */; +/*!40000 ALTER TABLE `llx_deliverydet_extrafields` ENABLE KEYS */; UNLOCK TABLES; -- @@ -12679,7 +12679,7 @@ CREATE TABLE `llx_user` ( LOCK TABLES `llx_user` WRITE; /*!40000 ALTER TABLE `llx_user` DISABLE KEYS */; -INSERT INTO `llx_user` VALUES (1,'2012-07-08 13:20:11','2019-11-28 11:52:58',NULL,NULL,'aeinstein',0,NULL,NULL,NULL,1,0,NULL,'11c9c772d6471aa24c27274bdd8a223b',NULL,NULL,'Einstein','Albert','',NULL,'123456789','','','','aeinstein@example.com','','[]','',0,'',1,1,NULL,NULL,NULL,'','2017-10-05 08:32:44','2017-10-03 11:43:50',NULL,'',1,'alberteinstein.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'aaaaff','',NULL,0,0,NULL,NULL,NULL,44.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(2,'2012-07-08 13:54:48','2019-11-28 11:52:58',NULL,NULL,'demo',1,NULL,NULL,NULL,1,0,NULL,'fe01ce2a7fbac8fafaed7c982a04e229',NULL,NULL,'Doe','David','Trainee',NULL,'09123123','','','','daviddoe@example.com','','[]','',0,'',1,1,NULL,NULL,NULL,'','2018-07-30 23:10:54','2018-07-30 23:04:17',NULL,'',1,'person9.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,35.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(3,'2012-07-11 16:18:59','2020-01-21 09:30:27',NULL,NULL,'pcurie',1,NULL,NULL,NULL,1,0,NULL,'ab335b4eb4c3c99334f656e5db9584c9',NULL,NULL,'Curie','Pierre','',NULL,'','','','','pcurie@example.com','','[]','',0,'',1,1,NULL,NULL,2,'','2014-12-21 17:38:55',NULL,NULL,'',1,'pierrecurie.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(4,'2015-01-23 17:52:27','2019-11-28 11:52:58',NULL,NULL,'bbookkeeper',1,NULL,NULL,NULL,1,0,NULL,'a7d30b58d647fcf59b7163f9592b1dbb',NULL,NULL,'Bookkeeper','Bob','Bookkeeper',NULL,'','','','','bbookkeeper@example.com','','{\"skype\":\"skypebbookkeeper\"}','',0,'',1,1,17,6,NULL,'','2015-02-25 10:18:41','2015-01-23 17:53:20',NULL,'',1,'person8.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,16.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(10,'2017-10-03 11:47:41','2019-11-28 11:52:58',NULL,NULL,'mcurie',1,NULL,NULL,NULL,1,0,NULL,'52cda011808bb282d1d3625ab607a145',NULL,'t3mnkbhs','Curie','Marie','',NULL,'','','','','mcurie@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'mariecurie.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'ffaaff','',NULL,0,0,NULL,NULL,NULL,44.00000000,'woman',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(11,'2017-10-05 09:07:52','2019-11-28 11:52:58',NULL,NULL,'zzeceo',1,NULL,NULL,NULL,1,0,NULL,'92af989c4c3a5140fb5d73eb77a52454',NULL,'cq78nf9m','Zeceo','Zack','President - CEO',NULL,'','','','','zzeceo@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 22:48:08','2017-10-05 21:18:46',NULL,'',1,'person4.jpeg',NULL,NULL,NULL,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,NULL,NULL,'2019-06-10 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(12,'2017-10-05 09:09:46','2020-01-07 13:47:17',NULL,NULL,'admin',0,NULL,NULL,NULL,1,0,NULL,'f6fdffe48c908deb0f4c3bd36c032e72',NULL,'nd6hgbcr','Adminson','Alice','Admin Technical',NULL,'','','','','aadminson@example.com','','[]','Alice - 123',1,NULL,1,1,NULL,NULL,NULL,'','2020-01-21 10:38:41','2020-01-21 10:35:27',NULL,'',1,'person6.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,2700.00000000,NULL,NULL,39.00000000,'woman',NULL,NULL,NULL,'generic_user_odt','1985-09-15',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(13,'2017-10-05 21:29:35','2019-11-28 11:52:58',NULL,NULL,'ccommercy',1,NULL,NULL,NULL,1,0,NULL,'179858e041af35e8f4c81d68c55fe9da',NULL,'y451ksdv','Commercy','Coraly','Commercial leader',NULL,'','','','','ccommercy@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'person7.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,1890.00000000,NULL,NULL,25.00000000,'woman',NULL,'2018-09-11 00:00:00',NULL,NULL,'1998-12-08',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(14,'2017-10-05 21:33:33','2019-11-28 11:52:58',NULL,NULL,'sscientol',1,NULL,NULL,NULL,1,0,NULL,'39bee07ac42f31c98e79cdcd5e5fe4c5',NULL,'s2hp8bxd','Scientol','Sam','Scientist leader',NULL,'','','','','sscientol@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'person3.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,3500.00000000,NULL,NULL,39.00000000,NULL,NULL,'2018-07-03 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(16,'2017-10-05 22:47:52','2019-11-28 11:52:58',NULL,NULL,'ccommerson',1,NULL,NULL,NULL,1,0,NULL,'d68005ccf362b82d084551b6291792a3',NULL,'cx9y1dk0','Charle1','Commerson','Sale representative',NULL,'','','','','ccommerson@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 23:46:24','2017-10-05 23:37:31',NULL,'',1,'person1.jpeg',NULL,NULL,13,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,2900.00000000,NULL,NULL,39.00000000,NULL,NULL,'2019-09-01 00:00:00',NULL,NULL,'1976-02-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(17,'2017-10-05 22:48:39','2019-11-28 11:52:58',NULL,NULL,'aleerfok',1,NULL,NULL,NULL,1,0,NULL,'a964065211872fb76f876c6c3e952ea3',NULL,'gw8cb7xj','Leerfok','Amanda','Sale representative',NULL,'','','','','aleerfok@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 23:16:06',NULL,NULL,'',0,'person5.jpeg',NULL,NULL,13,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,'woman',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(18,'2018-01-22 17:27:02','2019-11-28 11:52:58',NULL,NULL,'ldestailleur',1,NULL,NULL,NULL,1,0,NULL,'1bb7805145a7a5066df9e6d585b8b645',NULL,'87g06wbx','Destailleur','Laurent','Project leader of Dolibarr ERP CRM',NULL,'','','','','ldestailleur@example.com','','[]','
Laurent DESTAILLEUR
\r\n\r\n
\r\n
Project Director
\r\nldestailleur@example.com
\r\n\r\n
 
\r\n\r\n
\r\n
Facebook | Twitter | www.teclib.com
\r\n
\r\n
',0,NULL,1,1,10,10,NULL,'More information on http://www.destailleur.fr','2019-10-04 10:06:40','2017-09-06 11:55:30',NULL,'',1,'ldestailleur_200x200.jpg',NULL,NULL,NULL,NULL,NULL,NULL,'','','',NULL,NULL,'007f7f','',NULL,0,0,NULL,NULL,NULL,NULL,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(19,'2017-02-02 03:55:44','2020-01-16 15:44:42',NULL,NULL,'aboston',1,NULL,NULL,NULL,1,0,NULL,'a7a77a5aff2d5fc2f75f2f61507c88d4',NULL,NULL,'Boston','Alex','',NULL,'','','','','aboston@example.com','','[]','Alex Boston
\r\nAdmin support service - 555 01 02 03 04',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',0,'person2.jpeg',NULL,NULL,12,NULL,NULL,25.00000000,'','','',NULL,NULL,'ff00ff','',NULL,0,0,2700.00000000,NULL,NULL,32.00000000,NULL,NULL,'2016-11-04 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL); +INSERT INTO `llx_user` VALUES (1,'2012-07-08 13:20:11','2019-11-28 11:52:58',NULL,NULL,'aeinstein',0,NULL,NULL,NULL,1,0,NULL,'11c9c772d6471aa24c27274bdd8a223b',NULL,NULL,'Einstein','Albert','',NULL,'123456789','','','','aeinstein@example.com','','[]','',0,'',1,1,NULL,NULL,NULL,'','2017-10-05 08:32:44','2017-10-03 11:43:50',NULL,'',1,'alberteinstein.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'aaaaff','',NULL,0,0,NULL,NULL,NULL,44.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(2,'2012-07-08 13:54:48','2019-11-28 11:52:58',NULL,NULL,'demo',1,NULL,NULL,NULL,1,0,NULL,'fe01ce2a7fbac8fafaed7c982a04e229',NULL,NULL,'Doe','David','Trainee',NULL,'09123123','','','','daviddoe@example.com','','[]','',0,'',1,1,NULL,NULL,NULL,'','2018-07-30 23:10:54','2018-07-30 23:04:17',NULL,'',1,'person9.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,35.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(3,'2012-07-11 16:18:59','2020-01-21 09:30:27',NULL,NULL,'pcurie',1,NULL,NULL,NULL,1,0,NULL,'ab335b4eb4c3c99334f656e5db9584c9',NULL,NULL,'Curie','Pierre','',NULL,'','','','','pcurie@example.com','','[]','',0,'',1,1,NULL,NULL,2,'','2014-12-21 17:38:55',NULL,NULL,'',1,'pierrecurie.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(4,'2015-01-23 17:52:27','2019-11-28 11:52:58',NULL,NULL,'bbookkeeper',1,NULL,NULL,NULL,1,0,NULL,'a7d30b58d647fcf59b7163f9592b1dbb',NULL,NULL,'Bookkeeper','Bob','Bookkeeper',NULL,'','','','','bbookkeeper@example.com','','{\"skype\":\"skypebbookkeeper\"}','',0,'',1,1,17,6,NULL,'','2015-02-25 10:18:41','2015-01-23 17:53:20',NULL,'',1,'person8.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,16.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(10,'2017-10-03 11:47:41','2019-11-28 11:52:58',NULL,NULL,'mcurie',1,NULL,NULL,NULL,1,0,NULL,'52cda011808bb282d1d3625ab607a145',NULL,'t3mnkbhs','Curie','Marie','',NULL,'','','','','mcurie@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'mariecurie.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'ffaaff','',NULL,0,0,NULL,NULL,NULL,44.00000000,'woman',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(11,'2017-10-05 09:07:52','2019-11-28 11:52:58',NULL,NULL,'zzeceo',1,NULL,NULL,NULL,1,0,NULL,'92af989c4c3a5140fb5d73eb77a52454',NULL,'cq78nf9m','Zeceo','Zack','President - CEO',NULL,'','','','','zzeceo@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 22:48:08','2017-10-05 21:18:46',NULL,'',1,'person4.jpeg',NULL,NULL,NULL,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,NULL,NULL,'2019-06-10 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(12,'2017-10-05 09:09:46','2020-01-07 13:47:17',NULL,NULL,'admin',0,NULL,NULL,NULL,1,0,NULL,'f6fdffe48c908deb0f4c3bd36c032e72',NULL,'nd6hgbcr','Adminson','Alice','Admin Technical',NULL,'','','','','aadminson@example.com','','[]','Alice - 123',1,NULL,1,1,NULL,NULL,NULL,'','2020-01-21 10:38:41','2020-01-21 10:35:27',NULL,'',1,'person6.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,2700.00000000,NULL,NULL,39.00000000,'woman',NULL,NULL,NULL,'generic_user_odt','1985-09-15',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(13,'2017-10-05 21:29:35','2019-11-28 11:52:58',NULL,NULL,'ccommercy',1,NULL,NULL,NULL,1,0,NULL,'179858e041af35e8f4c81d68c55fe9da',NULL,'y451ksdv','Commercy','Coraly','Commercial leader',NULL,'','','','','ccommercy@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'person7.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,1890.00000000,NULL,NULL,25.00000000,'woman',NULL,'2018-09-11 00:00:00',NULL,NULL,'1998-12-08',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(14,'2017-10-05 21:33:33','2019-11-28 11:52:58',NULL,NULL,'sscientol',1,NULL,NULL,NULL,1,0,NULL,'39bee07ac42f31c98e79cdcd5e5fe4c5',NULL,'s2hp8bxd','Scientol','Sam','Scientist leader',NULL,'','','','','sscientol@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'person3.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,3500.00000000,NULL,NULL,39.00000000,NULL,NULL,'2018-07-03 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(16,'2017-10-05 22:47:52','2019-11-28 11:52:58',NULL,NULL,'ccommerson',1,NULL,NULL,NULL,1,0,NULL,'d68005ccf362b82d084551b6291792a3',NULL,'cx9y1dk0','Charle1','Commerson','Sale representative',NULL,'','','','','ccommerson@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 23:46:24','2017-10-05 23:37:31',NULL,'',1,'person1.jpeg',NULL,NULL,13,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,2900.00000000,NULL,NULL,39.00000000,NULL,NULL,'2019-09-01 00:00:00',NULL,NULL,'1976-02-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(17,'2017-10-05 22:48:39','2019-11-28 11:52:58',NULL,NULL,'aleerfok',1,NULL,NULL,NULL,1,0,NULL,'a964065211872fb76f876c6c3e952ea3',NULL,'gw8cb7xj','Leerfok','Amanda','Sale representative',NULL,'','','','','aleerfok@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 23:16:06',NULL,NULL,'',0,'person5.jpeg',NULL,NULL,13,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,'woman',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(18,'2018-01-22 17:27:02','2019-11-28 11:52:58',NULL,NULL,'ldestailleur',1,NULL,NULL,NULL,1,0,NULL,'1bb7805145a7a5066df9e6d585b8b645',NULL,'87g06wbx','Destailleur','Laurent','Project leader of Dolibarr ERP CRM',NULL,'','','','','ldestailleur@example.com','','[]','
Laurent DESTAILLEUR
\r\n\r\n
\r\n
Project Director
\r\nldestailleur@example.com
\r\n\r\n
 
\r\n\r\n
\r\n
Facebook | Twitter | www.teclib.com
\r\n
\r\n
',0,NULL,1,1,10,10,NULL,'More information on http://www.mydomain.com','2019-10-04 10:06:40','2017-09-06 11:55:30',NULL,'',1,'ldestailleur_200x200.jpg',NULL,NULL,NULL,NULL,NULL,NULL,'','','',NULL,NULL,'007f7f','',NULL,0,0,NULL,NULL,NULL,NULL,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(19,'2017-02-02 03:55:44','2020-01-16 15:44:42',NULL,NULL,'aboston',1,NULL,NULL,NULL,1,0,NULL,'a7a77a5aff2d5fc2f75f2f61507c88d4',NULL,NULL,'Boston','Alex','',NULL,'','','','','aboston@example.com','','[]','Alex Boston
\r\nAdmin support service - 555 01 02 03 04',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',0,'person2.jpeg',NULL,NULL,12,NULL,NULL,25.00000000,'','','',NULL,NULL,'ff00ff','',NULL,0,0,2700.00000000,NULL,NULL,32.00000000,NULL,NULL,'2016-11-04 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL); /*!40000 ALTER TABLE `llx_user` ENABLE KEYS */; UNLOCK TABLES; @@ -13655,7 +13655,7 @@ CREATE TABLE `tmp_user` ( LOCK TABLES `tmp_user` WRITE; /*!40000 ALTER TABLE `tmp_user` DISABLE KEYS */; -INSERT INTO `tmp_user` VALUES (1,'2012-07-08 13:20:11','2019-11-28 11:52:58',NULL,NULL,'aeinstein',0,NULL,NULL,NULL,1,0,NULL,'11c9c772d6471aa24c27274bdd8a223b',NULL,NULL,'Einstein','Albert','',NULL,'123456789','','','','aeinstein@example.com','','[]','',0,'',1,1,NULL,NULL,NULL,'','2017-10-05 08:32:44','2017-10-03 11:43:50',NULL,'',1,'alberteinstein.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'aaaaff','',NULL,0,0,NULL,NULL,NULL,44.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(2,'2012-07-08 13:54:48','2019-11-28 11:52:58',NULL,NULL,'demo',1,NULL,NULL,NULL,1,0,NULL,'fe01ce2a7fbac8fafaed7c982a04e229',NULL,NULL,'Doe','David','Trainee',NULL,'09123123','','','','daviddoe@example.com','','[]','',0,'',1,1,NULL,NULL,NULL,'','2018-07-30 23:10:54','2018-07-30 23:04:17',NULL,'',1,'person9.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,35.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(3,'2012-07-11 16:18:59','2020-01-21 09:30:27',NULL,NULL,'pcurie',1,NULL,NULL,NULL,1,0,NULL,'ab335b4eb4c3c99334f656e5db9584c9',NULL,NULL,'Curie','Pierre','',NULL,'','','','','pcurie@example.com','','[]','',0,'',1,1,NULL,NULL,2,'','2014-12-21 17:38:55',NULL,NULL,'',1,'pierrecurie.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(4,'2015-01-23 17:52:27','2019-11-28 11:52:58',NULL,NULL,'bbookkeeper',1,NULL,NULL,NULL,1,0,NULL,'a7d30b58d647fcf59b7163f9592b1dbb',NULL,NULL,'Bookkeeper','Bob','Bookkeeper',NULL,'','','','','bbookkeeper@example.com','','{\"skype\":\"skypebbookkeeper\"}','',0,'',1,1,17,6,NULL,'','2015-02-25 10:18:41','2015-01-23 17:53:20',NULL,'',1,'person8.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,16.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(10,'2017-10-03 11:47:41','2019-11-28 11:52:58',NULL,NULL,'mcurie',1,NULL,NULL,NULL,1,0,NULL,'52cda011808bb282d1d3625ab607a145',NULL,'t3mnkbhs','Curie','Marie','',NULL,'','','','','mcurie@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'mariecurie.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'ffaaff','',NULL,0,0,NULL,NULL,NULL,44.00000000,'woman',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(11,'2017-10-05 09:07:52','2019-11-28 11:52:58',NULL,NULL,'zzeceo',1,NULL,NULL,NULL,1,0,NULL,'92af989c4c3a5140fb5d73eb77a52454',NULL,'cq78nf9m','Zeceo','Zack','President - CEO',NULL,'','','','','zzeceo@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 22:48:08','2017-10-05 21:18:46',NULL,'',1,'person4.jpeg',NULL,NULL,NULL,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,NULL,NULL,'2019-06-10 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(12,'2017-10-05 09:09:46','2020-01-07 13:47:17',NULL,NULL,'admin',0,NULL,NULL,NULL,1,0,NULL,'f6fdffe48c908deb0f4c3bd36c032e72',NULL,'nd6hgbcr','Adminson','Alice','Admin Technical',NULL,'','','','','aadminson@example.com','','[]','Alice - 123',1,NULL,1,1,NULL,NULL,NULL,'','2020-01-21 10:38:41','2020-01-21 10:35:27',NULL,'',1,'person6.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,2700.00000000,NULL,NULL,39.00000000,'woman',NULL,NULL,NULL,'generic_user_odt','1985-09-15',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(13,'2017-10-05 21:29:35','2019-11-28 11:52:58',NULL,NULL,'ccommercy',1,NULL,NULL,NULL,1,0,NULL,'179858e041af35e8f4c81d68c55fe9da',NULL,'y451ksdv','Commercy','Coraly','Commercial leader',NULL,'','','','','ccommercy@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'person7.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,1890.00000000,NULL,NULL,25.00000000,'woman',NULL,'2018-09-11 00:00:00',NULL,NULL,'1998-12-08',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(14,'2017-10-05 21:33:33','2019-11-28 11:52:58',NULL,NULL,'sscientol',1,NULL,NULL,NULL,1,0,NULL,'39bee07ac42f31c98e79cdcd5e5fe4c5',NULL,'s2hp8bxd','Scientol','Sam','Scientist leader',NULL,'','','','','sscientol@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'person3.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,3500.00000000,NULL,NULL,39.00000000,NULL,NULL,'2018-07-03 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(16,'2017-10-05 22:47:52','2019-11-28 11:52:58',NULL,NULL,'ccommerson',1,NULL,NULL,NULL,1,0,NULL,'d68005ccf362b82d084551b6291792a3',NULL,'cx9y1dk0','Charle1','Commerson','Sale representative',NULL,'','','','','ccommerson@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 23:46:24','2017-10-05 23:37:31',NULL,'',1,'person1.jpeg',NULL,NULL,13,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,2900.00000000,NULL,NULL,39.00000000,NULL,NULL,'2019-09-01 00:00:00',NULL,NULL,'1976-02-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(17,'2017-10-05 22:48:39','2019-11-28 11:52:58',NULL,NULL,'aleerfok',1,NULL,NULL,NULL,1,0,NULL,'a964065211872fb76f876c6c3e952ea3',NULL,'gw8cb7xj','Leerfok','Amanda','Sale representative',NULL,'','','','','aleerfok@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 23:16:06',NULL,NULL,'',0,'person5.jpeg',NULL,NULL,13,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,'woman',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(18,'2018-01-22 17:27:02','2019-11-28 11:52:58',NULL,NULL,'ldestailleur',1,NULL,NULL,NULL,1,0,NULL,'1bb7805145a7a5066df9e6d585b8b645',NULL,'87g06wbx','Destailleur','Laurent','Project leader of Dolibarr ERP CRM',NULL,'','','','','ldestailleur@example.com','','[]','
Laurent DESTAILLEUR
\r\n\r\n
\r\n
Project Director
\r\nldestailleur@example.com
\r\n\r\n
 
\r\n\r\n
\r\n
Facebook | Twitter | www.teclib.com
\r\n
\r\n
',0,NULL,1,1,10,10,NULL,'More information on http://www.destailleur.fr','2019-10-04 10:06:40','2017-09-06 11:55:30',NULL,'',1,'ldestailleur_200x200.jpg',NULL,NULL,NULL,NULL,NULL,NULL,'','','',NULL,NULL,'007f7f','',NULL,0,0,NULL,NULL,NULL,NULL,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(19,'2017-02-02 03:55:44','2020-01-16 15:44:42',NULL,NULL,'aboston',1,NULL,NULL,NULL,1,0,NULL,'a7a77a5aff2d5fc2f75f2f61507c88d4',NULL,NULL,'Boston','Alex','',NULL,'','','','','aboston@example.com','','[]','Alex Boston
\r\nAdmin support service - 555 01 02 03 04',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',0,'person2.jpeg',NULL,NULL,12,NULL,NULL,25.00000000,'','','',NULL,NULL,'ff00ff','',NULL,0,0,2700.00000000,NULL,NULL,32.00000000,NULL,NULL,'2016-11-04 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL); +INSERT INTO `tmp_user` VALUES (1,'2012-07-08 13:20:11','2019-11-28 11:52:58',NULL,NULL,'aeinstein',0,NULL,NULL,NULL,1,0,NULL,'11c9c772d6471aa24c27274bdd8a223b',NULL,NULL,'Einstein','Albert','',NULL,'123456789','','','','aeinstein@example.com','','[]','',0,'',1,1,NULL,NULL,NULL,'','2017-10-05 08:32:44','2017-10-03 11:43:50',NULL,'',1,'alberteinstein.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'aaaaff','',NULL,0,0,NULL,NULL,NULL,44.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(2,'2012-07-08 13:54:48','2019-11-28 11:52:58',NULL,NULL,'demo',1,NULL,NULL,NULL,1,0,NULL,'fe01ce2a7fbac8fafaed7c982a04e229',NULL,NULL,'Doe','David','Trainee',NULL,'09123123','','','','daviddoe@example.com','','[]','',0,'',1,1,NULL,NULL,NULL,'','2018-07-30 23:10:54','2018-07-30 23:04:17',NULL,'',1,'person9.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,35.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(3,'2012-07-11 16:18:59','2020-01-21 09:30:27',NULL,NULL,'pcurie',1,NULL,NULL,NULL,1,0,NULL,'ab335b4eb4c3c99334f656e5db9584c9',NULL,NULL,'Curie','Pierre','',NULL,'','','','','pcurie@example.com','','[]','',0,'',1,1,NULL,NULL,2,'','2014-12-21 17:38:55',NULL,NULL,'',1,'pierrecurie.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(4,'2015-01-23 17:52:27','2019-11-28 11:52:58',NULL,NULL,'bbookkeeper',1,NULL,NULL,NULL,1,0,NULL,'a7d30b58d647fcf59b7163f9592b1dbb',NULL,NULL,'Bookkeeper','Bob','Bookkeeper',NULL,'','','','','bbookkeeper@example.com','','{\"skype\":\"skypebbookkeeper\"}','',0,'',1,1,17,6,NULL,'','2015-02-25 10:18:41','2015-01-23 17:53:20',NULL,'',1,'person8.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,16.00000000,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(10,'2017-10-03 11:47:41','2019-11-28 11:52:58',NULL,NULL,'mcurie',1,NULL,NULL,NULL,1,0,NULL,'52cda011808bb282d1d3625ab607a145',NULL,'t3mnkbhs','Curie','Marie','',NULL,'','','','','mcurie@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'mariecurie.jpg',NULL,NULL,14,NULL,NULL,NULL,'','','',NULL,NULL,'ffaaff','',NULL,0,0,NULL,NULL,NULL,44.00000000,'woman',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(11,'2017-10-05 09:07:52','2019-11-28 11:52:58',NULL,NULL,'zzeceo',1,NULL,NULL,NULL,1,0,NULL,'92af989c4c3a5140fb5d73eb77a52454',NULL,'cq78nf9m','Zeceo','Zack','President - CEO',NULL,'','','','','zzeceo@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 22:48:08','2017-10-05 21:18:46',NULL,'',1,'person4.jpeg',NULL,NULL,NULL,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,NULL,NULL,'2019-06-10 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(12,'2017-10-05 09:09:46','2020-01-07 13:47:17',NULL,NULL,'admin',0,NULL,NULL,NULL,1,0,NULL,'f6fdffe48c908deb0f4c3bd36c032e72',NULL,'nd6hgbcr','Adminson','Alice','Admin Technical',NULL,'','','','','aadminson@example.com','','[]','Alice - 123',1,NULL,1,1,NULL,NULL,NULL,'','2020-01-21 10:38:41','2020-01-21 10:35:27',NULL,'',1,'person6.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,2700.00000000,NULL,NULL,39.00000000,'woman',NULL,NULL,NULL,'generic_user_odt','1985-09-15',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(13,'2017-10-05 21:29:35','2019-11-28 11:52:58',NULL,NULL,'ccommercy',1,NULL,NULL,NULL,1,0,NULL,'179858e041af35e8f4c81d68c55fe9da',NULL,'y451ksdv','Commercy','Coraly','Commercial leader',NULL,'','','','','ccommercy@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'person7.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,1890.00000000,NULL,NULL,25.00000000,'woman',NULL,'2018-09-11 00:00:00',NULL,NULL,'1998-12-08',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(14,'2017-10-05 21:33:33','2019-11-28 11:52:58',NULL,NULL,'sscientol',1,NULL,NULL,NULL,1,0,NULL,'39bee07ac42f31c98e79cdcd5e5fe4c5',NULL,'s2hp8bxd','Scientol','Sam','Scientist leader',NULL,'','','','','sscientol@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,'person3.jpeg',NULL,NULL,11,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,3500.00000000,NULL,NULL,39.00000000,NULL,NULL,'2018-07-03 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(16,'2017-10-05 22:47:52','2019-11-28 11:52:58',NULL,NULL,'ccommerson',1,NULL,NULL,NULL,1,0,NULL,'d68005ccf362b82d084551b6291792a3',NULL,'cx9y1dk0','Charle1','Commerson','Sale representative',NULL,'','','','','ccommerson@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 23:46:24','2017-10-05 23:37:31',NULL,'',1,'person1.jpeg',NULL,NULL,13,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,2900.00000000,NULL,NULL,39.00000000,NULL,NULL,'2019-09-01 00:00:00',NULL,NULL,'1976-02-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(17,'2017-10-05 22:48:39','2019-11-28 11:52:58',NULL,NULL,'aleerfok',1,NULL,NULL,NULL,1,0,NULL,'a964065211872fb76f876c6c3e952ea3',NULL,'gw8cb7xj','Leerfok','Amanda','Sale representative',NULL,'','','','','aleerfok@example.com','','[]','',0,NULL,1,1,NULL,NULL,NULL,'','2017-10-05 23:16:06',NULL,NULL,'',0,'person5.jpeg',NULL,NULL,13,NULL,NULL,NULL,'','','',NULL,NULL,'','',NULL,0,0,NULL,NULL,NULL,39.00000000,'woman',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(18,'2018-01-22 17:27:02','2019-11-28 11:52:58',NULL,NULL,'ldestailleur',1,NULL,NULL,NULL,1,0,NULL,'1bb7805145a7a5066df9e6d585b8b645',NULL,'87g06wbx','Destailleur','Laurent','Project leader of Dolibarr ERP CRM',NULL,'','','','','ldestailleur@example.com','','[]','
Laurent DESTAILLEUR
\r\n\r\n
\r\n
Project Director
\r\nldestailleur@example.com
\r\n\r\n
 
\r\n\r\n
\r\n
Facebook | Twitter | www.teclib.com
\r\n
\r\n
',0,NULL,1,1,10,10,NULL,'More information on http://www.mydomain.com','2019-10-04 10:06:40','2017-09-06 11:55:30',NULL,'',1,'ldestailleur_200x200.jpg',NULL,NULL,NULL,NULL,NULL,NULL,'','','',NULL,NULL,'007f7f','',NULL,0,0,NULL,NULL,NULL,NULL,'man',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL),(19,'2017-02-02 03:55:44','2020-01-16 15:44:42',NULL,NULL,'aboston',1,NULL,NULL,NULL,1,0,NULL,'a7a77a5aff2d5fc2f75f2f61507c88d4',NULL,NULL,'Boston','Alex','',NULL,'','','','','aboston@example.com','','[]','Alex Boston
\r\nAdmin support service - 555 01 02 03 04',0,NULL,1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',0,'person2.jpeg',NULL,NULL,12,NULL,NULL,25.00000000,'','','',NULL,NULL,'ff00ff','',NULL,0,0,2700.00000000,NULL,NULL,32.00000000,NULL,NULL,'2016-11-04 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,-1,NULL,NULL); /*!40000 ALTER TABLE `tmp_user` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; diff --git a/dev/initdemo/mysqldump_dolibarr_3.5.0.sql b/dev/initdemo/mysqldump_dolibarr_3.5.0.sql index 28b05e920d8..46053d1a187 100644 --- a/dev/initdemo/mysqldump_dolibarr_3.5.0.sql +++ b/dev/initdemo/mysqldump_dolibarr_3.5.0.sql @@ -181,7 +181,7 @@ CREATE TABLE `llx_actioncomm` ( LOCK TABLES `llx_actioncomm` WRITE; /*!40000 ALTER TABLE `llx_actioncomm` DISABLE KEYS */; -INSERT INTO `llx_actioncomm` VALUES (1,NULL,1,'2010-07-08 14:21:44','2010-07-08 14:21:44',NULL,NULL,50,NULL,'Company AAA and Co added into Dolibarr','2010-07-08 14:21:44','2010-07-08 12:21:44',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company AAA and Co added into Dolibarr\nAuthor: admin',NULL,NULL),(2,NULL,1,'2010-07-08 14:23:48','2010-07-08 14:23:48',NULL,NULL,50,NULL,'Company Belin SARL added into Dolibarr','2010-07-08 14:23:48','2010-07-08 12:23:48',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company Belin SARL added into Dolibarr\nAuthor: admin',NULL,NULL),(3,NULL,1,'2010-07-08 22:42:12','2010-07-08 22:42:12',NULL,NULL,50,NULL,'Company Spanish Comp added into Dolibarr','2010-07-08 22:42:12','2010-07-08 20:42:12',1,NULL,NULL,3,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company Spanish Comp added into Dolibarr\nAuthor: admin',NULL,NULL),(4,NULL,1,'2010-07-08 22:48:18','2010-07-08 22:48:18',NULL,NULL,50,NULL,'Company Prospector Vaalen added into Dolibarr','2010-07-08 22:48:18','2010-07-08 20:48:18',1,NULL,NULL,4,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company Prospector Vaalen added into Dolibarr\nAuthor: admin',NULL,NULL),(5,NULL,1,'2010-07-08 23:22:57','2010-07-08 23:22:57',NULL,NULL,50,NULL,'Company NoCountry Co added into Dolibarr','2010-07-08 23:22:57','2010-07-08 21:22:57',1,NULL,NULL,5,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company NoCountry Co added into Dolibarr\nAuthor: admin',NULL,NULL),(6,NULL,1,'2010-07-09 00:15:09','2010-07-09 00:15:09',NULL,NULL,50,NULL,'Company Swiss customer added into Dolibarr','2010-07-09 00:15:09','2010-07-08 22:15:09',1,NULL,NULL,6,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company Swiss customer added into Dolibarr\nAuthor: admin',NULL,NULL),(7,NULL,1,'2010-07-09 01:24:26','2010-07-09 01:24:26',NULL,NULL,50,NULL,'Company Generic customer added into Dolibarr','2010-07-09 01:24:26','2010-07-08 23:24:26',1,NULL,NULL,7,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company Generic customer added into Dolibarr\nAuthor: admin',NULL,NULL),(8,NULL,1,'2010-07-10 14:54:27','2010-07-10 14:54:27',NULL,NULL,50,NULL,'Société Client salon ajoutée dans Dolibarr','2010-07-10 14:54:27','2010-07-10 12:54:27',1,NULL,NULL,8,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Client salon ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(9,NULL,1,'2010-07-10 14:54:44','2010-07-10 14:54:44',NULL,NULL,50,NULL,'Société Client salon invidivdu ajoutée dans Doliba','2010-07-10 14:54:44','2010-07-10 12:54:44',1,NULL,NULL,9,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Client salon invidivdu ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(10,NULL,1,'2010-07-10 14:56:10','2010-07-10 14:56:10',NULL,NULL,50,NULL,'Facture FA1007-0001 validée dans Dolibarr','2010-07-10 14:56:10','2011-07-18 17:29:22',1,NULL,NULL,9,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Facture FA1007-0001 validée dans Dolibarr\nAuteur: admin',1,'invoice'),(11,NULL,1,'2010-07-10 14:58:53','2010-07-10 14:58:53',NULL,NULL,50,NULL,'Facture FA1007-0001 validée dans Dolibarr','2010-07-10 14:58:53','2011-07-18 17:29:22',1,NULL,NULL,9,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Facture FA1007-0001 validée dans Dolibarr\nAuteur: admin',1,'invoice'),(12,NULL,1,'2010-07-10 15:00:55','2010-07-10 15:00:55',NULL,NULL,50,NULL,'Facture FA1007-0001 passée à payée dans Dolibarr','2010-07-10 15:00:55','2011-07-18 17:29:22',1,NULL,NULL,9,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Facture FA1007-0001 passée à payée dans Dolibarr\nAuteur: admin',1,'invoice'),(13,NULL,1,'2010-07-10 15:13:08','2010-07-10 15:13:08',NULL,NULL,50,NULL,'Société Smith Vick ajoutée dans Dolibarr','2010-07-10 15:13:08','2010-07-10 13:13:08',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Smith Vick ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(14,NULL,1,'2010-07-10 15:21:00','2010-07-10 16:21:00',NULL,NULL,5,NULL,'RDV avec mon chef','2010-07-10 15:21:48','2010-07-10 13:21:48',1,NULL,NULL,NULL,NULL,0,1,NULL,NULL,0,0,1,0,'',3600,NULL,'',NULL,NULL),(15,NULL,1,'2010-07-10 18:18:16','2010-07-10 18:18:16',NULL,NULL,50,NULL,'Contrat CONTRAT1 validé dans Dolibarr','2010-07-10 18:18:16','2010-07-10 16:18:16',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Contrat CONTRAT1 validé dans Dolibarr\nAuteur: admin',NULL,NULL),(16,NULL,1,'2010-07-10 18:35:57','2010-07-10 18:35:57',NULL,NULL,50,NULL,'Société Mon client ajoutée dans Dolibarr','2010-07-10 18:35:57','2010-07-10 16:35:57',1,NULL,NULL,11,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Mon client ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(17,NULL,1,'2010-07-11 16:18:08','2010-07-11 16:18:08',NULL,NULL,50,NULL,'Société Dupont Alain ajoutée dans Dolibarr','2010-07-11 16:18:08','2010-07-11 14:18:08',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Dupont Alain ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(18,NULL,1,'2010-07-11 17:11:00','2010-07-11 17:17:00',NULL,NULL,5,NULL,'Rendez-vous','2010-07-11 17:11:22','2010-07-11 15:11:22',1,NULL,NULL,NULL,NULL,0,1,NULL,NULL,0,0,1,0,'gfgdfgdf',360,NULL,'',NULL,NULL),(19,NULL,1,'2010-07-11 17:13:20','2010-07-11 17:13:20',NULL,NULL,50,NULL,'Société Vendeur de chips ajoutée dans Dolibarr','2010-07-11 17:13:20','2010-07-11 15:13:20',1,NULL,NULL,13,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Vendeur de chips ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(20,NULL,1,'2010-07-11 17:15:42','2010-07-11 17:15:42',NULL,NULL,50,NULL,'Commande CF1007-0001 validée','2010-07-11 17:15:42','2010-07-11 15:15:42',1,NULL,NULL,13,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Commande CF1007-0001 validée\nAuteur: admin',NULL,NULL),(21,NULL,1,'2010-07-11 18:47:33','2010-07-11 18:47:33',NULL,NULL,50,NULL,'Commande CF1007-0002 validée','2010-07-11 18:47:33','2010-07-11 16:47:33',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Commande CF1007-0002 validée\nAuteur: admin',NULL,NULL),(22,NULL,1,'2010-07-18 11:36:18','2010-07-18 11:36:18',NULL,NULL,50,NULL,'Proposition PR1007-0003 validée','2010-07-18 11:36:18','2011-07-18 17:29:22',1,NULL,NULL,4,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Proposition PR1007-0003 validée\nAuteur: admin',3,'propal'),(23,NULL,1,'2011-07-18 20:49:58','2011-07-18 20:49:58',NULL,NULL,50,NULL,'Invoice FA1007-0002 validated in Dolibarr','2011-07-18 20:49:58','2011-07-18 18:49:58',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1007-0002 validated in Dolibarr\nAuthor: admin',2,'invoice'),(24,NULL,1,'2011-07-28 01:37:00',NULL,NULL,NULL,1,NULL,'Phone call','2011-07-28 01:37:48','2011-07-27 23:37:48',1,NULL,NULL,NULL,2,0,1,NULL,NULL,0,0,1,-1,'',NULL,NULL,'',NULL,NULL),(25,NULL,1,'2011-08-01 02:31:24','2011-08-01 02:31:24',NULL,NULL,50,NULL,'Company mmm added into Dolibarr','2011-08-01 02:31:24','2011-08-01 00:31:24',1,NULL,NULL,15,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Company mmm added into Dolibarr\nAuthor: admin',15,'societe'),(26,NULL,1,'2011-08-01 02:31:43','2011-08-01 02:31:43',NULL,NULL,50,NULL,'Company ppp added into Dolibarr','2011-08-01 02:31:43','2011-08-01 00:31:43',1,NULL,NULL,16,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Company ppp added into Dolibarr\nAuthor: admin',16,'societe'),(27,NULL,1,'2011-08-01 02:41:26','2011-08-01 02:41:26',NULL,NULL,50,NULL,'Company aaa added into Dolibarr','2011-08-01 02:41:26','2011-08-01 00:41:26',1,NULL,NULL,17,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Company aaa added into Dolibarr\nAuthor: admin',17,'societe'),(28,NULL,1,'2011-08-01 03:34:11','2011-08-01 03:34:11',NULL,NULL,50,NULL,'Invoice FA1108-0003 validated in Dolibarr','2011-08-01 03:34:11','2011-08-01 01:34:11',1,NULL,NULL,7,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0003 validated in Dolibarr\nAuthor: admin',5,'invoice'),(29,NULL,1,'2011-08-01 03:34:11','2011-08-01 03:34:11',NULL,NULL,50,NULL,'Invoice FA1108-0003 validated in Dolibarr','2011-08-01 03:34:11','2011-08-01 01:34:11',1,NULL,NULL,7,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0003 changed to paid in Dolibarr\nAuthor: admin',5,'invoice'),(30,NULL,1,'2011-08-06 20:33:54','2011-08-06 20:33:54',NULL,NULL,50,NULL,'Invoice FA1108-0004 validated in Dolibarr','2011-08-06 20:33:54','2011-08-06 18:33:54',1,NULL,NULL,7,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0004 validated in Dolibarr\nAuthor: admin',6,'invoice'),(31,NULL,1,'2011-08-06 20:33:54','2011-08-06 20:33:54',NULL,NULL,50,NULL,'Invoice FA1108-0004 validated in Dolibarr','2011-08-06 20:33:54','2011-08-06 18:33:54',1,NULL,NULL,7,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0004 changed to paid in Dolibarr\nAuthor: admin',6,'invoice'),(38,NULL,1,'2011-08-08 02:41:55','2011-08-08 02:41:55',NULL,NULL,50,NULL,'Invoice FA1108-0005 validated in Dolibarr','2011-08-08 02:41:55','2011-08-08 00:41:55',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0005 validated in Dolibarr\nAuthor: admin',8,'invoice'),(40,NULL,1,'2011-08-08 02:53:40','2011-08-08 02:53:40',NULL,NULL,50,NULL,'Invoice FA1108-0005 changed to paid in Dolibarr','2011-08-08 02:53:40','2011-08-08 00:53:40',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0005 changed to paid in Dolibarr\nAuthor: admin',8,'invoice'),(41,NULL,1,'2011-08-08 02:54:05','2011-08-08 02:54:05',NULL,NULL,50,NULL,'Invoice FA1007-0002 changed to paid in Dolibarr','2011-08-08 02:54:05','2011-08-08 00:54:05',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1007-0002 changed to paid in Dolibarr\nAuthor: admin',2,'invoice'),(42,NULL,1,'2011-08-08 02:55:04','2011-08-08 02:55:04',NULL,NULL,50,NULL,'Invoice FA1107-0006 validated in Dolibarr','2011-08-08 02:55:04','2011-08-08 00:55:04',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1107-0006 validated in Dolibarr\nAuthor: admin',3,'invoice'),(43,NULL,1,'2011-08-08 02:55:26','2011-08-08 02:55:26',NULL,NULL,50,NULL,'Invoice FA1108-0007 validated in Dolibarr','2011-08-08 02:55:26','2011-08-08 00:55:26',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0007 validated in Dolibarr\nAuthor: admin',9,'invoice'),(44,NULL,1,'2011-08-08 02:55:58','2011-08-08 02:55:58',NULL,NULL,50,NULL,'Invoice FA1107-0006 changed to paid in Dolibarr','2011-08-08 02:55:58','2011-08-08 00:55:58',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1107-0006 changed to paid in Dolibarr\nAuthor: admin',3,'invoice'),(45,NULL,1,'2011-08-08 03:04:22','2011-08-08 03:04:22',NULL,NULL,50,NULL,'Order CO1108-0001 validated','2011-08-08 03:04:22','2011-08-08 01:04:22',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Order CO1108-0001 validated\nAuthor: admin',5,'order'),(46,NULL,1,'2011-08-08 13:59:09','2011-08-08 13:59:09',NULL,NULL,50,NULL,'Order CO1107-0002 validated','2011-08-08 13:59:10','2011-08-08 11:59:10',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Order CO1107-0002 validated\nAuthor: admin',1,'order'),(47,NULL,1,'2011-08-08 14:24:18','2011-08-08 14:24:18',NULL,NULL,50,NULL,'Proposal PR1007-0001 validated','2011-08-08 14:24:18','2011-08-08 12:24:18',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Proposal PR1007-0001 validated\nAuthor: admin',1,'propal'),(48,NULL,1,'2011-08-08 14:24:24','2011-08-08 14:24:24',NULL,NULL,50,NULL,'Proposal PR1108-0004 validated','2011-08-08 14:24:24','2011-08-08 12:24:24',1,NULL,NULL,17,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Proposal PR1108-0004 validated\nAuthor: admin',4,'propal'),(49,NULL,1,'2011-08-08 15:04:37','2011-08-08 15:04:37',NULL,NULL,50,NULL,'Order CF1108-0003 validated','2011-08-08 15:04:37','2011-08-08 13:04:37',1,NULL,NULL,17,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Order CF1108-0003 validated\nAuthor: admin',6,'order_supplier'),(50,NULL,1,'2012-12-08 17:56:47','2012-12-08 17:56:47',NULL,NULL,40,NULL,'Facture AV1212-0001 validée dans Dolibarr','2012-12-08 17:56:47','2012-12-08 16:56:47',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture AV1212-0001 validée dans Dolibarr\nAuteur: admin',10,'invoice'),(51,NULL,1,'2012-12-08 17:57:11','2012-12-08 17:57:11',NULL,NULL,40,NULL,'Facture AV1212-0001 validée dans Dolibarr','2012-12-08 17:57:11','2012-12-08 16:57:11',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture AV1212-0001 validée dans Dolibarr\nAuteur: admin',10,'invoice'),(52,NULL,1,'2012-12-08 17:58:27','2012-12-08 17:58:27',NULL,NULL,40,NULL,'Facture FA1212-0008 validée dans Dolibarr','2012-12-08 17:58:27','2012-12-08 16:58:27',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1212-0008 validée dans Dolibarr\nAuteur: admin',11,'invoice'),(53,NULL,1,'2012-12-08 18:20:49','2012-12-08 18:20:49',NULL,NULL,40,NULL,'Facture AV1212-0002 validée dans Dolibarr','2012-12-08 18:20:49','2012-12-08 17:20:49',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture AV1212-0002 validée dans Dolibarr\nAuteur: admin',12,'invoice'),(54,NULL,1,'2012-12-09 18:35:07','2012-12-09 18:35:07',NULL,NULL,40,NULL,'Facture AV1212-0002 passée à payée dans Dolibarr','2012-12-09 18:35:07','2012-12-09 17:35:07',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture AV1212-0002 passée à payée dans Dolibarr\nAuteur: admin',12,'invoice'),(55,NULL,1,'2012-12-09 20:14:42','2012-12-09 20:14:42',NULL,NULL,40,NULL,'Société doe john ajoutée dans Dolibarr','2012-12-09 20:14:42','2012-12-09 19:14:42',1,NULL,NULL,18,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Société doe john ajoutée dans Dolibarr\nAuteur: admin',18,'societe'),(56,NULL,1,'2012-12-12 18:54:19','2012-12-12 18:54:19',NULL,NULL,40,NULL,'Facture FA1212-0009 validée dans Dolibarr','2012-12-12 18:54:19','2012-12-12 17:54:19',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1212-0009 validée dans Dolibarr\nAuteur: admin',55,'invoice'),(121,NULL,1,'2012-12-06 10:00:00',NULL,NULL,NULL,50,NULL,'aaab','2012-12-21 17:48:08','2012-12-21 16:54:07',3,1,NULL,NULL,NULL,0,3,NULL,NULL,1,0,1,-1,NULL,NULL,NULL,NULL,NULL,NULL),(122,NULL,1,'2012-12-21 18:09:52','2012-12-21 18:09:52',NULL,NULL,40,NULL,'Facture client FA1007-0001 envoyée par EMail','2012-12-21 18:09:52','2012-12-21 17:09:52',1,NULL,NULL,9,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Mail envoyé par Firstname SuperAdminName à laurent@destailleur.fr.\nSujet du mail: Envoi facture FA1007-0001\nCorps du mail:\nVeuillez trouver ci-joint la facture FA1007-0001\r\n\r\nVous pouvez cliquer sur le lien sécurisé ci-dessous pour effectuer votre paiement via Paypal\r\n\r\nhttp://localhost/dolibarrnew/public/paypal/newpayment.php?source=invoice&ref=FA1007-0001&securekey=50c82fab36bb3b6aa83e2a50691803b2\r\n\r\nCordialement',1,'invoice'),(123,NULL,1,'2013-01-06 13:13:57','2013-01-06 13:13:57',NULL,NULL,40,NULL,'Facture 16 validée dans Dolibarr','2013-01-06 13:13:57','2013-01-06 12:13:57',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture 16 validée dans Dolibarr\nAuteur: admin',16,'invoice_supplier'),(124,NULL,1,'2013-01-12 12:23:05','2013-01-12 12:23:05',NULL,NULL,40,NULL,'Patient aaa ajouté','2013-01-12 12:23:05','2013-01-12 11:23:05',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Patient aaa ajouté\nAuteur: admin',19,'societe'),(125,NULL,1,'2013-01-12 12:52:20','2013-01-12 12:52:20',NULL,NULL,40,NULL,'Patient pppoo ajouté','2013-01-12 12:52:20','2013-01-12 11:52:20',1,NULL,NULL,20,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Patient pppoo ajouté\nAuteur: admin',20,'societe'),(127,NULL,1,'2013-01-19 18:22:48','2013-01-19 18:22:48',NULL,NULL,40,NULL,'Facture FS1301-0001 validée dans Dolibarr','2013-01-19 18:22:48','2013-01-19 17:22:48',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FS1301-0001 validée dans Dolibarr\nAuteur: admin',148,'invoice'),(128,NULL,1,'2013-01-19 18:31:10','2013-01-19 18:31:10',NULL,NULL,40,NULL,'Facture FA6801-0010 validée dans Dolibarr','2013-01-19 18:31:10','2013-01-19 17:31:10',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA6801-0010 validée dans Dolibarr\nAuteur: admin',150,'invoice'),(129,NULL,1,'2013-01-19 18:31:10','2013-01-19 18:31:10',NULL,NULL,40,NULL,'Facture FA6801-0010 passée à payée dans Dolibarr','2013-01-19 18:31:10','2013-01-19 17:31:10',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA6801-0010 passée à payée dans Dolibarr\nAuteur: admin',150,'invoice'),(130,NULL,1,'2013-01-19 18:31:58','2013-01-19 18:31:58',NULL,NULL,40,NULL,'Facture FS1301-0002 validée dans Dolibarr','2013-01-19 18:31:58','2013-01-19 17:31:58',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FS1301-0002 validée dans Dolibarr\nAuteur: admin',151,'invoice'),(131,NULL,1,'2013-01-19 18:31:58','2013-01-19 18:31:58',NULL,NULL,40,NULL,'Facture FS1301-0002 passée à payée dans Dolibarr','2013-01-19 18:31:58','2013-01-19 17:31:58',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FS1301-0002 passée à payée dans Dolibarr\nAuteur: admin',151,'invoice'),(132,NULL,1,'2013-01-23 15:07:54','2013-01-23 15:07:54',NULL,NULL,50,NULL,'Consultation 24 saisie (aaa)','2013-01-23 15:07:54','2013-01-23 14:07:54',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Consultation 24 saisie (aaa)\nAuteur: admin',24,'cabinetmed_cons'),(133,NULL,1,'2013-01-23 16:56:58','2013-01-23 16:56:58',NULL,NULL,40,NULL,'Patient pa ajouté','2013-01-23 16:56:58','2013-01-23 15:56:58',1,NULL,NULL,21,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Patient pa ajouté\nAuteur: admin',21,'societe'),(134,NULL,1,'2013-01-23 17:34:00',NULL,NULL,NULL,50,NULL,'bbcv','2013-01-23 17:35:21','2013-01-23 16:35:21',1,NULL,1,2,NULL,0,1,NULL,NULL,0,0,1,-1,'',NULL,NULL,'',NULL,NULL),(135,NULL,1,'2013-02-12 15:54:00','2013-02-12 15:54:00',NULL,NULL,40,NULL,'Facture FA1212-0011 validée dans Dolibarr','2013-02-12 15:54:37','2013-02-20 20:11:54',1,1,NULL,7,NULL,0,NULL,NULL,1,0,0,1,50,NULL,NULL,NULL,'Facture FA1212-0011 validée dans Dolibarr
\r\nAuteur: admin',13,'invoice'),(136,NULL,1,'2013-02-12 17:06:51','2013-02-12 17:06:51',NULL,NULL,40,NULL,'Commande CO1107-0003 validée','2013-02-12 17:06:51','2013-02-12 16:06:51',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Commande CO1107-0003 validée\nAuteur: admin',2,'order'),(137,NULL,1,'2013-02-17 16:22:10','2013-02-17 16:22:10',NULL,NULL,40,NULL,'Proposition PR1302-0009 validée','2013-02-17 16:22:10','2013-02-17 15:22:10',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Proposition PR1302-0009 validée\nAuteur: admin',9,'propal'),(138,NULL,1,'2013-02-17 16:27:00','2013-02-17 16:27:00',NULL,NULL,40,NULL,'Facture FA1302-0012 validée dans Dolibarr','2013-02-17 16:27:00','2013-02-17 15:27:00',1,NULL,NULL,18,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1302-0012 validée dans Dolibarr\nAuteur: admin',152,'invoice'),(139,NULL,1,'2013-02-17 16:27:29','2013-02-17 16:27:29',NULL,NULL,40,NULL,'Proposition PR1302-0010 validée','2013-02-17 16:27:29','2013-02-17 15:27:29',1,NULL,NULL,18,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Proposition PR1302-0010 validée\nAuteur: admin',11,'propal'),(140,NULL,1,'2013-02-17 18:27:56','2013-02-17 18:27:56',NULL,NULL,40,NULL,'Commande CO1107-0004 validée','2013-02-17 18:27:56','2013-02-17 17:27:56',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Commande CO1107-0004 validée\nAuteur: admin',3,'order'),(141,NULL,1,'2013-02-17 18:38:14','2013-02-17 18:38:14',NULL,NULL,40,NULL,'Commande CO1302-0005 validée','2013-02-17 18:38:14','2013-02-17 17:38:14',1,NULL,NULL,18,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Commande CO1302-0005 validée\nAuteur: admin',7,'order'),(142,NULL,1,'2013-02-26 22:57:50','2013-02-26 22:57:50',NULL,NULL,40,NULL,'Company pppp added into Dolibarr','2013-02-26 22:57:50','2013-02-26 21:57:50',1,NULL,NULL,22,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Company pppp added into Dolibarr\nAuthor: admin',22,'societe'),(143,NULL,1,'2013-02-26 22:58:13','2013-02-26 22:58:13',NULL,NULL,40,NULL,'Company ttttt added into Dolibarr','2013-02-26 22:58:13','2013-02-26 21:58:13',1,NULL,NULL,23,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Company ttttt added into Dolibarr\nAuthor: admin',23,'societe'),(144,NULL,1,'2013-02-27 10:00:00','2013-02-27 19:20:00',NULL,NULL,5,NULL,'Rendez-vous','2013-02-27 19:20:53','2013-02-27 18:20:53',1,NULL,NULL,NULL,NULL,0,1,NULL,1,0,0,1,-1,'',33600,NULL,'',NULL,NULL),(145,NULL,1,'2013-02-27 19:28:00',NULL,NULL,NULL,2,NULL,'fdsfsd','2013-02-27 19:28:48','2013-02-27 18:29:53',1,1,NULL,NULL,NULL,0,1,NULL,1,0,0,1,-1,NULL,NULL,NULL,NULL,NULL,NULL),(146,NULL,1,'2013-03-06 10:05:07','2013-03-06 10:05:07',NULL,NULL,40,NULL,'Contrat (PROV3) validé dans Dolibarr','2013-03-06 10:05:07','2013-03-06 09:05:07',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Contrat (PROV3) validé dans Dolibarr\nAuteur: admin',3,'contract'),(147,NULL,1,'2013-03-06 16:43:37','2013-03-06 16:43:37',NULL,NULL,40,NULL,'Facture FA1307-0013 validée dans Dolibarr','2013-03-06 16:43:37','2013-03-06 15:43:37',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1307-0013 validée dans Dolibarr\nAuteur: admin',158,'invoice'),(148,NULL,1,'2013-03-06 16:44:12','2013-03-06 16:44:12',NULL,NULL,40,NULL,'Facture FA1407-0014 validée dans Dolibarr','2013-03-06 16:44:12','2013-03-06 15:44:12',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1407-0014 validée dans Dolibarr\nAuteur: admin',159,'invoice'),(149,NULL,1,'2013-03-06 16:47:48','2013-03-06 16:47:48',NULL,NULL,40,NULL,'Facture FA1507-0015 validée dans Dolibarr','2013-03-06 16:47:48','2013-03-06 15:47:48',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1507-0015 validée dans Dolibarr\nAuteur: admin',160,'invoice'),(150,NULL,1,'2013-03-06 16:48:16','2013-03-06 16:48:16',NULL,NULL,40,NULL,'Facture FA1607-0016 validée dans Dolibarr','2013-03-06 16:48:16','2013-03-06 15:48:16',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1607-0016 validée dans Dolibarr\nAuteur: admin',161,'invoice'),(151,NULL,1,'2013-03-06 17:13:59','2013-03-06 17:13:59',NULL,NULL,40,NULL,'Société smith smith ajoutée dans Dolibarr','2013-03-06 17:13:59','2013-03-06 16:13:59',1,NULL,NULL,24,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Société smith smith ajoutée dans Dolibarr\nAuteur: admin',24,'societe'),(152,NULL,1,'2013-03-08 10:02:22','2013-03-08 10:02:22',NULL,NULL,40,NULL,'Proposition (PROV12) validée dans Dolibarr','2013-03-08 10:02:22','2013-03-08 09:02:22',1,NULL,NULL,23,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Proposition (PROV12) validée dans Dolibarr\nAuteur: admin',12,'propal'),(203,NULL,1,'2013-03-09 19:39:27','2013-03-09 19:39:27',NULL,NULL,40,'AC_ORDER_SUPPLIER_VALIDATE','Commande CF1303-0004 validée','2013-03-09 19:39:27','2013-03-09 18:39:27',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Commande CF1303-0004 validée\nAuteur: admin',13,'order_supplier'),(204,NULL,1,'2013-03-10 15:47:37','2013-03-10 15:47:37',NULL,NULL,40,'AC_COMPANY_CREATE','Patient créé','2013-03-10 15:47:37','2013-03-10 14:47:37',1,NULL,NULL,25,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Patient créé\nAuteur: admin',25,'societe'),(205,NULL,1,'2013-03-10 15:57:32','2013-03-10 15:57:32',NULL,NULL,40,'AC_COMPANY_CREATE','Tiers créé','2013-03-10 15:57:32','2013-03-10 14:57:32',1,NULL,NULL,26,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Tiers créé\nAuteur: admin',26,'societe'),(206,NULL,1,'2013-03-10 15:58:28','2013-03-10 15:58:28',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1303-0017 validée','2013-03-10 15:58:28','2013-03-10 14:58:28',1,NULL,NULL,26,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1303-0017 validée\nAuteur: admin',208,'invoice'),(207,NULL,1,'2013-03-19 09:38:10','2013-03-19 09:38:10',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1303-0018 validée','2013-03-19 09:38:10','2013-03-19 08:38:10',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1303-0018 validée\nAuteur: admin',209,'invoice'),(208,NULL,1,'2013-03-20 14:30:11','2013-03-20 14:30:11',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1107-0019 validée','2013-03-20 14:30:11','2013-03-20 13:30:11',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1107-0019 validée\nAuteur: admin',210,'invoice'),(209,NULL,1,'2013-03-22 09:40:25','2013-03-22 09:40:25',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1303-0020 validée','2013-03-22 09:40:25','2013-03-22 08:40:25',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1303-0020 validée\nAuteur: admin',211,'invoice'),(210,NULL,1,'2013-03-23 17:16:25','2013-03-23 17:16:25',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1303-0020 validée','2013-03-23 17:16:25','2013-03-23 16:16:25',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1303-0020 validée\nAuteur: admin',211,'invoice'),(211,NULL,1,'2013-03-23 18:08:27','2013-03-23 18:08:27',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1307-0013 validée','2013-03-23 18:08:27','2013-03-23 17:08:27',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1307-0013 validée\nAuteur: admin',158,'invoice'),(212,NULL,1,'2013-03-24 15:54:00','2013-03-24 15:54:00',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1212-0021 validée','2013-03-24 15:54:00','2013-03-24 14:54:00',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1212-0021 validée\nAuteur: admin',32,'invoice'),(213,NULL,1,'2013-11-07 01:02:39','2013-11-07 01:02:39',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:02:39','2013-11-07 00:02:39',1,NULL,NULL,27,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',27,'societe'),(214,NULL,1,'2013-11-07 01:05:22','2013-11-07 01:05:22',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:05:22','2013-11-07 00:05:22',1,NULL,NULL,28,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',28,'societe'),(215,NULL,1,'2013-11-07 01:07:07','2013-11-07 01:07:07',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:07:07','2013-11-07 00:07:07',1,NULL,NULL,29,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',29,'societe'),(216,NULL,1,'2013-11-07 01:07:58','2013-11-07 01:07:58',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:07:58','2013-11-07 00:07:58',1,NULL,NULL,30,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',30,'societe'),(217,NULL,1,'2013-11-07 01:10:09','2013-11-07 01:10:09',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:10:09','2013-11-07 00:10:09',1,NULL,NULL,31,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',31,'societe'),(218,NULL,1,'2013-11-07 01:15:57','2013-11-07 01:15:57',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:15:57','2013-11-07 00:15:57',1,NULL,NULL,32,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',32,'societe'),(219,NULL,1,'2013-11-07 01:16:51','2013-11-07 01:16:51',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:16:51','2013-11-07 00:16:51',1,NULL,NULL,33,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',33,'societe'); +INSERT INTO `llx_actioncomm` VALUES (1,NULL,1,'2010-07-08 14:21:44','2010-07-08 14:21:44',NULL,NULL,50,NULL,'Company AAA and Co added into Dolibarr','2010-07-08 14:21:44','2010-07-08 12:21:44',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company AAA and Co added into Dolibarr\nAuthor: admin',NULL,NULL),(2,NULL,1,'2010-07-08 14:23:48','2010-07-08 14:23:48',NULL,NULL,50,NULL,'Company Belin SARL added into Dolibarr','2010-07-08 14:23:48','2010-07-08 12:23:48',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company Belin SARL added into Dolibarr\nAuthor: admin',NULL,NULL),(3,NULL,1,'2010-07-08 22:42:12','2010-07-08 22:42:12',NULL,NULL,50,NULL,'Company Spanish Comp added into Dolibarr','2010-07-08 22:42:12','2010-07-08 20:42:12',1,NULL,NULL,3,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company Spanish Comp added into Dolibarr\nAuthor: admin',NULL,NULL),(4,NULL,1,'2010-07-08 22:48:18','2010-07-08 22:48:18',NULL,NULL,50,NULL,'Company Prospector Vaalen added into Dolibarr','2010-07-08 22:48:18','2010-07-08 20:48:18',1,NULL,NULL,4,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company Prospector Vaalen added into Dolibarr\nAuthor: admin',NULL,NULL),(5,NULL,1,'2010-07-08 23:22:57','2010-07-08 23:22:57',NULL,NULL,50,NULL,'Company NoCountry Co added into Dolibarr','2010-07-08 23:22:57','2010-07-08 21:22:57',1,NULL,NULL,5,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company NoCountry Co added into Dolibarr\nAuthor: admin',NULL,NULL),(6,NULL,1,'2010-07-09 00:15:09','2010-07-09 00:15:09',NULL,NULL,50,NULL,'Company Swiss customer added into Dolibarr','2010-07-09 00:15:09','2010-07-08 22:15:09',1,NULL,NULL,6,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company Swiss customer added into Dolibarr\nAuthor: admin',NULL,NULL),(7,NULL,1,'2010-07-09 01:24:26','2010-07-09 01:24:26',NULL,NULL,50,NULL,'Company Generic customer added into Dolibarr','2010-07-09 01:24:26','2010-07-08 23:24:26',1,NULL,NULL,7,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Company Generic customer added into Dolibarr\nAuthor: admin',NULL,NULL),(8,NULL,1,'2010-07-10 14:54:27','2010-07-10 14:54:27',NULL,NULL,50,NULL,'Société Client salon ajoutée dans Dolibarr','2010-07-10 14:54:27','2010-07-10 12:54:27',1,NULL,NULL,8,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Client salon ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(9,NULL,1,'2010-07-10 14:54:44','2010-07-10 14:54:44',NULL,NULL,50,NULL,'Société Client salon invidivdu ajoutée dans Doliba','2010-07-10 14:54:44','2010-07-10 12:54:44',1,NULL,NULL,9,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Client salon invidivdu ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(10,NULL,1,'2010-07-10 14:56:10','2010-07-10 14:56:10',NULL,NULL,50,NULL,'Facture FA1007-0001 validée dans Dolibarr','2010-07-10 14:56:10','2011-07-18 17:29:22',1,NULL,NULL,9,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Facture FA1007-0001 validée dans Dolibarr\nAuteur: admin',1,'invoice'),(11,NULL,1,'2010-07-10 14:58:53','2010-07-10 14:58:53',NULL,NULL,50,NULL,'Facture FA1007-0001 validée dans Dolibarr','2010-07-10 14:58:53','2011-07-18 17:29:22',1,NULL,NULL,9,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Facture FA1007-0001 validée dans Dolibarr\nAuteur: admin',1,'invoice'),(12,NULL,1,'2010-07-10 15:00:55','2010-07-10 15:00:55',NULL,NULL,50,NULL,'Facture FA1007-0001 passée à payée dans Dolibarr','2010-07-10 15:00:55','2011-07-18 17:29:22',1,NULL,NULL,9,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Facture FA1007-0001 passée à payée dans Dolibarr\nAuteur: admin',1,'invoice'),(13,NULL,1,'2010-07-10 15:13:08','2010-07-10 15:13:08',NULL,NULL,50,NULL,'Société Smith Vick ajoutée dans Dolibarr','2010-07-10 15:13:08','2010-07-10 13:13:08',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Smith Vick ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(14,NULL,1,'2010-07-10 15:21:00','2010-07-10 16:21:00',NULL,NULL,5,NULL,'RDV avec mon chef','2010-07-10 15:21:48','2010-07-10 13:21:48',1,NULL,NULL,NULL,NULL,0,1,NULL,NULL,0,0,1,0,'',3600,NULL,'',NULL,NULL),(15,NULL,1,'2010-07-10 18:18:16','2010-07-10 18:18:16',NULL,NULL,50,NULL,'Contrat CONTRAT1 validé dans Dolibarr','2010-07-10 18:18:16','2010-07-10 16:18:16',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Contrat CONTRAT1 validé dans Dolibarr\nAuteur: admin',NULL,NULL),(16,NULL,1,'2010-07-10 18:35:57','2010-07-10 18:35:57',NULL,NULL,50,NULL,'Société Mon client ajoutée dans Dolibarr','2010-07-10 18:35:57','2010-07-10 16:35:57',1,NULL,NULL,11,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Mon client ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(17,NULL,1,'2010-07-11 16:18:08','2010-07-11 16:18:08',NULL,NULL,50,NULL,'Société Dupont Alain ajoutée dans Dolibarr','2010-07-11 16:18:08','2010-07-11 14:18:08',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Dupont Alain ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(18,NULL,1,'2010-07-11 17:11:00','2010-07-11 17:17:00',NULL,NULL,5,NULL,'Rendez-vous','2010-07-11 17:11:22','2010-07-11 15:11:22',1,NULL,NULL,NULL,NULL,0,1,NULL,NULL,0,0,1,0,'gfgdfgdf',360,NULL,'',NULL,NULL),(19,NULL,1,'2010-07-11 17:13:20','2010-07-11 17:13:20',NULL,NULL,50,NULL,'Société Vendeur de chips ajoutée dans Dolibarr','2010-07-11 17:13:20','2010-07-11 15:13:20',1,NULL,NULL,13,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Société Vendeur de chips ajoutée dans Dolibarr\nAuteur: admin',NULL,NULL),(20,NULL,1,'2010-07-11 17:15:42','2010-07-11 17:15:42',NULL,NULL,50,NULL,'Commande CF1007-0001 validée','2010-07-11 17:15:42','2010-07-11 15:15:42',1,NULL,NULL,13,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Commande CF1007-0001 validée\nAuteur: admin',NULL,NULL),(21,NULL,1,'2010-07-11 18:47:33','2010-07-11 18:47:33',NULL,NULL,50,NULL,'Commande CF1007-0002 validée','2010-07-11 18:47:33','2010-07-11 16:47:33',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Commande CF1007-0002 validée\nAuteur: admin',NULL,NULL),(22,NULL,1,'2010-07-18 11:36:18','2010-07-18 11:36:18',NULL,NULL,50,NULL,'Proposition PR1007-0003 validée','2010-07-18 11:36:18','2011-07-18 17:29:22',1,NULL,NULL,4,NULL,0,NULL,NULL,1,0,0,1,100,'',NULL,NULL,'Proposition PR1007-0003 validée\nAuteur: admin',3,'propal'),(23,NULL,1,'2011-07-18 20:49:58','2011-07-18 20:49:58',NULL,NULL,50,NULL,'Invoice FA1007-0002 validated in Dolibarr','2011-07-18 20:49:58','2011-07-18 18:49:58',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1007-0002 validated in Dolibarr\nAuthor: admin',2,'invoice'),(24,NULL,1,'2011-07-28 01:37:00',NULL,NULL,NULL,1,NULL,'Phone call','2011-07-28 01:37:48','2011-07-27 23:37:48',1,NULL,NULL,NULL,2,0,1,NULL,NULL,0,0,1,-1,'',NULL,NULL,'',NULL,NULL),(25,NULL,1,'2011-08-01 02:31:24','2011-08-01 02:31:24',NULL,NULL,50,NULL,'Company mmm added into Dolibarr','2011-08-01 02:31:24','2011-08-01 00:31:24',1,NULL,NULL,15,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Company mmm added into Dolibarr\nAuthor: admin',15,'societe'),(26,NULL,1,'2011-08-01 02:31:43','2011-08-01 02:31:43',NULL,NULL,50,NULL,'Company ppp added into Dolibarr','2011-08-01 02:31:43','2011-08-01 00:31:43',1,NULL,NULL,16,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Company ppp added into Dolibarr\nAuthor: admin',16,'societe'),(27,NULL,1,'2011-08-01 02:41:26','2011-08-01 02:41:26',NULL,NULL,50,NULL,'Company aaa added into Dolibarr','2011-08-01 02:41:26','2011-08-01 00:41:26',1,NULL,NULL,17,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Company aaa added into Dolibarr\nAuthor: admin',17,'societe'),(28,NULL,1,'2011-08-01 03:34:11','2011-08-01 03:34:11',NULL,NULL,50,NULL,'Invoice FA1108-0003 validated in Dolibarr','2011-08-01 03:34:11','2011-08-01 01:34:11',1,NULL,NULL,7,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0003 validated in Dolibarr\nAuthor: admin',5,'invoice'),(29,NULL,1,'2011-08-01 03:34:11','2011-08-01 03:34:11',NULL,NULL,50,NULL,'Invoice FA1108-0003 validated in Dolibarr','2011-08-01 03:34:11','2011-08-01 01:34:11',1,NULL,NULL,7,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0003 changed to paid in Dolibarr\nAuthor: admin',5,'invoice'),(30,NULL,1,'2011-08-06 20:33:54','2011-08-06 20:33:54',NULL,NULL,50,NULL,'Invoice FA1108-0004 validated in Dolibarr','2011-08-06 20:33:54','2011-08-06 18:33:54',1,NULL,NULL,7,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0004 validated in Dolibarr\nAuthor: admin',6,'invoice'),(31,NULL,1,'2011-08-06 20:33:54','2011-08-06 20:33:54',NULL,NULL,50,NULL,'Invoice FA1108-0004 validated in Dolibarr','2011-08-06 20:33:54','2011-08-06 18:33:54',1,NULL,NULL,7,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0004 changed to paid in Dolibarr\nAuthor: admin',6,'invoice'),(38,NULL,1,'2011-08-08 02:41:55','2011-08-08 02:41:55',NULL,NULL,50,NULL,'Invoice FA1108-0005 validated in Dolibarr','2011-08-08 02:41:55','2011-08-08 00:41:55',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0005 validated in Dolibarr\nAuthor: admin',8,'invoice'),(40,NULL,1,'2011-08-08 02:53:40','2011-08-08 02:53:40',NULL,NULL,50,NULL,'Invoice FA1108-0005 changed to paid in Dolibarr','2011-08-08 02:53:40','2011-08-08 00:53:40',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0005 changed to paid in Dolibarr\nAuthor: admin',8,'invoice'),(41,NULL,1,'2011-08-08 02:54:05','2011-08-08 02:54:05',NULL,NULL,50,NULL,'Invoice FA1007-0002 changed to paid in Dolibarr','2011-08-08 02:54:05','2011-08-08 00:54:05',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1007-0002 changed to paid in Dolibarr\nAuthor: admin',2,'invoice'),(42,NULL,1,'2011-08-08 02:55:04','2011-08-08 02:55:04',NULL,NULL,50,NULL,'Invoice FA1107-0006 validated in Dolibarr','2011-08-08 02:55:04','2011-08-08 00:55:04',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1107-0006 validated in Dolibarr\nAuthor: admin',3,'invoice'),(43,NULL,1,'2011-08-08 02:55:26','2011-08-08 02:55:26',NULL,NULL,50,NULL,'Invoice FA1108-0007 validated in Dolibarr','2011-08-08 02:55:26','2011-08-08 00:55:26',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1108-0007 validated in Dolibarr\nAuthor: admin',9,'invoice'),(44,NULL,1,'2011-08-08 02:55:58','2011-08-08 02:55:58',NULL,NULL,50,NULL,'Invoice FA1107-0006 changed to paid in Dolibarr','2011-08-08 02:55:58','2011-08-08 00:55:58',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Invoice FA1107-0006 changed to paid in Dolibarr\nAuthor: admin',3,'invoice'),(45,NULL,1,'2011-08-08 03:04:22','2011-08-08 03:04:22',NULL,NULL,50,NULL,'Order CO1108-0001 validated','2011-08-08 03:04:22','2011-08-08 01:04:22',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Order CO1108-0001 validated\nAuthor: admin',5,'order'),(46,NULL,1,'2011-08-08 13:59:09','2011-08-08 13:59:09',NULL,NULL,50,NULL,'Order CO1107-0002 validated','2011-08-08 13:59:10','2011-08-08 11:59:10',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Order CO1107-0002 validated\nAuthor: admin',1,'order'),(47,NULL,1,'2011-08-08 14:24:18','2011-08-08 14:24:18',NULL,NULL,50,NULL,'Proposal PR1007-0001 validated','2011-08-08 14:24:18','2011-08-08 12:24:18',1,NULL,NULL,2,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Proposal PR1007-0001 validated\nAuthor: admin',1,'propal'),(48,NULL,1,'2011-08-08 14:24:24','2011-08-08 14:24:24',NULL,NULL,50,NULL,'Proposal PR1108-0004 validated','2011-08-08 14:24:24','2011-08-08 12:24:24',1,NULL,NULL,17,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Proposal PR1108-0004 validated\nAuthor: admin',4,'propal'),(49,NULL,1,'2011-08-08 15:04:37','2011-08-08 15:04:37',NULL,NULL,50,NULL,'Order CF1108-0003 validated','2011-08-08 15:04:37','2011-08-08 13:04:37',1,NULL,NULL,17,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Order CF1108-0003 validated\nAuthor: admin',6,'order_supplier'),(50,NULL,1,'2012-12-08 17:56:47','2012-12-08 17:56:47',NULL,NULL,40,NULL,'Facture AV1212-0001 validée dans Dolibarr','2012-12-08 17:56:47','2012-12-08 16:56:47',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture AV1212-0001 validée dans Dolibarr\nAuteur: admin',10,'invoice'),(51,NULL,1,'2012-12-08 17:57:11','2012-12-08 17:57:11',NULL,NULL,40,NULL,'Facture AV1212-0001 validée dans Dolibarr','2012-12-08 17:57:11','2012-12-08 16:57:11',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture AV1212-0001 validée dans Dolibarr\nAuteur: admin',10,'invoice'),(52,NULL,1,'2012-12-08 17:58:27','2012-12-08 17:58:27',NULL,NULL,40,NULL,'Facture FA1212-0008 validée dans Dolibarr','2012-12-08 17:58:27','2012-12-08 16:58:27',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1212-0008 validée dans Dolibarr\nAuteur: admin',11,'invoice'),(53,NULL,1,'2012-12-08 18:20:49','2012-12-08 18:20:49',NULL,NULL,40,NULL,'Facture AV1212-0002 validée dans Dolibarr','2012-12-08 18:20:49','2012-12-08 17:20:49',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture AV1212-0002 validée dans Dolibarr\nAuteur: admin',12,'invoice'),(54,NULL,1,'2012-12-09 18:35:07','2012-12-09 18:35:07',NULL,NULL,40,NULL,'Facture AV1212-0002 passée à payée dans Dolibarr','2012-12-09 18:35:07','2012-12-09 17:35:07',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture AV1212-0002 passée à payée dans Dolibarr\nAuteur: admin',12,'invoice'),(55,NULL,1,'2012-12-09 20:14:42','2012-12-09 20:14:42',NULL,NULL,40,NULL,'Société doe john ajoutée dans Dolibarr','2012-12-09 20:14:42','2012-12-09 19:14:42',1,NULL,NULL,18,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Société doe john ajoutée dans Dolibarr\nAuteur: admin',18,'societe'),(56,NULL,1,'2012-12-12 18:54:19','2012-12-12 18:54:19',NULL,NULL,40,NULL,'Facture FA1212-0009 validée dans Dolibarr','2012-12-12 18:54:19','2012-12-12 17:54:19',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1212-0009 validée dans Dolibarr\nAuteur: admin',55,'invoice'),(121,NULL,1,'2012-12-06 10:00:00',NULL,NULL,NULL,50,NULL,'aaab','2012-12-21 17:48:08','2012-12-21 16:54:07',3,1,NULL,NULL,NULL,0,3,NULL,NULL,1,0,1,-1,NULL,NULL,NULL,NULL,NULL,NULL),(122,NULL,1,'2012-12-21 18:09:52','2012-12-21 18:09:52',NULL,NULL,40,NULL,'Facture client FA1007-0001 envoyée par EMail','2012-12-21 18:09:52','2012-12-21 17:09:52',1,NULL,NULL,9,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Mail envoyé par Firstname SuperAdminName à laurent@mydomain.com.\nSujet du mail: Envoi facture FA1007-0001\nCorps du mail:\nVeuillez trouver ci-joint la facture FA1007-0001\r\n\r\nVous pouvez cliquer sur le lien sécurisé ci-dessous pour effectuer votre paiement via Paypal\r\n\r\nhttp://localhost/dolibarrnew/public/paypal/newpayment.php?source=invoice&ref=FA1007-0001&securekey=50c82fab36bb3b6aa83e2a50691803b2\r\n\r\nCordialement',1,'invoice'),(123,NULL,1,'2013-01-06 13:13:57','2013-01-06 13:13:57',NULL,NULL,40,NULL,'Facture 16 validée dans Dolibarr','2013-01-06 13:13:57','2013-01-06 12:13:57',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture 16 validée dans Dolibarr\nAuteur: admin',16,'invoice_supplier'),(124,NULL,1,'2013-01-12 12:23:05','2013-01-12 12:23:05',NULL,NULL,40,NULL,'Patient aaa ajouté','2013-01-12 12:23:05','2013-01-12 11:23:05',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Patient aaa ajouté\nAuteur: admin',19,'societe'),(125,NULL,1,'2013-01-12 12:52:20','2013-01-12 12:52:20',NULL,NULL,40,NULL,'Patient pppoo ajouté','2013-01-12 12:52:20','2013-01-12 11:52:20',1,NULL,NULL,20,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Patient pppoo ajouté\nAuteur: admin',20,'societe'),(127,NULL,1,'2013-01-19 18:22:48','2013-01-19 18:22:48',NULL,NULL,40,NULL,'Facture FS1301-0001 validée dans Dolibarr','2013-01-19 18:22:48','2013-01-19 17:22:48',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FS1301-0001 validée dans Dolibarr\nAuteur: admin',148,'invoice'),(128,NULL,1,'2013-01-19 18:31:10','2013-01-19 18:31:10',NULL,NULL,40,NULL,'Facture FA6801-0010 validée dans Dolibarr','2013-01-19 18:31:10','2013-01-19 17:31:10',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA6801-0010 validée dans Dolibarr\nAuteur: admin',150,'invoice'),(129,NULL,1,'2013-01-19 18:31:10','2013-01-19 18:31:10',NULL,NULL,40,NULL,'Facture FA6801-0010 passée à payée dans Dolibarr','2013-01-19 18:31:10','2013-01-19 17:31:10',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA6801-0010 passée à payée dans Dolibarr\nAuteur: admin',150,'invoice'),(130,NULL,1,'2013-01-19 18:31:58','2013-01-19 18:31:58',NULL,NULL,40,NULL,'Facture FS1301-0002 validée dans Dolibarr','2013-01-19 18:31:58','2013-01-19 17:31:58',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FS1301-0002 validée dans Dolibarr\nAuteur: admin',151,'invoice'),(131,NULL,1,'2013-01-19 18:31:58','2013-01-19 18:31:58',NULL,NULL,40,NULL,'Facture FS1301-0002 passée à payée dans Dolibarr','2013-01-19 18:31:58','2013-01-19 17:31:58',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FS1301-0002 passée à payée dans Dolibarr\nAuteur: admin',151,'invoice'),(132,NULL,1,'2013-01-23 15:07:54','2013-01-23 15:07:54',NULL,NULL,50,NULL,'Consultation 24 saisie (aaa)','2013-01-23 15:07:54','2013-01-23 14:07:54',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Consultation 24 saisie (aaa)\nAuteur: admin',24,'cabinetmed_cons'),(133,NULL,1,'2013-01-23 16:56:58','2013-01-23 16:56:58',NULL,NULL,40,NULL,'Patient pa ajouté','2013-01-23 16:56:58','2013-01-23 15:56:58',1,NULL,NULL,21,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Patient pa ajouté\nAuteur: admin',21,'societe'),(134,NULL,1,'2013-01-23 17:34:00',NULL,NULL,NULL,50,NULL,'bbcv','2013-01-23 17:35:21','2013-01-23 16:35:21',1,NULL,1,2,NULL,0,1,NULL,NULL,0,0,1,-1,'',NULL,NULL,'',NULL,NULL),(135,NULL,1,'2013-02-12 15:54:00','2013-02-12 15:54:00',NULL,NULL,40,NULL,'Facture FA1212-0011 validée dans Dolibarr','2013-02-12 15:54:37','2013-02-20 20:11:54',1,1,NULL,7,NULL,0,NULL,NULL,1,0,0,1,50,NULL,NULL,NULL,'Facture FA1212-0011 validée dans Dolibarr
\r\nAuteur: admin',13,'invoice'),(136,NULL,1,'2013-02-12 17:06:51','2013-02-12 17:06:51',NULL,NULL,40,NULL,'Commande CO1107-0003 validée','2013-02-12 17:06:51','2013-02-12 16:06:51',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Commande CO1107-0003 validée\nAuteur: admin',2,'order'),(137,NULL,1,'2013-02-17 16:22:10','2013-02-17 16:22:10',NULL,NULL,40,NULL,'Proposition PR1302-0009 validée','2013-02-17 16:22:10','2013-02-17 15:22:10',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Proposition PR1302-0009 validée\nAuteur: admin',9,'propal'),(138,NULL,1,'2013-02-17 16:27:00','2013-02-17 16:27:00',NULL,NULL,40,NULL,'Facture FA1302-0012 validée dans Dolibarr','2013-02-17 16:27:00','2013-02-17 15:27:00',1,NULL,NULL,18,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1302-0012 validée dans Dolibarr\nAuteur: admin',152,'invoice'),(139,NULL,1,'2013-02-17 16:27:29','2013-02-17 16:27:29',NULL,NULL,40,NULL,'Proposition PR1302-0010 validée','2013-02-17 16:27:29','2013-02-17 15:27:29',1,NULL,NULL,18,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Proposition PR1302-0010 validée\nAuteur: admin',11,'propal'),(140,NULL,1,'2013-02-17 18:27:56','2013-02-17 18:27:56',NULL,NULL,40,NULL,'Commande CO1107-0004 validée','2013-02-17 18:27:56','2013-02-17 17:27:56',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Commande CO1107-0004 validée\nAuteur: admin',3,'order'),(141,NULL,1,'2013-02-17 18:38:14','2013-02-17 18:38:14',NULL,NULL,40,NULL,'Commande CO1302-0005 validée','2013-02-17 18:38:14','2013-02-17 17:38:14',1,NULL,NULL,18,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Commande CO1302-0005 validée\nAuteur: admin',7,'order'),(142,NULL,1,'2013-02-26 22:57:50','2013-02-26 22:57:50',NULL,NULL,40,NULL,'Company pppp added into Dolibarr','2013-02-26 22:57:50','2013-02-26 21:57:50',1,NULL,NULL,22,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Company pppp added into Dolibarr\nAuthor: admin',22,'societe'),(143,NULL,1,'2013-02-26 22:58:13','2013-02-26 22:58:13',NULL,NULL,40,NULL,'Company ttttt added into Dolibarr','2013-02-26 22:58:13','2013-02-26 21:58:13',1,NULL,NULL,23,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Company ttttt added into Dolibarr\nAuthor: admin',23,'societe'),(144,NULL,1,'2013-02-27 10:00:00','2013-02-27 19:20:00',NULL,NULL,5,NULL,'Rendez-vous','2013-02-27 19:20:53','2013-02-27 18:20:53',1,NULL,NULL,NULL,NULL,0,1,NULL,1,0,0,1,-1,'',33600,NULL,'',NULL,NULL),(145,NULL,1,'2013-02-27 19:28:00',NULL,NULL,NULL,2,NULL,'fdsfsd','2013-02-27 19:28:48','2013-02-27 18:29:53',1,1,NULL,NULL,NULL,0,1,NULL,1,0,0,1,-1,NULL,NULL,NULL,NULL,NULL,NULL),(146,NULL,1,'2013-03-06 10:05:07','2013-03-06 10:05:07',NULL,NULL,40,NULL,'Contrat (PROV3) validé dans Dolibarr','2013-03-06 10:05:07','2013-03-06 09:05:07',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Contrat (PROV3) validé dans Dolibarr\nAuteur: admin',3,'contract'),(147,NULL,1,'2013-03-06 16:43:37','2013-03-06 16:43:37',NULL,NULL,40,NULL,'Facture FA1307-0013 validée dans Dolibarr','2013-03-06 16:43:37','2013-03-06 15:43:37',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1307-0013 validée dans Dolibarr\nAuteur: admin',158,'invoice'),(148,NULL,1,'2013-03-06 16:44:12','2013-03-06 16:44:12',NULL,NULL,40,NULL,'Facture FA1407-0014 validée dans Dolibarr','2013-03-06 16:44:12','2013-03-06 15:44:12',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1407-0014 validée dans Dolibarr\nAuteur: admin',159,'invoice'),(149,NULL,1,'2013-03-06 16:47:48','2013-03-06 16:47:48',NULL,NULL,40,NULL,'Facture FA1507-0015 validée dans Dolibarr','2013-03-06 16:47:48','2013-03-06 15:47:48',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1507-0015 validée dans Dolibarr\nAuteur: admin',160,'invoice'),(150,NULL,1,'2013-03-06 16:48:16','2013-03-06 16:48:16',NULL,NULL,40,NULL,'Facture FA1607-0016 validée dans Dolibarr','2013-03-06 16:48:16','2013-03-06 15:48:16',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1607-0016 validée dans Dolibarr\nAuteur: admin',161,'invoice'),(151,NULL,1,'2013-03-06 17:13:59','2013-03-06 17:13:59',NULL,NULL,40,NULL,'Société smith smith ajoutée dans Dolibarr','2013-03-06 17:13:59','2013-03-06 16:13:59',1,NULL,NULL,24,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Société smith smith ajoutée dans Dolibarr\nAuteur: admin',24,'societe'),(152,NULL,1,'2013-03-08 10:02:22','2013-03-08 10:02:22',NULL,NULL,40,NULL,'Proposition (PROV12) validée dans Dolibarr','2013-03-08 10:02:22','2013-03-08 09:02:22',1,NULL,NULL,23,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Proposition (PROV12) validée dans Dolibarr\nAuteur: admin',12,'propal'),(203,NULL,1,'2013-03-09 19:39:27','2013-03-09 19:39:27',NULL,NULL,40,'AC_ORDER_SUPPLIER_VALIDATE','Commande CF1303-0004 validée','2013-03-09 19:39:27','2013-03-09 18:39:27',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Commande CF1303-0004 validée\nAuteur: admin',13,'order_supplier'),(204,NULL,1,'2013-03-10 15:47:37','2013-03-10 15:47:37',NULL,NULL,40,'AC_COMPANY_CREATE','Patient créé','2013-03-10 15:47:37','2013-03-10 14:47:37',1,NULL,NULL,25,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Patient créé\nAuteur: admin',25,'societe'),(205,NULL,1,'2013-03-10 15:57:32','2013-03-10 15:57:32',NULL,NULL,40,'AC_COMPANY_CREATE','Tiers créé','2013-03-10 15:57:32','2013-03-10 14:57:32',1,NULL,NULL,26,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Tiers créé\nAuteur: admin',26,'societe'),(206,NULL,1,'2013-03-10 15:58:28','2013-03-10 15:58:28',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1303-0017 validée','2013-03-10 15:58:28','2013-03-10 14:58:28',1,NULL,NULL,26,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1303-0017 validée\nAuteur: admin',208,'invoice'),(207,NULL,1,'2013-03-19 09:38:10','2013-03-19 09:38:10',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1303-0018 validée','2013-03-19 09:38:10','2013-03-19 08:38:10',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1303-0018 validée\nAuteur: admin',209,'invoice'),(208,NULL,1,'2013-03-20 14:30:11','2013-03-20 14:30:11',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1107-0019 validée','2013-03-20 14:30:11','2013-03-20 13:30:11',1,NULL,NULL,10,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1107-0019 validée\nAuteur: admin',210,'invoice'),(209,NULL,1,'2013-03-22 09:40:25','2013-03-22 09:40:25',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1303-0020 validée','2013-03-22 09:40:25','2013-03-22 08:40:25',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1303-0020 validée\nAuteur: admin',211,'invoice'),(210,NULL,1,'2013-03-23 17:16:25','2013-03-23 17:16:25',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1303-0020 validée','2013-03-23 17:16:25','2013-03-23 16:16:25',1,NULL,NULL,19,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1303-0020 validée\nAuteur: admin',211,'invoice'),(211,NULL,1,'2013-03-23 18:08:27','2013-03-23 18:08:27',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1307-0013 validée','2013-03-23 18:08:27','2013-03-23 17:08:27',1,NULL,NULL,12,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1307-0013 validée\nAuteur: admin',158,'invoice'),(212,NULL,1,'2013-03-24 15:54:00','2013-03-24 15:54:00',NULL,NULL,40,'AC_BILL_VALIDATE','Facture FA1212-0021 validée','2013-03-24 15:54:00','2013-03-24 14:54:00',1,NULL,NULL,1,NULL,0,NULL,NULL,1,0,0,1,-1,'',NULL,NULL,'Facture FA1212-0021 validée\nAuteur: admin',32,'invoice'),(213,NULL,1,'2013-11-07 01:02:39','2013-11-07 01:02:39',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:02:39','2013-11-07 00:02:39',1,NULL,NULL,27,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',27,'societe'),(214,NULL,1,'2013-11-07 01:05:22','2013-11-07 01:05:22',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:05:22','2013-11-07 00:05:22',1,NULL,NULL,28,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',28,'societe'),(215,NULL,1,'2013-11-07 01:07:07','2013-11-07 01:07:07',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:07:07','2013-11-07 00:07:07',1,NULL,NULL,29,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',29,'societe'),(216,NULL,1,'2013-11-07 01:07:58','2013-11-07 01:07:58',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:07:58','2013-11-07 00:07:58',1,NULL,NULL,30,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',30,'societe'),(217,NULL,1,'2013-11-07 01:10:09','2013-11-07 01:10:09',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:10:09','2013-11-07 00:10:09',1,NULL,NULL,31,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',31,'societe'),(218,NULL,1,'2013-11-07 01:15:57','2013-11-07 01:15:57',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:15:57','2013-11-07 00:15:57',1,NULL,NULL,32,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',32,'societe'),(219,NULL,1,'2013-11-07 01:16:51','2013-11-07 01:16:51',NULL,NULL,40,'AC_COMPANY_CREATE','Third party created','2013-11-07 01:16:51','2013-11-07 00:16:51',1,NULL,NULL,33,NULL,0,NULL,0,1,0,0,1,-1,'',NULL,NULL,'Third party created\nAuthor: admin',33,'societe'); /*!40000 ALTER TABLE `llx_actioncomm` ENABLE KEYS */; UNLOCK TABLES; @@ -6805,7 +6805,7 @@ CREATE TABLE `llx_user` ( LOCK TABLES `llx_user` WRITE; /*!40000 ALTER TABLE `llx_user` DISABLE KEYS */; -INSERT INTO `llx_user` VALUES (1,'2010-07-08 13:20:11','2012-12-12 17:54:10','admin',0,NULL,NULL,NULL,'admin','21232f297a57a5a743894a0e4a801fc3',NULL,'SuperAdminName','Firstname','',NULL,'','','','bidon@destailleur.fr','',1,'','','',1,1,NULL,NULL,NULL,'','2014-04-05 16:19:30','2013-11-07 01:01:51',NULL,'',1,'01.jpg',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL),(2,'2010-07-08 13:54:48','2010-07-08 11:54:48','demo',1,NULL,NULL,NULL,'demo','fe01ce2a7fbac8fafaed7c982a04e229',NULL,'John','Doe',NULL,NULL,'09123123','','','johndoe@mycompany.com',NULL,0,'','','',1,1,NULL,NULL,NULL,'','2013-03-24 16:30:29','2010-07-08 14:12:02',NULL,'',1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL),(3,'2010-07-11 16:18:59','2013-02-20 19:07:21','adupont',1,NULL,NULL,NULL,'adupont','00856ab2bbb748aa29aa335a6e3a2407',NULL,'Dupont','Alain','',NULL,'','','','toto@aa.com','',0,'','','',1,1,NULL,NULL,2,'','2012-12-21 17:38:55',NULL,NULL,'',1,NULL,NULL,NULL,2,NULL,NULL,NULL,0,0,NULL,NULL),(4,'2013-01-23 17:52:27','2013-02-20 19:48:01','aaa',1,NULL,NULL,NULL,'aaa','47bce5c74f589f4867dbd57e9ca9f808',NULL,'aaa','','',NULL,'','','','','',0,'','','',1,1,17,6,NULL,'','2013-02-25 10:18:41','2013-01-23 17:53:20',NULL,'',1,NULL,NULL,NULL,5,NULL,NULL,NULL,0,0,NULL,NULL),(5,'2013-01-23 17:52:37','2013-01-23 16:52:37','bbb',0,NULL,NULL,NULL,'bbb','08f8e0260c64418510cefb2b06eee5cd',NULL,'bbb','','',NULL,'','','','','',1,'','','',1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL),(6,'2013-02-16 20:22:40','2013-02-16 19:22:40','aaab',2,NULL,NULL,NULL,'aaab','4c189b020ceb022e0ecc42482802e2b8',NULL,'aaab','','',NULL,'','','','','',0,'','','',1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL),(7,'2013-02-16 20:48:15','2013-02-16 19:48:15','zzz',2,NULL,NULL,NULL,'zzz','f3abb86bd34cf4d52698f14c0da1dc60',NULL,'zzz','','',NULL,'','','','','',0,'','','',1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL),(9,'2013-02-16 20:50:07','2013-03-24 16:10:14','zzzg',2,NULL,NULL,NULL,'jc28fg4h','93d789524fd223cf05eecea3f59cbe86',NULL,'zzzg','','',NULL,'','','','','fsdkkfsdf
\r\nfsdfsd
\r\nfsdfs',0,'','','',1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,NULL,NULL,NULL,5,'','','',NULL,NULL,NULL,NULL); +INSERT INTO `llx_user` VALUES (1,'2010-07-08 13:20:11','2012-12-12 17:54:10','admin',0,NULL,NULL,NULL,'admin','21232f297a57a5a743894a0e4a801fc3',NULL,'SuperAdminName','Firstname','',NULL,'','','','bidon@mydomain.com','',1,'','','',1,1,NULL,NULL,NULL,'','2014-04-05 16:19:30','2013-11-07 01:01:51',NULL,'',1,'01.jpg',NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL),(2,'2010-07-08 13:54:48','2010-07-08 11:54:48','demo',1,NULL,NULL,NULL,'demo','fe01ce2a7fbac8fafaed7c982a04e229',NULL,'John','Doe',NULL,NULL,'09123123','','','johndoe@mycompany.com',NULL,0,'','','',1,1,NULL,NULL,NULL,'','2013-03-24 16:30:29','2010-07-08 14:12:02',NULL,'',1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL),(3,'2010-07-11 16:18:59','2013-02-20 19:07:21','adupont',1,NULL,NULL,NULL,'adupont','00856ab2bbb748aa29aa335a6e3a2407',NULL,'Dupont','Alain','',NULL,'','','','toto@aa.com','',0,'','','',1,1,NULL,NULL,2,'','2012-12-21 17:38:55',NULL,NULL,'',1,NULL,NULL,NULL,2,NULL,NULL,NULL,0,0,NULL,NULL),(4,'2013-01-23 17:52:27','2013-02-20 19:48:01','aaa',1,NULL,NULL,NULL,'aaa','47bce5c74f589f4867dbd57e9ca9f808',NULL,'aaa','','',NULL,'','','','','',0,'','','',1,1,17,6,NULL,'','2013-02-25 10:18:41','2013-01-23 17:53:20',NULL,'',1,NULL,NULL,NULL,5,NULL,NULL,NULL,0,0,NULL,NULL),(5,'2013-01-23 17:52:37','2013-01-23 16:52:37','bbb',0,NULL,NULL,NULL,'bbb','08f8e0260c64418510cefb2b06eee5cd',NULL,'bbb','','',NULL,'','','','','',1,'','','',1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL),(6,'2013-02-16 20:22:40','2013-02-16 19:22:40','aaab',2,NULL,NULL,NULL,'aaab','4c189b020ceb022e0ecc42482802e2b8',NULL,'aaab','','',NULL,'','','','','',0,'','','',1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL),(7,'2013-02-16 20:48:15','2013-02-16 19:48:15','zzz',2,NULL,NULL,NULL,'zzz','f3abb86bd34cf4d52698f14c0da1dc60',NULL,'zzz','','',NULL,'','','','','',0,'','','',1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,NULL,NULL),(9,'2013-02-16 20:50:07','2013-03-24 16:10:14','zzzg',2,NULL,NULL,NULL,'jc28fg4h','93d789524fd223cf05eecea3f59cbe86',NULL,'zzzg','','',NULL,'','','','','fsdkkfsdf
\r\nfsdfsd
\r\nfsdfs',0,'','','',1,1,NULL,NULL,NULL,'',NULL,NULL,NULL,'',1,NULL,NULL,NULL,5,'','','',NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `llx_user` ENABLE KEYS */; UNLOCK TABLES; diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 03104270dcf..bf283993628 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -17,6 +17,7 @@ */nltechno* */htdocs/includes */htdocs/includes + .git diff --git a/doc/install/README-DE b/doc/install/README-DE index c7ece3891f3..047e1915d18 100644 --- a/doc/install/README-DE +++ b/doc/install/README-DE @@ -1,33 +1,45 @@ README (deutsch / german / allemand) --------------------------------- +------------------------------------ --------------------------------- +------------------------------------ Download / Herunterladen --------------------------------- +------------------------------------ * Dolibarr ERP/CRM kann man über die offizielle Dolibarr Website + https://www.dolibarr.org/downloads - oder direkt von Sourceforge + + oder direkt bei Sourceforge + https://sourceforge.net/projects/dolibarr/files/ + herunterladen. - - -* Die meisten externen Module/Themens sind über den DoliStore verfügbar: - https://www.dolistore.com/de/ --------------------------------- -Installation --------------------------------- -* Für eine kurze Einleitung, schau auf die README Datei im Hauptverzeichnis. +------------------------------------ +Installation / Hilfe +------------------------------------ + +* Für eine kurze Einleitung schau in die README Datei im Hauptverzeichnis. * Umfangreiche Dokumentationen sind im Dolibarr Wiki zu finden: https://wiki.dolibarr.org/index.php/Hauptseite * eine Deutsche Community bietet der Dolibarr e.V. unter https://www.dolibarr.de/ + + + + +------------------------------------ +Zusatzmodule +------------------------------------ + +* Die meisten externen Module/Themen sind über den offiziellen DoliStore verfügbar: + + https://www.dolistore.com/de/ - + diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 88282447c51..47a984cd467 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -65,12 +65,12 @@ if (!$sortfield) $sortfield = "aa.account_number"; if (!$sortorder) $sortorder = "ASC"; $arrayfields = array( - 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), - 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), + 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), - 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), - 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), + 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), + 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) ); @@ -93,24 +93,24 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if (!empty($cancel)) $action = ''; + if (!empty($cancel)) $action = ''; - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { - $search_account = ""; - $search_label = ""; + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $search_account = ""; + $search_label = ""; $search_labelshort = ""; $search_accountparent = ""; - $search_pcgtype = ""; + $search_pcgtype = ""; $search_array_options = array(); - } - if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on - || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified - { - if ($chartofaccounts > 0) - { + } + if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on + || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified + { + if ($chartofaccounts > 0) + { // Get language code for this $chartofaccounts $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; @@ -147,34 +147,34 @@ if (empty($reshook)) } } - if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } else { - $error++; - } - } + if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + $error++; + } + } - if ($action == 'disable') { - if ($accounting->fetch($id)) { - $mode = GETPOST('mode', 'int'); - $result = $accounting->accountDeactivate($id, $mode); - } + if ($action == 'disable') { + if ($accounting->fetch($id)) { + $mode = GETPOST('mode', 'int'); + $result = $accounting->accountDeactivate($id, $mode); + } - $action = 'update'; - if ($result < 0) { - setEventMessages($accounting->error, $accounting->errors, 'errors'); - } - } elseif ($action == 'enable') { - if ($accounting->fetch($id)) { - $mode = GETPOST('mode', 'int'); - $result = $accounting->account_activate($id, $mode); - } - $action = 'update'; - if ($result < 0) { - setEventMessages($accounting->error, $accounting->errors, 'errors'); - } - } + $action = 'update'; + if ($result < 0) { + setEventMessages($accounting->error, $accounting->errors, 'errors'); + } + } elseif ($action == 'enable') { + if ($accounting->fetch($id)) { + $mode = GETPOST('mode', 'int'); + $result = $accounting->account_activate($id, $mode); + } + $action = 'update'; + if ($result < 0) { + setEventMessages($accounting->error, $accounting->errors, 'errors'); + } + } } @@ -273,9 +273,9 @@ if ($resql) if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if (!empty($conf->use_javascript_ajax)) - { - print ' + if (!empty($conf->use_javascript_ajax)) + { + print ' '; - } + } print '
'; if ($optioncss != '') print ''; @@ -296,48 +296,48 @@ if ($resql) print ''; print ''; - $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); - print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); + print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); // Box to select active chart of account - print $langs->trans("Selectchartofaccounts")." : "; - print ''; + $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1"; + $sql .= " WHERE a.active = 1"; + dol_syslog('accountancy/admin/account.php $sql='.$sql); + print $sql; + $resqlchart = $db->query($sql); + if ($resqlchart) { + $numbis = $db->num_rows($resqlchart); + $i = 0; + while ($i < $numbis) { + $obj = $db->fetch_object($resqlchart); - print ''; + print ''; - $i++; - } - } else dol_print_error($db); - print ""; - print ajax_combobox("chartofaccounts"); - print ''; + $i++; + } + } else dol_print_error($db); + print ""; + print ajax_combobox("chartofaccounts"); + print ''; - print '
'; + print '
'; print '
'; $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); // This also change content of $arrayfields - $moreforfilter = ''; - $massactionbutton = ''; + $moreforfilter = ''; + $massactionbutton = ''; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; // Line for search fields print ''; @@ -358,7 +358,7 @@ if ($resql) print ''; print ''; - print ''; + print ''; if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); @@ -422,7 +422,7 @@ if ($resql) print ''; $accountparent->id = $obj->rowid2; $accountparent->label = $obj->label2; - $accountparent->account_number = $obj->account_number2; // Sotre an account number for output + $accountparent->account_number = $obj->account_number2; // Sotre an account number for output print $accountparent->getNomUrl(1); print "\n"; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index d3bd17d95a5..acec1468d79 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -472,13 +472,13 @@ if ($id) if ($valuetoshow != '') { print ''; } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 29ed90bb7be..b4f90f19675 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -108,16 +108,16 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) setEventMessages($object->error, $object->errors, 'errors'); } elseif ($res < 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = "create"; + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; } if (!$error) { - setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); - $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); - header("Location: ".$urltogo); - exit; + setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); + header("Location: ".$urltogo); + exit; } } } elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) { @@ -158,15 +158,15 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $result = $object->update($user); if ($result > 0) { - $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); - header("Location: ".$urltogo); + $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); + header("Location: ".$urltogo); exit(); } else { $mesg = $object->error; } } else { - $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); - header("Location: ".$urltogo); + $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); + header("Location: ".$urltogo); exit(); } } elseif ($action == 'delete' && $user->rights->accounting->chartofaccount) { @@ -210,7 +210,7 @@ if ($action == 'create') { print ''; print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print '
'; - if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { - print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - } elseif (!empty($tabhelp[$id][$value])) { - print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); - } else { - print $valuetoshow; - } + if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { + print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + } elseif (!empty($tabhelp[$id][$value])) { + print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + } else { + print $valuetoshow; + } print '
'; @@ -252,7 +252,7 @@ if ($action == 'create') { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -272,7 +272,7 @@ if ($action == 'create') { // Edit mode if ($action == 'update') { - dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); + print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); print ''."\n"; print ''; @@ -314,7 +314,7 @@ if ($action == 'create') { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -327,7 +327,7 @@ if ($action == 'create') { // View mode $linkback = ''.$langs->trans("BackToList").''; - dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr'); + print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr'); dol_banner_tab($object, 'ref', $linkback, 1, 'account_number', 'ref'); @@ -364,7 +364,7 @@ if ($action == 'create') { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Actions buttons diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index f68fbc18905..eefe62a47a4 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -102,7 +102,7 @@ print ''."\n"; print ''; print ''; -dol_fiche_head(); +print dol_get_fiche_head(); print ''; @@ -146,7 +146,7 @@ if (!empty($cat_id)) print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 9469a1e64f1..c9adac2f5a3 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -135,249 +135,249 @@ $sourceList = array(); if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) { - $search_country_id = ''; + $search_country_id = ''; } // Actions add or modify an entry into a dictionary if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { - $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); - $listfieldinsert = explode(',', $tabfieldinsert[$id]); - $listfieldmodify = explode(',', $tabfieldinsert[$id]); - $listfieldvalue = explode(',', $tabfieldvalue[$id]); + $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); + $listfieldinsert = explode(',', $tabfieldinsert[$id]); + $listfieldmodify = explode(',', $tabfieldinsert[$id]); + $listfieldvalue = explode(',', $tabfieldvalue[$id]); - // Check that all fields are filled - $ok = 1; - foreach ($listfield as $f => $value) - { + // Check that all fields are filled + $ok = 1; + foreach ($listfield as $f => $value) + { if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'range_account' && empty($_POST['range_account'])) continue; if ($value == 'country' || $value == 'country_id') continue; if (!GETPOSTISSET($value) || GETPOST($value) == '') - { - $ok = 0; - $fieldnamekey = $listfield[$f]; - // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; - if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; - if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; - if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; - if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; + { + $ok = 0; + $fieldnamekey = $listfield[$f]; + // We take translate key of field + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; + if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; + if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; + if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; + if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated'; - setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); - } - } - if (isset($_POST["code"])) - { - if ($_POST["code"] == '0') - { - $ok = 0; - setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); - } - } - if (!is_numeric(GETPOST('position', 'alpha'))) - { - $langs->loadLangs(array("errors")); + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); + } + } + if (isset($_POST["code"])) + { + if ($_POST["code"] == '0') + { + $ok = 0; + setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); + } + } + if (!is_numeric(GETPOST('position', 'alpha'))) + { + $langs->loadLangs(array("errors")); $ok = 0; setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors'); - } + } // Clean some parameters if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null - // Si verif ok et action add, on ajoute la ligne - if ($ok && GETPOST('actionadd', 'alpha')) - { - if ($tabrowid[$id]) - { - // Recupere id libre pour insertion - $newid = 0; - $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; - $result = $db->query($sql); - if ($result) - { - $obj = $db->fetch_object($result); - $newid = ($obj->newid + 1); - } else { - dol_print_error($db); - } - } + // Si verif ok et action add, on ajoute la ligne + if ($ok && GETPOST('actionadd', 'alpha')) + { + if ($tabrowid[$id]) + { + // Recupere id libre pour insertion + $newid = 0; + $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; + $result = $db->query($sql); + if ($result) + { + $obj = $db->fetch_object($result); + $newid = ($obj->newid + 1); + } else { + dol_print_error($db); + } + } - // Add new entry - $sql = "INSERT INTO ".$tabname[$id]." ("; - // List of fields - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $tabrowid[$id].","; - $sql .= $tabfieldinsert[$id]; - $sql .= ",active)"; - $sql .= " VALUES("; + // Add new entry + $sql = "INSERT INTO ".$tabname[$id]." ("; + // List of fields + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $tabrowid[$id].","; + $sql .= $tabfieldinsert[$id]; + $sql .= ",active)"; + $sql .= " VALUES("; - // List of values - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.","; - $i = 0; - foreach ($listfieldinsert as $f => $value) - { - if ($value == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; - } - if ($i) $sql .= ","; - if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') $sql .= "null"; // For vat, we want/accept code = '' - else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; - $i++; - } - $sql .= ",1)"; + // List of values + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.","; + $i = 0; + foreach ($listfieldinsert as $f => $value) + { + if ($value == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql .= ","; + if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') $sql .= "null"; // For vat, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; + } + $sql .= ",1)"; - dol_syslog("actionadd", LOG_DEBUG); - $result = $db->query($sql); - if ($result) // Add is ok - { - setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST = array('id'=>$id); // Clean $_POST array, we keep only - } else { - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); - } else { - dol_print_error($db); - } - } - } + dol_syslog("actionadd", LOG_DEBUG); + $result = $db->query($sql); + if ($result) // Add is ok + { + setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); + $_POST = array('id'=>$id); // Clean $_POST array, we keep only + } else { + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); + } else { + dol_print_error($db); + } + } + } - // Si verif ok et action modify, on modifie la ligne - if ($ok && GETPOST('actionmodify', 'alpha')) - { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + // Si verif ok et action modify, on modifie la ligne + if ($ok && GETPOST('actionmodify', 'alpha')) + { + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - // Modify entry - $sql = "UPDATE ".$tabname[$id]." SET "; - // Modifie valeur des champs - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) - { - $sql .= $tabrowid[$id]."="; - $sql .= "'".$db->escape($rowid)."', "; - } - $i = 0; - foreach ($listfieldmodify as $field) - { - if ($field == 'fk_country' && $_POST['country'] > 0) { - $_POST[$listfieldvalue[$i]] = $_POST['country']; - } elseif ($field == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; - } - if ($i) $sql .= ","; - $sql .= $field."="; - if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') $sql .= "null"; // For range_account, we want/accept code = '' - else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; - $i++; - } - $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); + // Modify entry + $sql = "UPDATE ".$tabname[$id]." SET "; + // Modifie valeur des champs + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) + { + $sql .= $tabrowid[$id]."="; + $sql .= "'".$db->escape($rowid)."', "; + } + $i = 0; + foreach ($listfieldmodify as $field) + { + if ($field == 'fk_country' && $_POST['country'] > 0) { + $_POST[$listfieldvalue[$i]] = $_POST['country']; + } elseif ($field == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql .= ","; + $sql .= $field."="; + if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') $sql .= "null"; // For range_account, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; + } + $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); - dol_syslog("actionmodify", LOG_DEBUG); - //print $sql; - $resql = $db->query($sql); - if (!$resql) - { - setEventMessages($db->error(), null, 'errors'); - } - } - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition + dol_syslog("actionmodify", LOG_DEBUG); + //print $sql; + $resql = $db->query($sql); + if (!$resql) + { + setEventMessages($db->error(), null, 'errors'); + } + } + //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } if (GETPOST('actioncancel', 'alpha')) { - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition + //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } if ($action == 'confirm_delete' && $confirm == 'yes') // delete { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid); + $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid); - dol_syslog("delete", LOG_DEBUG); - $result = $db->query($sql); - if (!$result) - { - if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') - { - setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); - } else { - dol_print_error($db); - } - } + dol_syslog("delete", LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') + { + setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); + } else { + dol_print_error($db); + } + } } // activate if ($action == $acts[0]) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } // disable if ($action == $acts[1]) { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } // favorite if ($action == 'activate_favorite') { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } // disable favorite if ($action == 'disable_favorite') { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } - if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } @@ -401,7 +401,7 @@ print ''.$langs->trans("AccountingAccountGroupsDesc" // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } //var_dump($elementList); @@ -410,407 +410,407 @@ if ($action == 'delete') */ if ($id) { - // Complete requete recherche valeurs avec critere de tri - $sql = $tabsql[$id]; + // Complete requete recherche valeurs avec critere de tri + $sql = $tabsql[$id]; - if ($search_country_id > 0) - { - if (preg_match('/ WHERE /', $sql)) $sql .= " AND "; - else $sql .= " WHERE "; - $sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)"; - } + if ($search_country_id > 0) + { + if (preg_match('/ WHERE /', $sql)) $sql .= " AND "; + else $sql .= " WHERE "; + $sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)"; + } - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield = 'country_code'; - $sql .= $db->order($sortfield, $sortorder); - $sql .= $db->plimit($listlimit + 1, $offset); - //print $sql; + // If sort order is "country", we use country_code instead + if ($sortfield == 'country') $sortfield = 'country_code'; + $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($listlimit + 1, $offset); + //print $sql; - $fieldlist = explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; print '
'; - print ''; + print '
'; - // Form to add a new line - if ($tabname[$id]) - { - $alabelisused = 0; + // Form to add a new line + if ($tabname[$id]) + { + $alabelisused = 0; - $fieldlist = explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); - // Line for title - print ''; - foreach ($fieldlist as $field => $value) - { - // Determine le nom du champ par rapport aux noms possibles - // dans les dictionnaires de donnees - $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut - $valuetoshow = $langs->trans($valuetoshow); // try to translate - $class = "left"; - if ($fieldlist[$field] == 'type') { - if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") { - $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); - } else { - $valuetoshow = $langs->trans("Type"); - } - } - if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { - $valuetoshow = $langs->trans("Label"); - } - if ($fieldlist[$field] == 'libelle_facture') { - $valuetoshow = $langs->trans("LabelOnDocuments"); - } - if ($fieldlist[$field] == 'country') { - $valuetoshow = $langs->trans("Country"); - } - if ($fieldlist[$field] == 'accountancy_code') { - $valuetoshow = $langs->trans("AccountancyCode"); - } - if ($fieldlist[$field] == 'accountancy_code_sell') { - $valuetoshow = $langs->trans("AccountancyCodeSell"); - } - if ($fieldlist[$field] == 'accountancy_code_buy') { - $valuetoshow = $langs->trans("AccountancyCodeBuy"); - } - if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { - $valuetoshow = $langs->trans("Pcg_version"); - } - if ($fieldlist[$field] == 'range_account') { - $valuetoshow = $langs->trans("Comment"); - } - if ($fieldlist[$field] == 'category_type') { - $valuetoshow = $langs->trans("Calculated"); - } - - if ($valuetoshow != '') { - print ''; - } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Line to enter new values - print ''; - - $obj = new stdClass(); - // If data was already input, we define them in obj to populate input fields. - if (GETPOST('actionadd', 'alpha')) - { - foreach ($fieldlist as $key=>$val) - { - if (GETPOST($val) != '') - $obj->$val = GETPOST($val); - } - } - - $tmpaction = 'create'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; - - if (empty($reshook)) - { - fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'add'); - } - - print ''; - print ""; - - $colspan = count($fieldlist) + 3; - if ($id == 32) $colspan++; - - print ''; // Keep   to have a line with enough height - } - - // List of available record in database - dol_syslog("htdocs/admin/dict", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - $param = '&id='.$id; - if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id; - $paramwithsearch = $param; - if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder; - if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield; - if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); - // There is several pages - if ($num > $listlimit) - { - print ''; - } - - // Title line with search boxes - print ''; - $filterfound = 0; - foreach ($fieldlist as $field => $value) - { - $showfield = 1; // By defaut - - if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } - - if ($showfield) - { - if ($value == 'country') - { - print ''; - $filterfound++; - } else { - print ''; - } - } - } - print ''; - print ''; - print ''; - print ''; - print ''; - - // Title of lines - print ''; - foreach ($fieldlist as $field => $value) - { - // Determine le nom du champ par rapport aux noms possibles - // dans les dictionnaires de donnees - $showfield = 1; // By defaut - $class = "left"; - $sortable = 1; - $valuetoshow = ''; - - $valuetoshow = ucfirst($fieldlist[$field]); // By defaut - $valuetoshow = $langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field] == 'source') { - $valuetoshow = $langs->trans("Contact"); - } - if ($fieldlist[$field] == 'price') { - $valuetoshow = $langs->trans("PriceUHT"); - } - if ($fieldlist[$field] == 'taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") { - $valuetoshow = $langs->trans("Rate"); - } else { - $valuetoshow = $langs->trans("Amount"); - } - $class = 'center'; - } - if ($fieldlist[$field] == 'type') { - $valuetoshow = $langs->trans("Type"); - } - if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { - $valuetoshow = $langs->trans("Label"); - } - if ($fieldlist[$field] == 'country') { - $valuetoshow = $langs->trans("Country"); - } - if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { - $showfield = 0; - } - if ($fieldlist[$field] == 'accountancy_code') { - $valuetoshow = $langs->trans("AccountancyCode"); - } - if ($fieldlist[$field] == 'accountancy_code_sell') { - $valuetoshow = $langs->trans("AccountancyCodeSell"); - $sortable = 0; - } - if ($fieldlist[$field] == 'accountancy_code_buy') { - $valuetoshow = $langs->trans("AccountancyCodeBuy"); - $sortable = 0; - } - if ($fieldlist[$field] == 'fk_pcg_version') { - $valuetoshow = $langs->trans("Pcg_version"); - } - if ($fieldlist[$field] == 'account_parent') { - $valuetoshow = $langs->trans("Accountsparent"); - } - if ($fieldlist[$field] == 'pcg_type') { - $valuetoshow = $langs->trans("Pcg_type"); - } - if ($fieldlist[$field] == 'type_template') { - $valuetoshow = $langs->trans("TypeOfTemplate"); - } + // Line for title + print ''; + foreach ($fieldlist as $field => $value) + { + // Determine le nom du champ par rapport aux noms possibles + // dans les dictionnaires de donnees + $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + $class = "left"; + if ($fieldlist[$field] == 'type') { + if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") { + $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); + } else { + $valuetoshow = $langs->trans("Type"); + } + } + if ($fieldlist[$field] == 'code') { + $valuetoshow = $langs->trans("Code"); + } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { + $valuetoshow = $langs->trans("Label"); + } + if ($fieldlist[$field] == 'libelle_facture') { + $valuetoshow = $langs->trans("LabelOnDocuments"); + } + if ($fieldlist[$field] == 'country') { + $valuetoshow = $langs->trans("Country"); + } + if ($fieldlist[$field] == 'accountancy_code') { + $valuetoshow = $langs->trans("AccountancyCode"); + } + if ($fieldlist[$field] == 'accountancy_code_sell') { + $valuetoshow = $langs->trans("AccountancyCodeSell"); + } + if ($fieldlist[$field] == 'accountancy_code_buy') { + $valuetoshow = $langs->trans("AccountancyCodeBuy"); + } + if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { + $valuetoshow = $langs->trans("Pcg_version"); + } if ($fieldlist[$field] == 'range_account') { - $valuetoshow = $langs->trans("Comment"); - } + $valuetoshow = $langs->trans("Comment"); + } if ($fieldlist[$field] == 'category_type') { - $valuetoshow = $langs->trans("Calculated"); - } - // Affiche nom du champ - if ($showfield) { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' '); - } - } + $valuetoshow = $langs->trans("Calculated"); + } + + if ($valuetoshow != '') { + print ''; + } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + + // Line to enter new values + print ''; + + $obj = new stdClass(); + // If data was already input, we define them in obj to populate input fields. + if (GETPOST('actionadd', 'alpha')) + { + foreach ($fieldlist as $key=>$val) + { + if (GETPOST($val) != '') + $obj->$val = GETPOST($val); + } + } + + $tmpaction = 'create'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; + + if (empty($reshook)) + { + fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'add'); + } + + print ''; + print ""; + + $colspan = count($fieldlist) + 3; + if ($id == 32) $colspan++; + + print ''; // Keep   to have a line with enough height + } + + // List of available record in database + dol_syslog("htdocs/admin/dict", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + $param = '&id='.$id; + if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id; + $paramwithsearch = $param; + if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder; + if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield; + if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); + // There is several pages + if ($num > $listlimit) + { + print ''; + } + + // Title line with search boxes + print ''; + $filterfound = 0; + foreach ($fieldlist as $field => $value) + { + $showfield = 1; // By defaut + + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } + + if ($showfield) + { + if ($value == 'country') + { + print ''; + $filterfound++; + } else { + print ''; + } + } + } + print ''; + print ''; + print ''; + print ''; + print ''; + + // Title of lines + print ''; + foreach ($fieldlist as $field => $value) + { + // Determine le nom du champ par rapport aux noms possibles + // dans les dictionnaires de donnees + $showfield = 1; // By defaut + $class = "left"; + $sortable = 1; + $valuetoshow = ''; + + $valuetoshow = ucfirst($fieldlist[$field]); // By defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + if ($fieldlist[$field] == 'source') { + $valuetoshow = $langs->trans("Contact"); + } + if ($fieldlist[$field] == 'price') { + $valuetoshow = $langs->trans("PriceUHT"); + } + if ($fieldlist[$field] == 'taux') { + if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") { + $valuetoshow = $langs->trans("Rate"); + } else { + $valuetoshow = $langs->trans("Amount"); + } + $class = 'center'; + } + if ($fieldlist[$field] == 'type') { + $valuetoshow = $langs->trans("Type"); + } + if ($fieldlist[$field] == 'code') { + $valuetoshow = $langs->trans("Code"); + } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { + $valuetoshow = $langs->trans("Label"); + } + if ($fieldlist[$field] == 'country') { + $valuetoshow = $langs->trans("Country"); + } + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { + $showfield = 0; + } + if ($fieldlist[$field] == 'accountancy_code') { + $valuetoshow = $langs->trans("AccountancyCode"); + } + if ($fieldlist[$field] == 'accountancy_code_sell') { + $valuetoshow = $langs->trans("AccountancyCodeSell"); + $sortable = 0; + } + if ($fieldlist[$field] == 'accountancy_code_buy') { + $valuetoshow = $langs->trans("AccountancyCodeBuy"); + $sortable = 0; + } + if ($fieldlist[$field] == 'fk_pcg_version') { + $valuetoshow = $langs->trans("Pcg_version"); + } + if ($fieldlist[$field] == 'account_parent') { + $valuetoshow = $langs->trans("Accountsparent"); + } + if ($fieldlist[$field] == 'pcg_type') { + $valuetoshow = $langs->trans("Pcg_type"); + } + if ($fieldlist[$field] == 'type_template') { + $valuetoshow = $langs->trans("TypeOfTemplate"); + } + if ($fieldlist[$field] == 'range_account') { + $valuetoshow = $langs->trans("Comment"); + } + if ($fieldlist[$field] == 'category_type') { + $valuetoshow = $langs->trans("Calculated"); + } + // Affiche nom du champ + if ($showfield) { + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' '); + } + } print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center '); - print getTitleFieldOfList(''); - print getTitleFieldOfList(''); - print getTitleFieldOfList(''); - print ''; + print getTitleFieldOfList(''); + print getTitleFieldOfList(''); + print getTitleFieldOfList(''); + print ''; - if ($num) - { - // Lines with values - while ($i < $num) - { - $obj = $db->fetch_object($resql); - //print_r($obj); - print ''; - if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) - { - $tmpaction = 'edit'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; + if ($num) + { + // Lines with values + while ($i < $num) + { + $obj = $db->fetch_object($resql); + //print_r($obj); + print ''; + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) + { + $tmpaction = 'edit'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; - // Show fields - if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit'); + // Show fields + if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit'); - print ''; - print ''; - print ''; - print ''; - } else { - $tmpaction = 'view'; - $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + print ''; + print ''; + print ''; + print ''; + } else { + $tmpaction = 'view'; + $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; + $error = $hookmanager->error; $errors = $hookmanager->errors; - if (empty($reshook)) - { - foreach ($fieldlist as $field => $value) - { - $showfield = 1; - $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; - if ($value == 'category_type') - { - $valuetoshow = yn($valuetoshow); - } elseif ($valuetoshow == 'all') { - $valuetoshow = $langs->trans('All'); - } elseif ($fieldlist[$field] == 'country') { - if (empty($obj->country_code)) - { - $valuetoshow = '-'; - } else { - $key = $langs->trans("Country".strtoupper($obj->country_code)); - $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); - } - } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') { - $key = $langs->trans("Country".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); - } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') { - $langs->loadLangs(array("propal")); - $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); - } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') { - $key = $langs->trans("Action".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); - } elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { - $showfield = 0; - } + if (empty($reshook)) + { + foreach ($fieldlist as $field => $value) + { + $showfield = 1; + $class = "left"; + $valuetoshow = $obj->{$fieldlist[$field]}; + if ($value == 'category_type') + { + $valuetoshow = yn($valuetoshow); + } elseif ($valuetoshow == 'all') { + $valuetoshow = $langs->trans('All'); + } elseif ($fieldlist[$field] == 'country') { + if (empty($obj->country_code)) + { + $valuetoshow = '-'; + } else { + $key = $langs->trans("Country".strtoupper($obj->country_code)); + $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); + } + } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') { + $key = $langs->trans("Country".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); + } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') { + $langs->loadLangs(array("propal")); + $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); + } elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') { + $key = $langs->trans("Action".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); + } elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { + $showfield = 0; + } - $class = 'tddict'; + $class = 'tddict'; // Show value for field if ($showfield) print ''; - } - } + } + } - // Can an entry be erased or disabled ? - $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default - if (isset($obj->code)) - { - if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; } - } + // Can an entry be erased or disabled ? + $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default + if (isset($obj->code)) + { + if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; } + } - $canbemodified = $iserasable; + $canbemodified = $iserasable; - $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); - if ($param) $url .= '&'.$param; - $url .= '&'; + $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); + if ($param) $url .= '&'.$param; + $url .= '&'; - // Active - print '"; + // Active + print '"; - // Modify link - if ($canbemodified) print ''; - else print ''; + // Modify link + if ($canbemodified) print ''; + else print ''; - // Delete link - if ($iserasable) - { - print ''; - } else print ''; + // Delete link + if ($iserasable) + { + print ''; + } else print ''; - // Link to setup the group - print ''; - } - print "\n"; - $i++; - } - } - } else { - dol_print_error($db); - } + // Link to setup the group + print ''; + } + print "\n"; + $i++; + } + } + } else { + dol_print_error($db); + } - print '
'; - if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); - else print $valuetoshow; - print ''; - print ''; - print '
'; - print ''; - print '
 
'; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); - print '
'; - print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); - print ''; - if ($filterfound) - { - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - } - print '
'; + if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + else print $valuetoshow; + print ''; + print ''; + print '
'; + print ''; + print '
 
'; + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print '
'; + print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); + print ''; + if ($filterfound) + { + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + } + print '
'; - print ''; - print ''; - print ''; - print '
'; - print ''; - print '
'; + print ''; + print ''; + print ''; + print '
'; + print ''; + print '
'.$valuetoshow.''; - if ($canbedisabled) print ''.$actl[$obj->active].''; - else { - print $langs->trans("AlwaysActive"); - } - print "'; + if ($canbedisabled) print ''.$actl[$obj->active].''; + else { + print $langs->trans("AlwaysActive"); + } + print "'.img_edit().' '.img_edit().' '; - if ($user->admin) print ''.img_delete().''; - //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin - print ' '; + if ($user->admin) print ''.img_delete().''; + //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin + print ' '; - if (empty($obj->formula)) - { - print ''; - print $langs->trans("ListOfAccounts"); - print ''; - } - print '
'; + if (empty($obj->formula)) + { + print ''; + print $langs->trans("ListOfAccounts"); + print ''; + } + print '
'; + print ''; print '
'; - print '
'; + print ''; } print '
'; @@ -865,7 +865,7 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co print ''; } } elseif ($fieldlist[$field] == 'category_type') { - print ''; + print ''; print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { diff --git a/htdocs/accountancy/admin/closure.php b/htdocs/accountancy/admin/closure.php index a425fd45768..7e781b3fc71 100644 --- a/htdocs/accountancy/admin/closure.php +++ b/htdocs/accountancy/admin/closure.php @@ -39,8 +39,8 @@ $action = GETPOST('action', 'aZ09'); $list_account_main = array( - 'ACCOUNTING_RESULT_PROFIT', - 'ACCOUNTING_RESULT_LOSS' + 'ACCOUNTING_RESULT_PROFIT', + 'ACCOUNTING_RESULT_LOSS' ); /* @@ -48,17 +48,17 @@ $list_account_main = array( */ if ($action == 'update') { - $error = 0; + $error = 0; - $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha'); + $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha'); - if (!empty($defaultjournal)) { - if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } else { - $error++; - } + if (!empty($defaultjournal)) { + if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + $error++; + } foreach ($list_account_main as $constname) { $constvalue = GETPOST($constname, 'alpha'); @@ -99,20 +99,20 @@ print ''; print ''; foreach ($list_account_main as $key) { - print ''; - // Param - $label = $langs->trans($key); - $keydesc = $key.'_Desc'; + print ''; + // Param + $label = $langs->trans($key); + $keydesc = $key.'_Desc'; - $htmltext = $langs->trans($keydesc); - print ''; - // Value - print ''; - print ''; + $htmltext = $langs->trans($keydesc); + print ''; + // Value + print ''; + print ''; } // Journal diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index b2262c603f9..ba45220c8cc 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -45,7 +45,7 @@ $action = GETPOST('action', 'aZ09'); // Parameters ACCOUNTING_EXPORT_* $main_option = array( - 'ACCOUNTING_EXPORT_PREFIX_SPEC', + 'ACCOUNTING_EXPORT_PREFIX_SPEC', ); $configuration = AccountancyExport::getTypeConfig(); @@ -58,22 +58,22 @@ $listcr = $configuration['cr']; $model_option = array( - '1' => array( - 'label' => 'ACCOUNTING_EXPORT_FORMAT', - 'param' => $listformat, - ), - '2' => array( - 'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV', - 'param' => '', - ), - '3' => array( - 'label' => 'ACCOUNTING_EXPORT_ENDLINE', - 'param' => $listcr, - ), - '4' => array( - 'label' => 'ACCOUNTING_EXPORT_DATE', - 'param' => '', - ), + '1' => array( + 'label' => 'ACCOUNTING_EXPORT_FORMAT', + 'param' => $listformat, + ), + '2' => array( + 'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV', + 'param' => '', + ), + '3' => array( + 'label' => 'ACCOUNTING_EXPORT_ENDLINE', + 'param' => $listcr, + ), + '4' => array( + 'label' => 'ACCOUNTING_EXPORT_DATE', + 'param' => '', + ), ); @@ -105,22 +105,22 @@ if ($action == 'update') { } } - foreach ($listparam[$modelcsv] as $key => $value) { - $constante = $key; + foreach ($listparam[$modelcsv] as $key => $value) { + $constante = $key; - if (strpos($constante, 'ACCOUNTING') !== false) { - $constvalue = GETPOST($key, 'alpha'); - if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } - } + if (strpos($constante, 'ACCOUNTING') !== false) { + $constvalue = GETPOST($key, 'alpha'); + if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + } if (!$error) { - // reload - $configuration = AccountancyExport::getTypeConfig(); - $listparam = $configuration['param']; - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + // reload + $configuration = AccountancyExport::getTypeConfig(); + $listparam = $configuration['param']; + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } @@ -148,36 +148,36 @@ print 'jQuery(document).ready(function () {'."\n"; print ' function initfields()'."\n"; print ' {'."\n"; foreach ($listparam as $key => $param) { - print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n"; - print ' {'."\n"; - print ' //console.log("'.$param['label'].'");'."\n"; - if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) { - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n"; - } - if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) { - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n"; - } - if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) { - print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n"; - } - if (empty($param['ACCOUNTING_EXPORT_DATE'])) { - print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n"; - } - print ' }'."\n"; + print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n"; + print ' {'."\n"; + print ' //console.log("'.$param['label'].'");'."\n"; + if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) { + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n"; + } + if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) { + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n"; + } + if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) { + print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n"; + } + if (empty($param['ACCOUNTING_EXPORT_DATE'])) { + print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n"; + } + print ' }'."\n"; } print ' }'."\n"; print ' initfields();'."\n"; @@ -262,17 +262,17 @@ if ($num2) { foreach ($model_option as $key) { print ''; - // Param - $label = $key['label']; + // Param + $label = $key['label']; print ''; // Value - print ''; } diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 1ddcddf13e6..4aa1fd99ff4 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -113,7 +113,7 @@ if ($result) $i = 0; - $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write); + $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write); $title = $langs->trans('AccountingPeriods'); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index a4227a761a4..aa10c0101c1 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -159,7 +159,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print '
'; - print $form->textwithpicto($label, $htmltext); - print ''; // Do not force class=right, or it align also the content of the select box - print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); - print '
'; + print $form->textwithpicto($label, $htmltext); + print ''; // Do not force class=right, or it align also the content of the select box + print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print '
'.$langs->trans($label).''; - if (is_array($key['param'])) { - print $form->selectarray($label, $key['param'], $conf->global->$label, 0); - } else { - print ''; - } + print ''; + if (is_array($key['param'])) { + print $form->selectarray($label, $key['param'], $conf->global->$label, 0); + } else { + print ''; + } print '
'; @@ -187,7 +187,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -202,7 +202,7 @@ if ($action == 'create') $head = fiscalyear_prepare_head($object); if ($action == 'edit') { - dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); + print dol_get_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); print '
'."\n"; print ''; @@ -248,7 +248,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); } else { /* * Confirm delete @@ -257,7 +257,7 @@ if ($action == 'create') print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete"); } - dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); + print dol_get_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); print ''; @@ -296,7 +296,7 @@ if ($action == 'create') print "
"; - dol_fiche_end(); + print dol_get_fiche_end(); if (!empty($user->rights->accounting->fiscalyear->write)) { diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index f293c9b450b..2971e2eb114 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -49,7 +49,7 @@ if ($id) { $head = fiscalyear_prepare_head($object); - dol_fiche_head($head, 'info', $langs->trans("Fiscalyear"), 0, 'cron'); + print dol_get_fiche_head($head, 'info', $langs->trans("Fiscalyear"), 0, 'cron'); print ''; + print ''; + print '
'; dol_print_object_info($object); diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 819160e7d23..68a9660a0e9 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -420,15 +420,15 @@ if ($id) $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate $class = "left"; - if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } + if ($fieldlist[$field] == 'code') { + $valuetoshow = $langs->trans("Code"); + } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Label"); } - if ($fieldlist[$field] == 'nature') { - $valuetoshow = $langs->trans("NatureOfJournal"); - } + if ($fieldlist[$field] == 'nature') { + $valuetoshow = $langs->trans("NatureOfJournal"); + } if ($valuetoshow != '') { print ''; @@ -540,14 +540,14 @@ if ($id) $valuetoshow = ucfirst($fieldlist[$field]); // By defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } + $valuetoshow = $langs->trans("Code"); + } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { - $valuetoshow = $langs->trans("Label"); - } + $valuetoshow = $langs->trans("Label"); + } if ($fieldlist[$field] == 'nature') { - $valuetoshow = $langs->trans("NatureOfJournal"); - } + $valuetoshow = $langs->trans("NatureOfJournal"); + } // Affiche nom du champ if ($showfield) { @@ -594,7 +594,7 @@ if ($id) if (empty($reshook)) { - $langs->load("accountancy"); + $langs->load("accountancy"); foreach ($fieldlist as $field => $value) { $showfield = 1; @@ -607,7 +607,7 @@ if ($id) $valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]}); } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { $valuetoshow = $langs->trans($obj->label); - } + } $class = 'tddict'; // Show value for field @@ -619,15 +619,15 @@ if ($id) $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default if (isset($obj->code) && $id != 10) { if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { - $iserasable = 0; - $canbedisabled = 0; - } elseif ($obj->code == 'RECEP') { - $iserasable = 0; - $canbedisabled = 0; - } elseif ($obj->code == 'EF0') { - $iserasable = 0; - $canbedisabled = 0; - } + $iserasable = 0; + $canbedisabled = 0; + } elseif ($obj->code == 'RECEP') { + $iserasable = 0; + $canbedisabled = 0; + } elseif ($obj->code == 'EF0') { + $iserasable = 0; + $canbedisabled = 0; + } } $canbemodified = $iserasable; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index d88800016a8..e09f6ec14cf 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -42,7 +42,7 @@ if (empty($conf->accounting->enabled)) { accessforbidden(); } if (!$user->rights->accounting->bind->write) - accessforbidden(); + accessforbidden(); // search & action GETPOST $action = GETPOST('action', 'aZ09'); @@ -100,14 +100,14 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_ref = ''; - $search_label = ''; - $search_desc = ''; + $search_ref = ''; + $search_label = ''; + $search_desc = ''; $search_vat = ''; - $search_onsell = ''; - $search_onpurchase = ''; - $search_current_account = ''; - $search_current_account_valid = '-1'; + $search_onsell = ''; + $search_onpurchase = ''; + $search_current_account = ''; + $search_current_account_valid = '-1'; } // Sales or Purchase mode ? @@ -117,8 +117,8 @@ if ($action == 'update') { $accounting_product_modes = array( 'ACCOUNTANCY_SELL', - 'ACCOUNTANCY_SELL_INTRA', - 'ACCOUNTANCY_SELL_EXPORT', + 'ACCOUNTANCY_SELL_INTRA', + 'ACCOUNTANCY_SELL_EXPORT', 'ACCOUNTANCY_BUY', 'ACCOUNTANCY_BUY_INTRA', 'ACCOUNTANCY_BUY_EXPORT' @@ -172,22 +172,22 @@ if ($action == 'update') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $sql .= " SET accountancy_code_sell = ".$accounting->account_number; } - if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number; - } - if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number; - } + if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + $sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number; + } + if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { + $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number; + } $sql .= " WHERE rowid = ".((int) $productid); dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); if ($db->query($sql)) { - $ok++; - $db->commit(); + $ok++; + $db->commit(); } else { - $ko++; - $db->rollback(); + $ko++; + $db->rollback(); } } @@ -253,7 +253,7 @@ $sql .= " aa.rowid as aaid"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; + $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; @@ -271,9 +271,9 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_buy", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_buy", $search_current_account); + } } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_buy_intra", $search_current_account); @@ -283,17 +283,17 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { $sql .= natural_search("p.accountancy_code_buy_export", $search_current_account); } } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_sell", $search_current_account); + } } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account); + } } else { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account); + } } if ($search_current_account_valid == 'withoutvalidaccount') { @@ -301,7 +301,7 @@ if ($search_current_account_valid == 'withoutvalidaccount') } if ($search_current_account_valid == 'withvalidaccount') { - $sql .= " AND aa.account_number IS NOT NULL"; + $sql .= " AND aa.account_number IS NOT NULL"; } // Add search filter like if (strlen(trim($search_ref))) { @@ -324,13 +324,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -342,32 +342,32 @@ if ($result) $num = $db->num_rows($result); $i = 0; - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref); - if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label); - if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref); + if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label); + if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc); if ($search_vat > 0) $param .= '&search_vat='.urlencode($search_vat); - if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account); - if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid); - if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode); + if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account); + if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid); + if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode); - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); + print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); print '
'; print ''.$langs->trans("InitAccountancyDesc").'
'; print '
'; - // Select mode + // Select mode print ''; print ''; print ''; @@ -377,13 +377,13 @@ if ($result) print "\n"; if ($mysoc->isInEEC()) { - print ''; - print '\n"; + print ''; + print '\n"; } - print ''; - print '\n"; + print ''; + print '\n"; print ''; print '\n"; if ($mysoc->isInEEC()) @@ -405,8 +405,8 @@ if ($result) $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $buttonsave = ''; - //print '
'.$buttonsave.'
'; + $buttonsave = ''; + //print '
'.$buttonsave.'
'; $texte = $langs->trans("ListOfProductsServices"); print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $buttonsave, $num, $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1); @@ -444,22 +444,22 @@ if ($result) print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); - if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); + if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); // On sell / On purchase - if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell_intra"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell_export"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_buy"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { + print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_sell"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_sell_intra"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { + print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_sell_export"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_buy"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); $fieldtosortaccount = "p.accountancy_code_buy_intra"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { @@ -475,8 +475,8 @@ if ($result) $product_static = new Product($db); $i = 0; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) + { $obj = $db->fetch_object($result); // Ref produit as link @@ -494,12 +494,12 @@ if ($result) $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell_intra; + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell_export; - } else { + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell_export; + } else { $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } @@ -560,11 +560,11 @@ if ($result) if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) { - // TODO ADJUST DESCRIPTION SIZE - // print ''; - // TODO: we should set a user defined value to adjust user square / wide screen size - $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; - print ''; + // TODO ADJUST DESCRIPTION SIZE + // print ''; + // TODO: we should set a user defined value to adjust user square / wide screen size + $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + print ''; } // VAT @@ -581,36 +581,36 @@ if ($result) // Current accounting account print ''; // New account to set $defaultvalue = ''; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - // Accounting account buy + // Accounting account buy print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { // Accounting account buy intra (In EEC) @@ -620,7 +620,7 @@ if ($result) $codesell = length_accountg($obj->accountancy_code_buy_intra); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { // Accounting account buy export (Out of EEC) @@ -630,7 +630,7 @@ if ($result) $codesell = length_accountg($obj->accountancy_code_buy_export); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { // Accounting account sell @@ -640,32 +640,32 @@ if ($result) $codesell = length_accountg($obj->accountancy_code_sell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - // Accounting account sell intra (In EEC) - print ''; - } else { - // Accounting account sell export (Out of EEC) - print ''; - } + // Accounting account sell intra (In EEC) + print ''; + } else { + // Accounting account sell export (Out of EEC) + print ''; + } // Checkbox select print ''; + print ''; print ""; $i++; } @@ -689,7 +689,17 @@ if ($result) if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'button\'); else jQuery("#changeaccount").attr(\'class\',\'button\'); } - jQuery(".checkforselect, #checkallactions").click(function() { + + jQuery(".checkforselect").change(function() { + init_savebutton(); + }); + jQuery(".productforselect").change(function() { + console.log($(this).attr("id")+" "+$(this).val()); + if ($(this).val() && $(this).val() != -1) { + $(".productforselect"+$(this).attr("id")).prop(\'checked\', true); + } else { + $(".productforselect"+$(this).attr("id")).prop(\'checked\', false); + } init_savebutton(); }); diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index 4b44bd35149..20fe5b86355 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -105,7 +105,7 @@ $title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger'); llxHeader('', $title); // Customer -$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '0' as type, sa.entity"; +$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe sa"; $sql .= " WHERE sa.entity IN (".getEntity('societe').")"; $sql .= " AND sa.code_compta <> ''"; @@ -148,7 +148,7 @@ if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db // Supplier $sql .= " UNION "; -$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '1' as type, sa.entity FROM ".MAIN_DB_PREFIX."societe sa"; +$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity FROM ".MAIN_DB_PREFIX."societe sa"; $sql .= " WHERE sa.entity IN (".getEntity('societe').")"; $sql .= " AND sa.code_compta_fournisseur <> ''"; //print $sql; @@ -190,7 +190,7 @@ if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db // User $sql .= " UNION "; -$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '2' as type, u.entity FROM ".MAIN_DB_PREFIX."user u"; +$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity FROM ".MAIN_DB_PREFIX."user u"; $sql .= " WHERE u.entity IN (".getEntity('user').")"; $sql .= " AND u.accountancy_code <> ''"; //print $sql; @@ -287,7 +287,7 @@ if ($resql) print ''; if (!empty($arrayfields['subaccount']['checked'])) print ''; if (!empty($arrayfields['label']['checked'])) print ''; - if (!empty($arrayfields['type']['checked'])) print ''; + if (!empty($arrayfields['type']['checked'])) print ''; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print ''; } print ''; + print ''; } // Action column print '\n"; + print "\n"; if (!$i) $totalarray['nbfield']++; } @@ -1065,9 +1065,9 @@ print ''; // TODO Replace this with mass delete action if ($user->rights->accounting->mouvements->supprimer_tous) { - print '
'."\n"; - print ''.$langs->trans("DeleteMvt").''; - print '
'; + print '
'."\n"; + print ''.$langs->trans("DeleteMvt").''; + print '
'; } print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 4ed055be0b1..45e8c6aee70 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("accountancy")); +$langs->loadLangs(array("accountancy", "compta")); $action = GETPOST('action', 'aZ09'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); @@ -138,7 +138,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { @@ -172,55 +172,55 @@ if (empty($reshook)) if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; - $param .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int'); + $param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int'); } if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; - $param .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int'); + $param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int'); } if (!empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; - $param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); + $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); } if (!empty($search_accountancy_code_start)) { $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); + $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); } if (!empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); + $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); } if (!empty($search_label_account)) { $filter['t.label_compte'] = $search_label_account; - $param .= '&search_label_compte=' . urlencode($search_label_account); + $param .= '&search_label_compte='.urlencode($search_label_account); } if (!empty($search_mvt_num)) { $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num=' . urlencode($search_mvt_num); + $param .= '&search_mvt_num='.urlencode($search_mvt_num); } if (!empty($search_doc_ref)) { $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref=' . urlencode($search_doc_ref); + $param .= '&search_doc_ref='.urlencode($search_doc_ref); } if (!empty($search_label_operation)) { $filter['t.label_operation'] = $search_label_operation; - $param .= '&search_label_operation=' . urlencode($search_label_operation); + $param .= '&search_label_operation='.urlencode($search_label_operation); } if (!empty($search_direction)) { $filter['t.sens'] = $search_direction; - $param .= '&search_direction=' . urlencode($search_direction); + $param .= '&search_direction='.urlencode($search_direction); } if (!empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code=' . urlencode($search_ledger_code); + $param .= '&search_ledger_code='.urlencode($search_ledger_code); } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; - $param .= '&search_debit=' . urlencode($search_debit); + $param .= '&search_debit='.urlencode($search_debit); } if (!empty($search_credit)) { $filter['t.credit'] = $search_credit; - $param .= '&search_credit=' . urlencode($search_credit); + $param .= '&search_credit='.urlencode($search_credit); } if (!empty($search_lettering_code)) { $filter['t.lettering_code'] = $search_lettering_code; @@ -376,18 +376,17 @@ print ''; print ''; - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); $newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss'=>'marginleftonly btnTitleSelected')); $newcardbutton .= '   '; -$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -427,7 +426,7 @@ print ''; // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; + print ''; } // Date document if (!empty($arrayfields['t.doc_date']['checked'])) { @@ -447,19 +446,19 @@ if (!empty($arrayfields['t.piece_num']['checked'])) } // Ref document if (!empty($arrayfields['t.doc_ref']['checked'])) { - print ''; + print ''; } // Label operation if (!empty($arrayfields['t.label_operation']['checked'])) { - print ''; + print ''; } // Debit if (!empty($arrayfields['t.debit']['checked'])) { - print ''; + print ''; } // Credit if (!empty($arrayfields['t.credit']['checked'])) { - print ''; + print ''; } // Lettering code if (!empty($arrayfields['t.lettering_code']['checked'])) @@ -535,7 +534,7 @@ while ($i < min($num, $limit)) $balance = $sous_total_debit - $sous_total_credit; print ''; print ''; - if ($balance > 0 ) + if ($balance > 0) { print '' : ''; + print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; if (!$i) $totalarray['nbfield']++; } @@ -681,7 +680,7 @@ while ($i < min($num, $limit)) // Amount credit if (!empty($arrayfields['t.credit']['checked'])) { - print ''; + print ''; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; $totalarray['val']['totalcredit'] += $line->credit; @@ -734,7 +733,7 @@ print ''; $balance = $sous_total_debit - $sous_total_credit; print ''; print ''; -if ($balance > 0 ) +if ($balance > 0) { print ''; + print ''; + print ''; } print ''; } diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index ed8f347a177..90f3d4c04ef 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -50,7 +50,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) { if (!$cancel) { - if ($codeventil < 0) $codeventil = 0; + if ($codeventil < 0) $codeventil = 0; $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; $sql .= " SET fk_code_ventilation = ".$codeventil; @@ -60,12 +60,12 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else { - setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); - if ($backtopage) - { - header("Location: ".$backtopage); - exit(); - } + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); + if ($backtopage) + { + header("Location: ".$backtopage); + exit(); + } } } else { header("Location: ./lines.php"); @@ -119,7 +119,7 @@ if (!empty($id)) { print load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_accountancy'); - dol_fiche_head(); + print dol_get_fiche_head(); print '
'.$langs->trans('Options').''.$langs->trans('Description').'
'.$langs->trans('OptionModeProductSellIntra').''.$langs->trans('OptionModeProductSellIntraDesc'); - print "
'.$langs->trans('OptionModeProductSellIntra').''.$langs->trans('OptionModeProductSellIntraDesc'); + print "
'.$langs->trans('OptionModeProductSellExport').''.$langs->trans('OptionModeProductSellExportDesc'); - print "
'.$langs->trans('OptionModeProductSellExport').''.$langs->trans('OptionModeProductSellExportDesc'); + print "
'.$langs->trans('OptionModeProductBuy').''.$langs->trans('OptionModeProductBuyDesc')."
' . $obj->description . ''.nl2br(dol_trunc($obj->description, $trunclength)).'' . $obj->description . ''.nl2br(dol_trunc($obj->description, $trunclength)).''; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - print length_accountg($obj->accountancy_code_buy); - if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + print length_accountg($obj->accountancy_code_buy); + if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - print length_accountg($obj->accountancy_code_buy_intra); - if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - print length_accountg($obj->accountancy_code_buy_export); - if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - print length_accountg($obj->accountancy_code_sell); - if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - print length_accountg($obj->accountancy_code_sell_intra); - if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + print length_accountg($obj->accountancy_code_buy_intra); + if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + print length_accountg($obj->accountancy_code_buy_export); + if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { + print length_accountg($obj->accountancy_code_sell); + if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + print length_accountg($obj->accountancy_code_sell_intra); + if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); } else { - print length_accountg($obj->accountancy_code_sell_export); - if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } + print length_accountg($obj->accountancy_code_sell_export); + if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; $codesell = length_accountg($obj->accountancy_code_buy); if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); print ''; - //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; - $codesell = length_accountg($obj->accountancy_code_sell_intra); - //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); - print ''; - //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; - $codesell = length_accountg($obj->accountancy_code_sell_export); - if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); - print ''; + //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell_intra); + //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); + print ''; + //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell_export); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); + print ''; - print '
'.$form->selectarray('search_type', array('0'=>$langs->trans('Customer'), '1'=>$langs->trans('Supplier'), '2'=>$langs->trans('Employee')), $search_type, 1).''.$form->selectarray('search_type', array('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).' '; $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); @@ -335,17 +335,17 @@ if ($resql) print ''; $s = ''; // Customer - if ($obj->type == 0) + if ($obj->type == 1) { $s .= ''.$langs->trans("Customer").''; } // Supplier - elseif ($obj->type == 1) + elseif ($obj->type == 2) { $s .= ''.$langs->trans("Supplier").''; } // User - elseif ($obj->type == 2) + elseif ($obj->type == 3) { $s .= ''.$langs->trans("Employee").''; } @@ -378,17 +378,17 @@ if ($resql) print ''; $e = ''; // Customer - if ($obj->type == 0) + if ($obj->type == 1) { $e .= ''.img_edit().''; } // Supplier - elseif ($obj->type == 1) + elseif ($obj->type == 2) { $e .= ''.img_edit().''; } // User - elseif ($obj->type == 2) + elseif ($obj->type == 3) { $e .= ''.img_edit().''; } diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index c3e225e5399..a930ed12852 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -274,11 +274,11 @@ if ($action != 'export_csv') $sous_total_credit = 0; $displayed_account = ""; - $accountingaccountstatic = new AccountingAccount($db); + $accountingaccountstatic = new AccountingAccount($db); $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; - $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features + $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'"; $sql .= " GROUP BY t.numero_compte"; @@ -292,12 +292,12 @@ if ($action != 'export_csv') foreach ($object->lines as $line) { - $accountingaccountstatic->fetch(null, $line->numero_compte, true); - if (!empty($accountingaccountstatic->account_number)) { - $accounting_account = $accountingaccountstatic->getNomUrl(0, 1); - } else { - $accounting_account = length_accountg($line->numero_compte); - } + $accountingaccountstatic->fetch(null, $line->numero_compte, true); + if (!empty($accountingaccountstatic->account_number)) { + $accounting_account = $accountingaccountstatic->getNomUrl(0, 1); + } else { + $accounting_account = length_accountg($line->numero_compte); + } $link = ''; $total_debit += $line->debit; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 8ca880de25f..c2a478c79ec 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -114,12 +114,12 @@ if ($action == "confirm_update") { $object->credit = $credit; if (floatval($debit) != 0.0) { - $object->montant = $debit; // deprecated + $object->montant = $debit; // deprecated $object->amount = $debit; $object->sens = 'D'; } if (floatval($credit) != 0.0) { - $object->montant = $credit; // deprecated + $object->montant = $credit; // deprecated $object->amount = $credit; $object->sens = 'C'; } @@ -175,13 +175,13 @@ if ($action == "confirm_update") { $object->fk_docdet = (int) GETPOST('fk_docdet', 'int'); if (floatval($debit) != 0.0) { - $object->montant = $debit; // deprecated + $object->montant = $debit; // deprecated $object->amount = $debit; $object->sens = 'D'; } if (floatval($credit) != 0.0) { - $object->montant = $credit; // deprecated + $object->montant = $credit; // deprecated $object->amount = $credit; $object->sens = 'C'; } @@ -245,7 +245,7 @@ if ($action == "confirm_update") { $object->journal_label = $journal_label; $object->fk_doc = 0; $object->fk_docdet = 0; - $object->montant = 0; // deprecated + $object->montant = 0; // deprecated $object->amount = 0; $result = $object->createStd($user, 0, $mode); @@ -351,7 +351,7 @@ if ($action == 'create') print ''."\n"; print ''."\n"; - dol_fiche_head(); + print dol_get_fiche_head(); print ''; @@ -386,7 +386,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -415,7 +415,7 @@ if ($action == 'create') $head[$h][2] = 'transaction'; $h++; - dol_fiche_head($head, 'transaction', '', -1); + print dol_get_fiche_head($head, 'transaction', '', -1); //dol_banner_tab($object, '', $backlink); @@ -573,7 +573,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -719,7 +719,7 @@ if ($action == 'create') } } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index d89d0dca60c..6d663edcf4e 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -151,7 +151,7 @@ $arrayfields = array( 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), 't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0), 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0), - 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), + 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); @@ -176,145 +176,145 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { - $search_mvt_num = ''; - $search_doc_type = ''; - $search_doc_ref = ''; - $search_doc_date = ''; - $search_accountancy_code = ''; - $search_accountancy_code_start = ''; - $search_accountancy_code_end = ''; - $search_accountancy_aux_code = ''; - $search_accountancy_aux_code_start = ''; - $search_accountancy_aux_code_end = ''; - $search_mvt_label = ''; - $search_direction = ''; - $search_ledger_code = ''; - $search_date_start = ''; - $search_date_end = ''; - $search_date_creation_start = ''; - $search_date_creation_end = ''; - $search_date_modification_start = ''; - $search_date_modification_end = ''; - $search_date_export_start = ''; - $search_date_export_end = ''; - $search_debit = ''; - $search_credit = ''; - $search_lettering_code = ''; + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_mvt_num = ''; + $search_doc_type = ''; + $search_doc_ref = ''; + $search_doc_date = ''; + $search_accountancy_code = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_accountancy_aux_code = ''; + $search_accountancy_aux_code_start = ''; + $search_accountancy_aux_code_end = ''; + $search_mvt_label = ''; + $search_direction = ''; + $search_ledger_code = ''; + $search_date_start = ''; + $search_date_end = ''; + $search_date_creation_start = ''; + $search_date_creation_end = ''; + $search_date_modification_start = ''; + $search_date_modification_end = ''; + $search_date_export_start = ''; + $search_date_export_end = ''; + $search_debit = ''; + $search_credit = ''; + $search_lettering_code = ''; $search_not_reconciled = ''; - } + } - // Must be after the remove filter action, before the export. - $param = ''; - $filter = array(); - if (!empty($search_date_start)) { - $filter['t.doc_date>='] = $search_date_start; - $tmp = dol_getdate($search_date_start); - $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_end)) { - $filter['t.doc_date<='] = $search_date_end; - $tmp = dol_getdate($search_date_end); - $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']); - } - if (!empty($search_doc_date)) { - $filter['t.doc_date'] = $search_doc_date; - $tmp = dol_getdate($search_doc_date); - $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']); - } - if (!empty($search_doc_type)) { - $filter['t.doc_type'] = $search_doc_type; - $param .= '&search_doc_type='.urlencode($search_doc_type); - } - if (!empty($search_doc_ref)) { - $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref='.urlencode($search_doc_ref); - } - if (!empty($search_accountancy_code)) { - $filter['t.numero_compte'] = $search_accountancy_code; - $param .= '&search_accountancy_code='.urlencode($search_accountancy_code); - } - if (!empty($search_accountancy_code_start)) { - $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); - } - if (!empty($search_accountancy_code_end)) { - $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); - } - if (!empty($search_accountancy_aux_code)) { - $filter['t.subledger_account'] = $search_accountancy_aux_code; - $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code); - } - if (!empty($search_accountancy_aux_code_start)) { - $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; - $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start); - } - if (!empty($search_accountancy_aux_code_end)) { - $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; - $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end); - } - if (!empty($search_mvt_label)) { - $filter['t.label_operation'] = $search_mvt_label; - $param .= '&search_mvt_label='.urlencode($search_mvt_label); - } - if (!empty($search_direction)) { - $filter['t.sens'] = $search_direction; - $param .= '&search_direction='.urlencode($search_direction); - } - if (!empty($search_ledger_code)) { - $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code='.urlencode($search_ledger_code); - } - if (!empty($search_mvt_num)) { - $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num='.urlencode($search_mvt_num); - } - if (!empty($search_date_creation_start)) { - $filter['t.date_creation>='] = $search_date_creation_start; - $tmp = dol_getdate($search_date_creation_start); - $param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_creation_end)) { - $filter['t.date_creation<='] = $search_date_creation_end; - $tmp = dol_getdate($search_date_creation_end); - $param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']); - } - if (!empty($search_date_modification_start)) { - $filter['t.tms>='] = $search_date_modification_start; - $tmp = dol_getdate($search_date_modification_start); - $param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_modification_end)) { - $filter['t.tms<='] = $search_date_modification_end; - $tmp = dol_getdate($search_date_modification_end); - $param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']); - } - if (!empty($search_date_export_start)) { - $filter['t.date_export>='] = $search_date_export_start; - $tmp = dol_getdate($search_date_export_start); - $param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_export_end)) { - $filter['t.date_export<='] = $search_date_export_end; - $tmp = dol_getdate($search_date_export_end); - $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']); - } - if (!empty($search_debit)) { - $filter['t.debit'] = $search_debit; - $param .= '&search_debit='.urlencode($search_debit); - } - if (!empty($search_credit)) { - $filter['t.credit'] = $search_credit; - $param .= '&search_credit='.urlencode($search_credit); - } - if (!empty($search_lettering_code)) { - $filter['t.lettering_code'] = $search_lettering_code; - $param .= '&search_lettering_code='.urlencode($search_lettering_code); - } + // Must be after the remove filter action, before the export. + $param = ''; + $filter = array(); + if (!empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $tmp = dol_getdate($search_date_start); + $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $tmp = dol_getdate($search_date_end); + $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']); + } + if (!empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $tmp = dol_getdate($search_doc_date); + $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']); + } + if (!empty($search_doc_type)) { + $filter['t.doc_type'] = $search_doc_type; + $param .= '&search_doc_type='.urlencode($search_doc_type); + } + if (!empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $param .= '&search_doc_ref='.urlencode($search_doc_ref); + } + if (!empty($search_accountancy_code)) { + $filter['t.numero_compte'] = $search_accountancy_code; + $param .= '&search_accountancy_code='.urlencode($search_accountancy_code); + } + if (!empty($search_accountancy_code_start)) { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); + } + if (!empty($search_accountancy_code_end)) { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); + } + if (!empty($search_accountancy_aux_code)) { + $filter['t.subledger_account'] = $search_accountancy_aux_code; + $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code); + } + if (!empty($search_accountancy_aux_code_start)) { + $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; + $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start); + } + if (!empty($search_accountancy_aux_code_end)) { + $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; + $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end); + } + if (!empty($search_mvt_label)) { + $filter['t.label_operation'] = $search_mvt_label; + $param .= '&search_mvt_label='.urlencode($search_mvt_label); + } + if (!empty($search_direction)) { + $filter['t.sens'] = $search_direction; + $param .= '&search_direction='.urlencode($search_direction); + } + if (!empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + $param .= '&search_ledger_code='.urlencode($search_ledger_code); + } + if (!empty($search_mvt_num)) { + $filter['t.piece_num'] = $search_mvt_num; + $param .= '&search_mvt_num='.urlencode($search_mvt_num); + } + if (!empty($search_date_creation_start)) { + $filter['t.date_creation>='] = $search_date_creation_start; + $tmp = dol_getdate($search_date_creation_start); + $param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_creation_end)) { + $filter['t.date_creation<='] = $search_date_creation_end; + $tmp = dol_getdate($search_date_creation_end); + $param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']); + } + if (!empty($search_date_modification_start)) { + $filter['t.tms>='] = $search_date_modification_start; + $tmp = dol_getdate($search_date_modification_start); + $param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_modification_end)) { + $filter['t.tms<='] = $search_date_modification_end; + $tmp = dol_getdate($search_date_modification_end); + $param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']); + } + if (!empty($search_date_export_start)) { + $filter['t.date_export>='] = $search_date_export_start; + $tmp = dol_getdate($search_date_export_start); + $param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_export_end)) { + $filter['t.date_export<='] = $search_date_export_end; + $tmp = dol_getdate($search_date_export_end); + $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']); + } + if (!empty($search_debit)) { + $filter['t.debit'] = $search_debit; + $param .= '&search_debit='.urlencode($search_debit); + } + if (!empty($search_credit)) { + $filter['t.credit'] = $search_credit; + $param .= '&search_credit='.urlencode($search_credit); + } + if (!empty($search_lettering_code)) { + $filter['t.lettering_code'] = $search_lettering_code; + $param .= '&search_lettering_code='.urlencode($search_lettering_code); + } if (!empty($search_not_reconciled)) { $filter['t.reconciled_option'] = $search_not_reconciled; $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); @@ -475,48 +475,48 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { { setEventMessages($object->error, $object->errors, 'errors'); } else { - // Export files + // Export files $accountancyexport = new AccountancyExport($db); $accountancyexport->export($object->lines, $formatexportset); - if (!empty($accountancyexport->errors)) - { - setEventMessages('', $accountancyexport->errors, 'errors'); - } else { - // Specify as export : update field date_export - $error = 0; - $db->begin(); + if (!empty($accountancyexport->errors)) + { + setEventMessages('', $accountancyexport->errors, 'errors'); + } else { + // Specify as export : update field date_export + $error = 0; + $db->begin(); - if (is_array($object->lines)) - { - foreach ($object->lines as $movement) - { - $now = dol_now(); + if (is_array($object->lines)) + { + foreach ($object->lines as $movement) + { + $now = dol_now(); - $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; - $sql .= " SET date_export = '".$db->idate($now)."'"; - $sql .= " WHERE rowid = ".$movement->id; + $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql .= " SET date_export = '".$db->idate($now)."'"; + $sql .= " WHERE rowid = ".$movement->id; - dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); - $result = $db->query($sql); - if (!$result) - { - $error++; - break; - } - } - } + dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + $error++; + break; + } + } + } - if (!$error) - { - $db->commit(); - // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); - } else { - $error++; - $db->rollback(); - setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); - } - } + if (!$error) + { + $db->commit(); + // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); + } else { + $error++; + $db->rollback(); + setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); + } + } exit; } } @@ -629,9 +629,9 @@ else $buttonLabel = $langs->trans("ExportList"); // Button re-export if (!empty($conf->global->ACCOUNTING_REEXPORT)) { - $newcardbutton = ''.img_picto($langs->trans("Activated"), 'switch_on').' '; + $newcardbutton = ''.img_picto($langs->trans("Activated"), 'switch_on').' '; } else { - $newcardbutton = ''.img_picto($langs->trans("Disabled"), 'switch_off').' '; + $newcardbutton = ''.img_picto($langs->trans("Disabled"), 'switch_off').' '; } $newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; @@ -791,14 +791,14 @@ if (!empty($arrayfields['t.tms']['checked'])) // Date export if (!empty($arrayfields['t.date_export']['checked'])) { - print '
'; - print '
'; - print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); - print '
'; - print '
'; - print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); - print '
'; - print '
'; + print '
'; + print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
'; + print '
'; + print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
'; + print '
'; @@ -854,7 +854,7 @@ while ($i < min($num, $limit)) $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->amount; // deprecated + $line->montant = $obj->amount; // deprecated $line->amount = $obj->amount; $line->sens = $obj->sens; $line->lettering_code = $obj->lettering_code; @@ -893,65 +893,65 @@ while ($i < min($num, $limit)) // Document ref if (!empty($arrayfields['t.doc_ref']['checked'])) { - if ($line->doc_type == 'customer_invoice') - { - $langs->loadLangs(array('bills')); + if ($line->doc_type == 'customer_invoice') + { + $langs->loadLangs(array('bills')); - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $objectstatic = new Facture($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'facture'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $objectstatic = new Facture($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'facture'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } elseif ($line->doc_type == 'supplier_invoice') - { - $langs->loadLangs(array('bills')); + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } elseif ($line->doc_type == 'supplier_invoice') + { + $langs->loadLangs(array('bills')); - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $objectstatic = new FactureFournisseur($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'invoice_supplier'; + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $objectstatic = new FactureFournisseur($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'invoice_supplier'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); - } elseif ($line->doc_type == 'expense_report') - { - $langs->loadLangs(array('trips')); + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); + } elseif ($line->doc_type == 'expense_report') + { + $langs->loadLangs(array('trips')); - require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $objectstatic = new ExpenseReport($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'expensereport'; + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $objectstatic = new ExpenseReport($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'expensereport'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } else { - // Other type - } + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } else { + // Other type + } - print ''; + print ''; - print ''; - // Picto + Ref - print '
'; + print ''; + // Picto + Ref + print '
'; - if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') - { - print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); - print $documentlink; - } else { - print $line->doc_ref; - } - print '
'; + if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') + { + print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + print $documentlink; + } else { + print $line->doc_ref; + } + print '
'; - print "
'.$langs->trans("Balance").':'; print price($sous_total_debit - $sous_total_credit); @@ -666,7 +665,7 @@ while ($i < min($num, $limit)) if (!empty($arrayfields['t.label_operation']['checked'])) { // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_operation . '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')
'.$line->label_operation.''.$line->label_operation.'
('.length_accounta($line->subledger_account).')
' . ($line->credit ? price($line->credit) : '') . ''.($line->credit ? price($line->credit) : '').'
'.$langs->trans("Balance").':'; print price($sous_total_debit - $sous_total_credit); diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php new file mode 100644 index 00000000000..c286780e572 --- /dev/null +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -0,0 +1,766 @@ + + * Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2018 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/accountancy/bookkeeping/listbysubaccount.php + * \ingroup Accountancy (Double entries) + * \brief List operation of ledger ordered by subaccount number + */ + +require '../../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array("accountancy", "compta")); + +$action = GETPOST('action', 'aZ09'); +$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); +$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); +$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); + +$search_accountancy_code = GETPOST("search_accountancy_code"); +$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); +if ($search_accountancy_code_start == - 1) { + $search_accountancy_code_start = ''; +} +$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); +if ($search_accountancy_code_end == - 1) { + $search_accountancy_code_end = ''; +} +$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); +$search_label_operation = GETPOST('search_label_operation', 'alpha'); +$search_mvt_num = GETPOST('search_mvt_num', 'int'); +$search_direction = GETPOST('search_direction', 'alpha'); +$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); +$search_debit = GETPOST('search_debit', 'alpha'); +$search_credit = GETPOST('search_credit', 'alpha'); +$search_lettering_code = GETPOST('search_lettering_code', 'alpha'); +$search_not_reconciled = GETPOST('search_reconciled_option', 'alpha'); + +if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { + $action = 'delbookkeepingyear'; +} + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if ($sortorder == "") $sortorder = "ASC"; +if ($sortfield == "") $sortfield = "t.doc_date,t.rowid"; + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new BookKeeping($db); +$formfile = new FormFile($db); +$hookmanager->initHooks(array('bookkeepingbysubaccountlist')); + +$formaccounting = new FormAccounting($db); +$form = new Form($db); + +if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) { + $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; + $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; + $sql .= $db->plimit(1); + $res = $db->query($sql); + + if ($res->num_rows > 0) { + $fiscalYear = $db->fetch_object($res); + $search_date_start = strtotime($fiscalYear->date_start); + $search_date_end = strtotime($fiscalYear->date_end); + } else { + $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); + $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + $year_end = $year_start + 1; + $month_end = $month_start - 1; + if ($month_end < 1) + { + $month_end = 12; + $year_end--; + } + $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); + $search_date_end = dol_get_last_day($year_end, $month_end); + } +} + +$arrayfields = array( + // 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), + 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), + 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), + 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), + 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), + 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1), + 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), + 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), +); + +if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); + +/* + * Action + */ +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } + +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_doc_date = ''; + $search_accountancy_code = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_label_account = ''; + $search_doc_ref = ''; + $search_label_operation = ''; + $search_mvt_num = ''; + $search_direction = ''; + $search_ledger_code = ''; + $search_date_start = ''; + $search_date_end = ''; + $search_date_startyear = ''; + $search_date_startmonth = ''; + $search_date_startday = ''; + $search_date_endyear = ''; + $search_date_endmonth = ''; + $search_date_endday = ''; + $search_debit = ''; + $search_credit = ''; + $search_lettering_code = ''; + $search_not_reconciled = ''; + } + + // Must be after the remove filter action, before the export. + $param = ''; + $filter = array(); + + if (!empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int'); + } + if (!empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int'); + } + if (!empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); + } + if (!empty($search_accountancy_code_start)) { + $filter['t.subledger_account>='] = $search_accountancy_code_start; + $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); + } + if (!empty($search_accountancy_code_end)) { + $filter['t.subledger_account<='] = $search_accountancy_code_end; + $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); + } + if (!empty($search_label_account)) { + $filter['t.label_compte'] = $search_label_account; + $param .= '&search_label_compte='.urlencode($search_label_account); + } + if (!empty($search_mvt_num)) { + $filter['t.piece_num'] = $search_mvt_num; + $param .= '&search_mvt_num='.urlencode($search_mvt_num); + } + if (!empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $param .= '&search_doc_ref='.urlencode($search_doc_ref); + } + if (!empty($search_label_operation)) { + $filter['t.label_operation'] = $search_label_operation; + $param .= '&search_label_operation='.urlencode($search_label_operation); + } + if (!empty($search_direction)) { + $filter['t.sens'] = $search_direction; + $param .= '&search_direction='.urlencode($search_direction); + } + if (!empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + $param .= '&search_ledger_code='.urlencode($search_ledger_code); + } + if (!empty($search_debit)) { + $filter['t.debit'] = $search_debit; + $param .= '&search_debit='.urlencode($search_debit); + } + if (!empty($search_credit)) { + $filter['t.credit'] = $search_credit; + $param .= '&search_credit='.urlencode($search_credit); + } + if (!empty($search_lettering_code)) { + $filter['t.lettering_code'] = $search_lettering_code; + $param .= '&search_lettering_code='.urlencode($search_lettering_code); + } + if (!empty($search_not_reconciled)) { + $filter['t.reconciled_option'] = $search_not_reconciled; + $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); + } +} + +if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { + $import_key = GETPOST('importkey', 'alpha'); + + if (!empty($import_key)) { + $result = $object->deleteByImportkey($import_key); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + // Make a redirect to avoid to launch the delete later after a back button + header("Location: listbyaccount.php".($param ? '?'.$param : '')); + exit; + } +} +if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { + $delmonth = GETPOST('delmonth', 'int'); + $delyear = GETPOST('delyear', 'int'); + if ($delyear == -1) { + $delyear = 0; + } + $deljournal = GETPOST('deljournal', 'alpha'); + if ($deljournal == -1) { + $deljournal = 0; + } + + if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) + { + $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages("RecordDeleted", null, 'mesgs'); + } + + // Make a redirect to avoid to launch the delete later after a back button + header("Location: listbysubaccount.php".($param ? '?'.$param : '')); + exit; + } else { + setEventMessages("NoRecordDeleted", null, 'warnings'); + } +} +if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { + $mvt_num = GETPOST('mvt_num', 'int'); + + if (!empty($mvt_num)) { + $result = $object->deleteMvtNum($mvt_num); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + } + + header("Location: listbysubaccount.php?noreset=1".($param ? '&'.$param : '')); + exit; + } +} + + +/* + * View + */ + +$formaccounting = new FormAccounting($db); +$formfile = new FormFile($db); +$formother = new FormOther($db); +$form = new Form($db); + +$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("BookkeepingSubAccount").')'; + +llxHeader('', $title_page); + + +// List +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); + if ($nbtotalofrecords < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); + +if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); +} + +$num = count($object->lines); + + +if ($action == 'delmouv') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); + print $formconfirm; +} +if ($action == 'delbookkeepingyear') { + $form_question = array(); + $delyear = GETPOST('delyear', 'int'); + $deljournal = GETPOST('deljournal', 'alpha'); + + if (empty($delyear)) { + $delyear = dol_print_date(dol_now(), '%Y'); + } + $month_array = array(); + for ($i = 1; $i <= 12; $i++) { + $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); + } + $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); + $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); + + $form_question['delmonth'] = array( + 'name' => 'delmonth', + 'type' => 'select', + 'label' => $langs->trans('DelMonth'), + 'values' => $month_array, + 'default' => '' + ); + $form_question['delyear'] = array( + 'name' => 'delyear', + 'type' => 'select', + 'label' => $langs->trans('DelYear'), + 'values' => $year_array, + 'default' => $delyear + ); + $form_question['deljournal'] = array( + 'name' => 'deljournal', + 'type' => 'other', // We don't use select here, the journal_array is already a select html component + 'label' => $langs->trans('DelJournal'), + 'value' => $journal_array, + 'default' => $deljournal + ); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); + print $formconfirm; +} + + +print '
'; +print ''; +print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; + + +$newcardbutton = dolGetButtonTitle($langs->trans('ViewAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss'=>'marginleftonly btnTitleSelected')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); + +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + +// Reverse sort order +if (preg_match('/^asc/i', $sortorder)) $sortorder = "asc"; +else $sortorder = "desc"; + +$moreforfilter = ''; + +// Accountancy account +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('AccountAccounting').': '; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('From').' '; +$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', 1, 'maxwidth200'); +$moreforfilter .= ' '.$langs->trans('to').' '; +$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', 1, 'maxwidth200'); +$moreforfilter .= '
'; +$moreforfilter .= '
'; + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +print '
'; +print $moreforfilter; +print '
'; + +print '
'; +print ''; + +// Filters lines +print ''; + +// Code journal +if (!empty($arrayfields['t.code_journal']['checked'])) { + print ''; +} +// Date document +if (!empty($arrayfields['t.doc_date']['checked'])) { + print ''; +} +// Movement number +if (!empty($arrayfields['t.piece_num']['checked'])) +{ + print ''; +} +// Ref document +if (!empty($arrayfields['t.doc_ref']['checked'])) { + print ''; +} +// Label operation +if (!empty($arrayfields['t.label_operation']['checked'])) { + print ''; +} +// Debit +if (!empty($arrayfields['t.debit']['checked'])) { + print ''; +} +// Credit +if (!empty($arrayfields['t.credit']['checked'])) { + print ''; +} +// Lettering code +if (!empty($arrayfields['t.lettering_code']['checked'])) +{ + print ''; +} + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +// Action column +print ''; +print "\n"; + +print ''; +if (!empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +print "\n"; + + +$total_debit = 0; +$total_credit = 0; +$sous_total_debit = 0; +$sous_total_credit = 0; +$displayed_account_number = null; // Start with undefined to be able to distinguish with empty + +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$totalarray = array(); +while ($i < min($num, $limit)) +{ + $line = $object->lines[$i]; + + $total_debit += $line->debit; + $total_credit += $line->credit; + + $accountg = length_accounta($line->subledger_account); + //if (empty($accountg)) $accountg = '-'; + + // Is it a break ? + if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { + $colspan = $totalarray['nbfield'] - 3; + $colspanend = $totalarray['nbfield'] - 7; + // Show a subtotal by accounting account + if (isset($displayed_account_number)) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + // Show balance of last shown account + $balance = $sous_total_debit - $sous_total_credit; + print ''; + print ''; + if ($balance > 0) + { + print ''; + print ''; + } else { + print ''; + print ''; + } + print ''; + print ''; + } + + // Show the break account + print ""; + print ''; + print ''; + + $displayed_account_number = $accountg; + //if (empty($displayed_account_number)) $displayed_account_number='-'; + $sous_total_debit = 0; + $sous_total_credit = 0; + + $colspan = 0; + } + + print ''; + + // Journal code + if (!empty($arrayfields['t.code_journal']['checked'])) + { + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $line->code_journal); + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Document date + if (!empty($arrayfields['t.doc_date']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Piece number + if (!empty($arrayfields['t.piece_num']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Document ref + if (!empty($arrayfields['t.doc_ref']['checked'])) + { + if ($line->doc_type == 'customer_invoice') + { + $langs->loadLangs(array('bills')); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $objectstatic = new Facture($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'facture'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } elseif ($line->doc_type == 'supplier_invoice') + { + $langs->loadLangs(array('bills')); + + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $objectstatic = new FactureFournisseur($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'invoice_supplier'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); + } elseif ($line->doc_type == 'expense_report') + { + $langs->loadLangs(array('trips')); + + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $objectstatic = new ExpenseReport($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'expensereport'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } else { + // Other type + } + + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Label operation + if (!empty($arrayfields['t.label_operation']['checked'])) { + // Affiche un lien vers la facture client/fournisseur + $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); + print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; + if (!$i) $totalarray['nbfield']++; + } + + // Amount debit + if (!empty($arrayfields['t.debit']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; + $totalarray['val']['totaldebit'] += $line->debit; + } + + // Amount credit + if (!empty($arrayfields['t.credit']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; + $totalarray['val']['totalcredit'] += $line->credit; + } + + // Lettering code + if (!empty($arrayfields['t.lettering_code']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; + + // Comptabilise le sous-total + $sous_total_debit += $line->debit; + $sous_total_credit += $line->credit; + + print "\n"; + + $i++; +} + +// Show sub-total of last shown account +$colspan = $totalarray['nbfield'] - 3; +$colspanend = $totalarray['nbfield'] - 8; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +// Show balance of last shown account +$balance = $sous_total_debit - $sous_total_credit; +print ''; +print ''; +if ($balance > 0) +{ + print ''; + print ''; +} else { + print ''; + print ''; +} +print ''; +print ''; + +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + + +print "
'; + print '
'; + print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
'; + print '
'; + print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
'; + print '
'; + print ''; + print '
'.$langs->trans("NotReconciled").''; + print '
'; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'.$langs->trans("TotalForAccount").' '.length_accounta($displayed_account_number).':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; + print price($sous_total_debit - $sous_total_credit); + print ''; + print price($sous_total_credit - $sous_total_debit); + print '
'; + if ($line->subledger_account != "" && $line->subledger_account != '-1') print length_accounta($line->subledger_account).' : '.$object->get_compte_desc($line->numero_compte); + else print ''.$langs->trans("Unknown").''; + print '
'.$journaltoshow.''.dol_print_date($line->doc_date, 'day').''; + $object->id = $line->id; + $object->piece_num = $line->piece_num; + print $object->getNomUrl(1, '', 0, '', 1); + print ''; + + print ''; + // Picto + Ref + print '
'; + + if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') + { + print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + print $documentlink; + } else { + print $line->doc_ref; + } + print '
'; + + print "
'.$line->label_operation.''.$line->label_operation.'
('.length_accounta($line->subledger_account).')
'.($line->debit ? price($line->debit) : '').''.($line->credit ? price($line->credit) : '').''.$line->lettering_code.''; + if (empty($line->date_export)) { + if ($user->rights->accounting->mouvements->creer) { + print ''.img_edit().''; + } + if ($user->rights->accounting->mouvements->supprimer) { + print '   '.img_delete().''; + } + } + print '
'.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; + print price($sous_total_debit - $sous_total_credit); + print ''; + print price($sous_total_credit - $sous_total_debit); + print '
"; +print '
'; + +// TODO Replace this with mass delete action +if ($user->rights->accounting->mouvements->supprimer_tous) { + print '
'."\n"; + print ''.$langs->trans("DeleteMvt").''; + print '
'; +} + +print '
'; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index 321ef282dff..e831e21f814 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -135,13 +135,13 @@ $head = societe_prepare_head($object); dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); -dol_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'company'); +print dol_get_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); -dol_fiche_end(); +print dol_get_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; @@ -195,17 +195,17 @@ dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEB if ($resql) { $i = 0; - $param = "&socid=".$socid; + $param = "&socid=".$socid; print '
'; - print ''; + print ''; print ''; - $letteringbutton = ''; + $letteringbutton = ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; /* print ''; @@ -244,13 +244,13 @@ if ($resql) { print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center '); - print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); + print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); print "\n"; $solde = 0; $tmp = ''; - while ($obj = $db->fetch_object($resql)) { + while ($obj = $db->fetch_object($resql)) { if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit); @@ -265,20 +265,20 @@ if ($resql) { print ''; // Journal - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $obj->code_journal); - $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); - print ''; + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $obj->code_journal); + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); + print ''; - if (empty($obj->lettering_code)) { - print ''; - print ''."\n"; - } else { - print ''; - print ''; - } + if (empty($obj->lettering_code)) { + print ''; + print ''."\n"; + } else { + print ''; + print ''; + } print "\n"; } @@ -299,9 +299,9 @@ if ($resql) { print "
'.price(round($solde, 2)).''.$journaltoshow.''.$journaltoshow.''; - print img_edit(); - print ''.$obj->lettering_code.''; + print img_edit(); + print ''.$obj->lettering_code.'
"; - print '
'."\n"; - print $letteringbutton; - print '
'; + print '
'."\n"; + print $letteringbutton; + print '
'; print ""; $db->free($resql); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index 144c2595d25..b5620f3ec25 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -4,7 +4,7 @@ * Copyright (C) 2013 Olivier Geffroy * Copyright (C) 2013 Florian Henry * Copyright (C) 2013-2019 Alexandre Spangaro - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,7 +41,7 @@ $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); +$socid = GETPOST('socid', 'int') ? ((int) GETPOST('socid', 'int')) : ((int) GETPOST('id', 'int')); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -134,13 +134,13 @@ $head = societe_prepare_head($object); dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); -dol_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'company'); +print dol_get_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); -dol_fiche_end(); +print dol_get_fiche_end(); $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; @@ -193,17 +193,17 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $param = "&socid=".$socid; + $param = "&socid=".$socid; print '
'; - print ''; + print ''; print ''; - $letteringbutton = ''; + $letteringbutton = ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; /* print ''; @@ -242,7 +242,7 @@ if ($resql) { print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center '); - print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); + print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); print "\n"; $solde = 0; @@ -261,21 +261,21 @@ if ($resql) { print ''; print ''; - // Journal - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $obj->code_journal); - $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); - print ''; + // Journal + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $obj->code_journal); + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); + print ''; if (empty($obj->lettering_code) && empty($obj->date_validated)) { print ''; - print ''."\n"; + print ''."\n"; } else { - print ''; - print ''; - } + print ''; + print ''; + } print "\n"; } @@ -296,9 +296,9 @@ if ($resql) { print "
'.price($obj->credit).''.price(round($solde, 2)).''.$journaltoshow.''.$journaltoshow.''; - print img_edit(); - print ''; + print img_edit(); + print ''.$obj->lettering_code.''.$obj->lettering_code.'
"; - print '
'."\n"; + print '
'."\n"; print $letteringbutton; - print '
'; + print '
'; print ""; $db->free($resql); diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index c7f7f8cf68c..eb43348f1ea 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -31,10 +31,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; */ class AccountancyCategory // extends CommonObject { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error string @@ -63,9 +63,9 @@ class AccountancyCategory // extends CommonObject public $rowid; /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; /** * @var string Accountancy code @@ -73,11 +73,11 @@ class AccountancyCategory // extends CommonObject public $code; /** - * @var string Accountancy Category label - */ - public $label; + * @var string Accountancy Category label + */ + public $label; - /** + /** * @var string Accountancy range account */ public $range_account; @@ -381,8 +381,8 @@ class AccountancyCategory // extends CommonObject * @param int $id Id * @return int <0 if KO, 0 if not found, >0 if OK */ - public function display($id) - { + public function display($id) + { global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; @@ -408,7 +408,7 @@ class AccountancyCategory // extends CommonObject return -1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -417,8 +417,8 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function getCptBK($id) - { + public function getCptBK($id) + { global $conf; $sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref"; @@ -457,7 +457,7 @@ class AccountancyCategory // extends CommonObject return -1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -466,41 +466,41 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function getAccountsWithNoCategory($id) - { - global $conf; + public function getAccountsWithNoCategory($id) + { + global $conf; - $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; - $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; - $sql .= " AND aa.active = 1"; - $sql .= " AND aa.entity = ".$conf->entity; - $sql .= " GROUP BY aa.account_number, aa.label"; - $sql .= " ORDER BY aa.account_number, aa.label"; + $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; + $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; + $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = ".$conf->entity; + $sql .= " GROUP BY aa.account_number, aa.label"; + $sql .= " ORDER BY aa.account_number, aa.label"; - $this->lines_CptBk = array(); + $this->lines_CptBk = array(); - dol_syslog(__METHOD__, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num) { - while ($obj = $this->db->fetch_object($resql)) { - $this->lines_cptbk[] = $obj; - } - } + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num) { + while ($obj = $this->db->fetch_object($resql)) { + $this->lines_cptbk[] = $obj; + } + } - return $num; - } else { - $this->error = "Error ".$this->db->lasterror(); - $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + return $num; + } else { + $this->error = "Error ".$this->db->lasterror(); + $this->errors[] = $this->error; + dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); - return -1; - } - } + return -1; + } + } /** * Function to add an accounting account in an accounting category @@ -510,8 +510,8 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function updateAccAcc($id_cat, $cpts = array()) - { + public function updateAccAcc($id_cat, $cpts = array()) + { global $conf; $error = 0; @@ -523,7 +523,7 @@ class AccountancyCategory // extends CommonObject $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; $sql .= " AND aa.entity = ".$conf->entity; - $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql + $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql $this->db->begin(); @@ -539,13 +539,13 @@ class AccountancyCategory // extends CommonObject $accountincptsadded = array(); while ($obj = $this->db->fetch_object($resql)) { - $account_number_formated = length_accountg($obj->account_number); - if (!empty($accountincptsadded[$account_number_formated])) continue; + $account_number_formated = length_accountg($obj->account_number); + if (!empty($accountincptsadded[$account_number_formated])) continue; - if (array_key_exists($account_number_formated, $cpts)) + if (array_key_exists($account_number_formated, $cpts)) { - $accountincptsadded[$account_number_formated] = 1; - // We found an account number that is in list $cpts of account to add + $accountincptsadded[$account_number_formated] = 1; + // We found an account number that is in list $cpts of account to add $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account"; $sql .= " SET fk_accounting_category=".$id_cat; $sql .= " WHERE rowid=".$obj->rowid; @@ -572,7 +572,7 @@ class AccountancyCategory // extends CommonObject return 1; } - } + } /** * Function to delete an accounting account from an accounting category @@ -581,8 +581,8 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function deleteCptCat($cpt_id) - { + public function deleteCptCat($cpt_id) + { $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa"; @@ -598,7 +598,7 @@ class AccountancyCategory // extends CommonObject } // Commit or rollback - if ($error) { + if ($error) { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); @@ -606,12 +606,12 @@ class AccountancyCategory // extends CommonObject $this->db->rollback(); return -1 * $error; - } else { + } else { $this->db->commit(); - return 1; - } - } + return 1; + } + } /** * Function to know all category from accounting account @@ -781,7 +781,7 @@ class AccountancyCategory // extends CommonObject 'formula' => $obj->formula, 'position' => $obj->position, 'category_type' => $obj->category_type, - 'bc' => $obj->sens + 'bc' => $obj->sens ); $i++; } diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 0204602438f..c36a0c8f906 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -55,7 +55,7 @@ class AccountancyExport public static $EXPORT_TYPE_QUADRATUS = 60; public static $EXPORT_TYPE_WINFIC = 70; public static $EXPORT_TYPE_OPENCONCERTO = 100; - public static $EXPORT_TYPE_LDCOMPTA = 110; + public static $EXPORT_TYPE_LDCOMPTA = 110; public static $EXPORT_TYPE_LDCOMPTA10 = 120; public static $EXPORT_TYPE_FEC = 1000; @@ -111,7 +111,7 @@ class AccountancyExport self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), - self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), + self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'), @@ -144,9 +144,9 @@ class AccountancyExport self::$EXPORT_TYPE_COGILOG => 'cogilog', self::$EXPORT_TYPE_AGIRIS => 'agiris', self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto', - self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', - self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', - self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', + self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', + self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', + self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', self::$EXPORT_TYPE_FEC => 'fec', ); @@ -201,22 +201,22 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => array( 'label' => $langs->trans('Modelcsv_agiris'), ), - self::$EXPORT_TYPE_OPENCONCERTO => array( - 'label' => $langs->trans('Modelcsv_openconcerto'), - 'ACCOUNTING_EXPORT_FORMAT' => 'csv', - ), + self::$EXPORT_TYPE_OPENCONCERTO => array( + 'label' => $langs->trans('Modelcsv_openconcerto'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), self::$EXPORT_TYPE_SAGE50_SWISS => array( 'label' => $langs->trans('Modelcsv_Sage50_Swiss'), 'ACCOUNTING_EXPORT_FORMAT' => 'csv', ), - self::$EXPORT_TYPE_LDCOMPTA => array( - 'label' => $langs->trans('Modelcsv_LDCompta'), - 'ACCOUNTING_EXPORT_FORMAT' => 'csv', - ), + self::$EXPORT_TYPE_LDCOMPTA => array( + 'label' => $langs->trans('Modelcsv_LDCompta'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), self::$EXPORT_TYPE_LDCOMPTA10 => array( - 'label' => $langs->trans('Modelcsv_LDCompta10'), - 'ACCOUNTING_EXPORT_FORMAT' => 'csv', - ), + 'label' => $langs->trans('Modelcsv_LDCompta10'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), self::$EXPORT_TYPE_FEC => array( 'label' => $langs->trans('Modelcsv_FEC'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', @@ -254,7 +254,7 @@ class AccountancyExport $filename = 'general_ledger-'.$this->getFormatCode($formatexportset); $type_export = 'general_ledger'; - global $db; // The tpl file use $db + global $db; // The tpl file use $db include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; @@ -289,21 +289,21 @@ class AccountancyExport case self::$EXPORT_TYPE_AGIRIS : $this->exportAgiris($TData); break; - case self::$EXPORT_TYPE_OPENCONCERTO : - $this->exportOpenConcerto($TData); - break; + case self::$EXPORT_TYPE_OPENCONCERTO : + $this->exportOpenConcerto($TData); + break; case self::$EXPORT_TYPE_SAGE50_SWISS : $this->exportSAGE50SWISS($TData); break; - case self::$EXPORT_TYPE_LDCOMPTA : - $this->exportLDCompta($TData); - break; - case self::$EXPORT_TYPE_LDCOMPTA10 : - $this->exportLDCompta10($TData); - break; - case self::$EXPORT_TYPE_FEC : - $this->exportFEC($TData); - break; + case self::$EXPORT_TYPE_LDCOMPTA : + $this->exportLDCompta($TData); + break; + case self::$EXPORT_TYPE_LDCOMPTA10 : + $this->exportLDCompta10($TData); + break; + case self::$EXPORT_TYPE_FEC : + $this->exportFEC($TData); + break; case self::$EXPORT_TYPE_CHARLEMAGNE : $this->exportCharlemagne($TData); break; @@ -386,6 +386,7 @@ class AccountancyExport foreach ($objectLines as $line) { $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date.$separator; print $line->code_journal.$separator; print length_accountg($line->numero_compte).$separator; @@ -394,7 +395,7 @@ class AccountancyExport print price($line->debit).$separator; print price($line->credit).$separator; print 'E'.$separator; - print length_accountg($line->subledger_account).$separator; + print length_accounta($line->subledger_account).$separator; print $end_line; } } @@ -599,7 +600,7 @@ class AccountancyExport $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0'); if ($data->sens == 'D') { - $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); } else { @@ -659,10 +660,10 @@ class AccountancyExport print $date.$separator; print $line->code_journal.$separator; if (empty($line->subledger_account)) { - print $line->numero_compte.$separator; - } else { - print $line->subledger_account.$separator; - } + print $line->numero_compte.$separator; + } else { + print $line->subledger_account.$separator; + } //print substr(length_accountg($line->numero_compte), 0, 2) . $separator; print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator; print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator; @@ -714,36 +715,36 @@ class AccountancyExport } } - /** - * Export format : OpenConcerto - * - * @param array $objectLines data - * @return void - */ - public function exportOpenConcerto($objectLines) - { + /** + * Export format : OpenConcerto + * + * @param array $objectLines data + * @return void + */ + public function exportOpenConcerto($objectLines) + { - $separator = ';'; - $end_line = "\n"; + $separator = ';'; + $end_line = "\n"; - foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + foreach ($objectLines as $line) { + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date.$separator; - print $line->code_journal.$separator; - if (empty($line->subledger_account)) { - print length_accountg($line->numero_compte).$separator; - } else { - print length_accounta($line->subledger_account).$separator; - } - print $line->doc_ref.$separator; - print $line->label_operation.$separator; - print price($line->debit).$separator; - print price($line->credit).$separator; + print $date.$separator; + print $line->code_journal.$separator; + if (empty($line->subledger_account)) { + print length_accountg($line->numero_compte).$separator; + } else { + print length_accounta($line->subledger_account).$separator; + } + print $line->doc_ref.$separator; + print $line->label_operation.$separator; + print price($line->debit).$separator; + print price($line->credit).$separator; - print $end_line; - } - } + print $end_line; + } + } /** * Export format : Configurable CSV @@ -822,25 +823,25 @@ class AccountancyExport print $line->piece_num.$separator; // FEC:EcritureDate - print $date_document . $separator; + print $date_document.$separator; // FEC:CompteNum print $line->numero_compte.$separator; // FEC:CompteLib - print dol_string_unaccent($line->label_compte) . $separator; + print dol_string_unaccent($line->label_compte).$separator; // FEC:CompAuxNum print $line->subledger_account.$separator; // FEC:CompAuxLib - print dol_string_unaccent($line->subledger_label) . $separator; + print dol_string_unaccent($line->subledger_label).$separator; // FEC:PieceRef print $line->doc_ref.$separator; // FEC:PieceDate - print dol_string_unaccent($date_creation) . $separator; + print dol_string_unaccent($date_creation).$separator; // FEC:EcritureLib print $line->label_operation.$separator; @@ -858,7 +859,7 @@ class AccountancyExport print $line->date_lettering.$separator; // FEC:ValidDate - print $date_validation . $separator; + print $date_validation.$separator; // FEC:Montantdevise print $line->multicurrency_amount.$separator; @@ -870,152 +871,152 @@ class AccountancyExport } } - /** - * Export format : SAGE50SWISS - * - * https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984 - * http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf - * - * @param array $objectLines data - * - * @return void - */ - public function exportSAGE50SWISS($objectLines) - { - // SAGE50SWISS - $this->separator = ','; - $this->end_line = "\r\n"; + /** + * Export format : SAGE50SWISS + * + * https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984 + * http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf + * + * @param array $objectLines data + * + * @return void + */ + public function exportSAGE50SWISS($objectLines) + { + // SAGE50SWISS + $this->separator = ','; + $this->end_line = "\r\n"; - // Print header line - print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag"; - print $this->end_line; - $thisPieceNum = ""; - $thisPieceAccountNr = ""; - $aSize = count($objectLines); - foreach ($objectLines as $aIndex=>$line) + // Print header line + print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag"; + print $this->end_line; + $thisPieceNum = ""; + $thisPieceAccountNr = ""; + $aSize = count($objectLines); + foreach ($objectLines as $aIndex=>$line) { - $sammelBuchung = false; - if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) - { - $sammelBuchung = true; - } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) - { - $sammelBuchung = true; - } elseif ($aIndex + 1 < $aSize - && $objectLines[$aIndex + 1]->piece_num == $line->piece_num - && $aIndex - 1 < $aSize - && $objectLines[$aIndex - 1]->piece_num == $line->piece_num - ) - { - $sammelBuchung = true; - } + $sammelBuchung = false; + if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) + { + $sammelBuchung = true; + } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) + { + $sammelBuchung = true; + } elseif ($aIndex + 1 < $aSize + && $objectLines[$aIndex + 1]->piece_num == $line->piece_num + && $aIndex - 1 < $aSize + && $objectLines[$aIndex - 1]->piece_num == $line->piece_num + ) + { + $sammelBuchung = true; + } - //Blg - print $line->piece_num.$this->separator; + //Blg + print $line->piece_num.$this->separator; - // Datum - $date = dol_print_date($line->doc_date, '%d.%m.%Y'); - print $date.$this->separator; + // Datum + $date = dol_print_date($line->doc_date, '%d.%m.%Y'); + print $date.$this->separator; - // Kto - print length_accountg($line->numero_compte).$this->separator; - // S/H - if ($line->sens == 'D') - { - print 'S'.$this->separator; - } else { - print 'H'.$this->separator; - } - //Grp - print self::trunc($line->code_journal, 1).$this->separator; - // GKto - if (empty($line->code_tiers)) - { - if ($line->piece_num == $thisPieceNum) - { - print length_accounta($thisPieceAccountNr).$this->separator; - } else { - print "div".$this->separator; - } - } else { - print length_accounta($line->code_tiers).$this->separator; - } - //SId - print $this->separator; - //SIdx - print "0".$this->separator; - //KIdx - print "0".$this->separator; - //BTyp - print "0".$this->separator; + // Kto + print length_accountg($line->numero_compte).$this->separator; + // S/H + if ($line->sens == 'D') + { + print 'S'.$this->separator; + } else { + print 'H'.$this->separator; + } + //Grp + print self::trunc($line->code_journal, 1).$this->separator; + // GKto + if (empty($line->code_tiers)) + { + if ($line->piece_num == $thisPieceNum) + { + print length_accounta($thisPieceAccountNr).$this->separator; + } else { + print "div".$this->separator; + } + } else { + print length_accounta($line->code_tiers).$this->separator; + } + //SId + print $this->separator; + //SIdx + print "0".$this->separator; + //KIdx + print "0".$this->separator; + //BTyp + print "0".$this->separator; - //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung - if ($sammelBuchung) - { - print "2".$this->separator; - } else { - print "1".$this->separator; - } - // Code - print '""'.$this->separator; - // Netto - if ($line->montant >= 0) - { - print $line->montant.$this->separator; - } else { - print ($line->montant * -1).$this->separator; - } - // Steuer - print "0.00".$this->separator; - // FW-Betrag - print "0.00".$this->separator; - // Tx1 - $line1 = self::toAnsi($line->label_compte, 29); - if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) - { - $line1 = ""; - } - $line2 = self::toAnsi($line->doc_ref, 29); - if (strlen($line1) == 0) - { - $line1 = $line2; - $line2 = ""; - } - if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) - { - $line1 = $line1.' / '.$line2; - $line2 = ""; - } + //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung + if ($sammelBuchung) + { + print "2".$this->separator; + } else { + print "1".$this->separator; + } + // Code + print '""'.$this->separator; + // Netto + if ($line->montant >= 0) + { + print $line->montant.$this->separator; + } else { + print ($line->montant * -1).$this->separator; + } + // Steuer + print "0.00".$this->separator; + // FW-Betrag + print "0.00".$this->separator; + // Tx1 + $line1 = self::toAnsi($line->label_compte, 29); + if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) + { + $line1 = ""; + } + $line2 = self::toAnsi($line->doc_ref, 29); + if (strlen($line1) == 0) + { + $line1 = $line2; + $line2 = ""; + } + if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) + { + $line1 = $line1.' / '.$line2; + $line2 = ""; + } - print '"'.self::toAnsi($line1).'"'.$this->separator; - // Tx2 - print '"'.self::toAnsi($line2).'"'.$this->separator; - //PkKey - print "0".$this->separator; - //OpId - print $this->separator; + print '"'.self::toAnsi($line1).'"'.$this->separator; + // Tx2 + print '"'.self::toAnsi($line2).'"'.$this->separator; + //PkKey + print "0".$this->separator; + //OpId + print $this->separator; - // Flag - print "0"; + // Flag + print "0"; - print $this->end_line; + print $this->end_line; - if ($line->piece_num !== $thisPieceNum) - { - $thisPieceNum = $line->piece_num; - $thisPieceAccountNr = $line->numero_compte; - } - } - } + if ($line->piece_num !== $thisPieceNum) + { + $thisPieceNum = $line->piece_num; + $thisPieceAccountNr = $line->numero_compte; + } + } + } - /** - * Export format : LD Compta version 9 - * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf - * - * @param array $objectLines data - * - * @return void - */ + /** + * Export format : LD Compta version 9 + * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf + * + * @param array $objectLines data + * + * @return void + */ public function exportLDCompta($objectLines) { @@ -1168,23 +1169,23 @@ class AccountancyExport { $soc = $this->db->fetch_object($resql); - $address = array('', '', ''); - if (strpos($soc->address, "\n") !== false) { - $address = explode("\n", $soc->address); - if (is_array($address) && count($address) > 0) { - foreach ($address as $key=>$data) { - $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data); - $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); - } - } - } else { - $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40); - $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40); - $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); - } + $address = array('', '', ''); + if (strpos($soc->address, "\n") !== false) { + $address = explode("\n", $soc->address); + if (is_array($address) && count($address) > 0) { + foreach ($address as $key=>$data) { + $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data); + $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); + } + } + } else { + $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40); + $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40); + $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); + } $type_enregistrement = 'C'; - //TYPE + //TYPE print $type_enregistrement.$separator; //NOCL print $soc->code_client.$separator; @@ -1193,15 +1194,15 @@ class AccountancyExport //LIBI print $separator; //TITR - print $separator; + print $separator; //RSSO print $soc->nom.$separator; //CAD1 - print $address[0].$separator; + print $address[0].$separator; //CAD2 - print $address[1].$separator; + print $address[1].$separator; //CAD3 - print $address[2].$separator; + print $address[2].$separator; //COPO print $soc->zip.$separator; //BUDI @@ -1223,7 +1224,7 @@ class AccountancyExport //COMM print $separator; //SIRE - print str_replace(" ", "", $soc->siret).$separator; + print str_replace(" ", "", $soc->siret).$separator; //RIBP print $separator; //DOBQ @@ -1486,15 +1487,15 @@ class AccountancyExport * * @param string $str Original string to encode and optionaly truncate * @param integer $size Truncate string after $size characters - * @return string String encoded in Windows-1251 charset + * @return string String encoded in Windows-1251 charset */ public static function toAnsi($str, $size = -1) - { + { $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251'); - if ($retVal >= 0 && $size >= 0) - { - $retVal = mb_substr($retVal, 0, $size, 'Windows-1251'); - } - return $retVal; + if ($retVal >= 0 && $size >= 0) + { + $retVal = mb_substr($retVal, 0, $size, 'Windows-1251'); + } + return $retVal; } } diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index c2f3468016c..193a03f1726 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -28,10 +28,10 @@ */ class AccountancySystem { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -44,13 +44,13 @@ class AccountancySystem public $rowid; /** - * @var int ID - */ + * @var int ID + */ public $fk_pcg_version; - /** - * @var string pcg type - */ + /** + * @var string pcg type + */ public $pcg_type; /** @@ -59,18 +59,18 @@ class AccountancySystem public $numero; /** - * @var string Accountancy System label - */ - public $label; + * @var string Accountancy System label + */ + public $label; - /** - * @var string account number - */ + /** + * @var string account number + */ public $account_number; - /** - * @var string account parent - */ + /** + * @var string account parent + */ public $account_parent; /** @@ -78,10 +78,10 @@ class AccountancySystem * * @param DoliDB $db handler */ - public function __construct($db) - { + public function __construct($db) + { $this->db = $db; - } + } /** @@ -93,42 +93,42 @@ class AccountancySystem */ public function fetch($rowid = 0, $ref = '') { - global $conf; + global $conf; - if ($rowid > 0 || $ref) - { - $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; - $sql .= " WHERE"; - if ($rowid) { - $sql .= " a.rowid = ".((int) $rowid); - } elseif ($ref) { - $sql .= " a.pcg_version = '".$this->db->escape($ref)."'"; - } + if ($rowid > 0 || $ref) + { + $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; + $sql .= " WHERE"; + if ($rowid) { + $sql .= " a.rowid = ".((int) $rowid); + } elseif ($ref) { + $sql .= " a.pcg_version = '".$this->db->escape($ref)."'"; + } - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); - if ($obj) { - $this->id = $obj->rowid; - $this->rowid = $obj->rowid; - $this->pcg_version = $obj->pcg_version; - $this->ref = $obj->pcg_version; - $this->label = $obj->label; - $this->active = $obj->active; + if ($obj) { + $this->id = $obj->rowid; + $this->rowid = $obj->rowid; + $this->pcg_version = $obj->pcg_version; + $this->ref = $obj->pcg_version; + $this->label = $obj->label; + $this->active = $obj->active; - return $this->id; - } else { - return 0; - } - } else { - $this->error = "Error ".$this->db->lasterror(); - $this->errors[] = "Error ".$this->db->lasterror(); - } - } - return -1; + return $this->id; + } else { + return 0; + } + } else { + $this->error = "Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); + } + } + return -1; } @@ -138,8 +138,8 @@ class AccountancySystem * @param User $user making insert * @return int if KO, Id of line if OK */ - public function create($user) - { + public function create($user) + { $now = dol_now(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system"; @@ -165,6 +165,6 @@ class AccountancySystem dol_syslog($this->error, LOG_ERR); } - return $result; - } + return $result; + } } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 199899f89d5..ebf397c2dfd 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -74,35 +74,35 @@ class AccountingAccount extends CommonObject public $rowid; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * @var string pcg version - */ + * @var string pcg version + */ public $fk_pcg_version; - /** - * @var string pcg type - */ + /** + * @var string pcg type + */ public $pcg_type; - /** - * @var string account number - */ + /** + * @var string account number + */ public $account_number; - /** - * @var int ID parent account - */ + /** + * @var int ID parent account + */ public $account_parent; - /** - * @var int ID category account - */ + /** + * @var int ID category account + */ public $account_category; /** @@ -110,10 +110,10 @@ class AccountingAccount extends CommonObject */ public $status; - /** - * @var string Label of account - */ - public $label; + /** + * @var string Label of account + */ + public $label; /** * @var string Label short of account @@ -121,19 +121,19 @@ class AccountingAccount extends CommonObject public $labelshort; /** - * @var int ID - */ - public $fk_user_author; + * @var int ID + */ + public $fk_user_author; - /** - * @var int ID - */ - public $fk_user_modif; + /** + * @var int ID + */ + public $fk_user_modif; /** * @var int active (duplicate with status) */ - public $active; + public $active; /** * @var int reconcilable @@ -145,13 +145,13 @@ class AccountingAccount extends CommonObject * * @param DoliDB $db Database handle */ - public function __construct($db) - { + public function __construct($db) + { global $conf; $this->db = $db; $this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; // Used to add a filter in Form::showrefnav method - } + } /** * Load record in memory @@ -162,7 +162,7 @@ class AccountingAccount extends CommonObject * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code). * @return int <0 if KO, 0 if not found, Id of record if OK and found */ - public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') + public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') { global $conf; @@ -182,7 +182,7 @@ class AccountingAccount extends CommonObject $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$this->db->escape($conf->global->CHARTOFACCOUNTS).')'; } if (!empty($limittoachartaccount)) { - $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; + $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; } dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); @@ -229,8 +229,8 @@ class AccountingAccount extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - public function create($user, $notrigger = 0) - { + public function create($user, $notrigger = 0) + { global $conf; $error = 0; $now = dol_now(); @@ -318,7 +318,7 @@ class AccountingAccount extends CommonObject $this->db->commit(); return $this->id; } - } + } /** * Update record @@ -366,8 +366,8 @@ class AccountingAccount extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function checkUsage() - { + public function checkUsage() + { global $langs; $sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet"; @@ -400,8 +400,8 @@ class AccountingAccount extends CommonObject * @param int $notrigger 0=triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function delete($user, $notrigger = 0) - { + public function delete($user, $notrigger = 0) + { $error = 0; $result = $this->checkUsage(); @@ -436,9 +436,9 @@ class AccountingAccount extends CommonObject } else { return -1; } - } + } - /** + /** * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto @@ -446,28 +446,29 @@ class AccountingAccount extends CommonObject * @param int $nourl 1=Disable url * @param string $moretitle Add more text to title tooltip * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) * @param string $option 'ledger', 'journals', 'accountcard' * @return string String with URL */ - public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') { - global $langs, $conf, $user; + global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; + $url = ''; if (empty($option) || $option == 'ledger') { - $url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; + $url = DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start='.urlencode($this->account_number).'&search_accountancy_code_end='.urlencode($this->account_number); $labelurl = $langs->trans("ShowAccountingAccountInLedger"); } elseif ($option == 'journals') { - $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; + $url = DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?search_accountancy_code_start='.urlencode($this->account_number).'&search_accountancy_code_end='.urlencode($this->account_number); $labelurl = $langs->trans("ShowAccountingAccountInJournals"); } elseif ($option == 'accountcard') { - $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; + $url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.urlencode($this->id); $labelurl = $langs->trans("ShowAccountingAccount"); } @@ -523,7 +524,7 @@ class AccountingAccount extends CommonObject if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $linkstart.$label_link.$linkend; return $result; - } + } /** * Information on record @@ -531,8 +532,8 @@ class AccountingAccount extends CommonObject * @param int $id of record * @return void */ - public function info($id) - { + public function info($id) + { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a'; $sql .= ' WHERE a.rowid = '.$id; @@ -567,18 +568,18 @@ class AccountingAccount extends CommonObject * Deactivate an account (for status active or status reconcilable) * * @param int $id Id - * @param int $mode 0=field active, 1=field reconcilable + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ - public function accountDeactivate($id, $mode = 0) - { + public function accountDeactivate($id, $mode = 0) + { $result = $this->checkUsage(); $fieldtouse = 'active'; - if ($mode == 1) - { + if ($mode == 1) + { $fieldtouse = 'reconcilable'; - } + } if ($result > 0) { $this->db->begin(); @@ -603,26 +604,26 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Account activated * * @param int $id Id - * @param int $mode 0=field active, 1=field reconcilable + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ - public function account_activate($id, $mode = 0) - { - // phpcs:enable + public function account_activate($id, $mode = 0) + { + // phpcs:enable $this->db->begin(); - if ($mode == 0) - { - $fieldtouse = 'active'; - } elseif ($mode == 1) - { - $fieldtouse = 'reconcilable'; - } + if ($mode == 0) + { + $fieldtouse = 'active'; + } elseif ($mode == 1) + { + $fieldtouse = 'reconcilable'; + } $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account "; $sql .= "SET ".$fieldtouse." = '1'"; @@ -630,15 +631,15 @@ class AccountingAccount extends CommonObject dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); - if ($result) { + if ($result) { $this->db->commit(); return 1; - } else { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; - } - } + } + } /** @@ -652,7 +653,7 @@ class AccountingAccount extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -662,7 +663,7 @@ class AccountingAccount extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->loadLangs(array("users")); diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 882eee71769..c002abf2a89 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -56,29 +56,29 @@ class AccountingJournal extends CommonObject */ public $rowid; - /** - * @var string Accounting journal code - */ + /** + * @var string Accounting journal code + */ public $code; /** - * @var string Accounting Journal label - */ - public $label; + * @var string Accounting Journal label + */ + public $label; - /** - * @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new - */ - public $nature; + /** + * @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new + */ + public $nature; - /** - * @var int is active or not - */ + /** + * @var int is active or not + */ public $active; - /** - * @var array array of lines - */ + /** + * @var array array of lines + */ public $lines; /** @@ -86,10 +86,10 @@ class AccountingJournal extends CommonObject * * @param DoliDB $db Database handle */ - public function __construct($db) - { - $this->db = $db; - } + public function __construct($db) + { + $this->db = $db; + } /** * Load an object from database @@ -155,8 +155,8 @@ class AccountingJournal extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { $sql = "SELECT rowid, code, label, nature, active"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter @@ -284,7 +284,7 @@ class AccountingJournal extends CommonObject return $this->LibType($this->nature, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return type of an accounting journal * @@ -294,7 +294,7 @@ class AccountingJournal extends CommonObject */ public function LibType($nature, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->loadLangs(array("accountancy")); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index f5f4bf80221..505c51d27fe 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -768,10 +768,11 @@ class BookKeeping extends CommonObject * @param int $offset offset limit * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) + * @param int $option option (0: general account or 1: subaccount) * * @return int <0 if KO, >=0 if OK */ - public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0) { global $conf; @@ -836,7 +837,13 @@ class BookKeeping extends CommonObject $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } // Affichage par compte comptable - $sql .= ' ORDER BY t.numero_compte ASC'; + if (!empty($option)) { + $sql .= ' AND t.subledger_account IS NOT NULL'; + $sql .= ' ORDER BY t.subledger_account ASC'; + } else { + $sql .= ' ORDER BY t.numero_compte ASC'; + } + if (!empty($sortfield)) { $sql .= ', '.$sortfield.' '.$sortorder; } @@ -1530,14 +1537,14 @@ class BookKeeping extends CommonObject $this->label_compte = 'Customer'; $this->label_operation = 'Sales of pea'; $this->debit = 99.9; - $this->credit = ''; - $this->montant = ''; + $this->credit = 0.0; + $this->amount = 0.0; $this->sens = 'D'; $this->fk_user_author = $user->id; - $this->import_key = ''; + $this->import_key = '20201027'; $this->code_journal = 'VT'; $this->journal_label = 'Journal de vente'; - $this->piece_num = ''; + $this->piece_num = 1234; $this->date_creation = $now; } diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php index 808ccfba0ef..1013ad1b6ce 100644 --- a/htdocs/accountancy/closure/validate.php +++ b/htdocs/accountancy/closure/validate.php @@ -63,24 +63,24 @@ $year_current = $year_start; if ($action == 'validate') { - $now = dol_now(); + $now = dol_now(); - // Update database - $db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " SET b.date_validated = '".$db->idate($now)."'"; - $sql .= ' WHERE b.date_validated IS NULL'; + // Update database + $db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql .= " SET b.date_validated = '".$db->idate($now)."'"; + $sql .= ' WHERE b.date_validated IS NULL'; - dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); - $resql = $db->query($sql); - if (!$resql1) { - $error++; - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } else { - $db->commit(); - } - // End clean database + dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); + $resql = $db->query($sql); + if (!$resql1) { + $error++; + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $db->commit(); + } + // End clean database } @@ -135,8 +135,8 @@ if ($resql) { while ($row = $db->fetch_row($resql)) { for ($i = 1; $i <= 12; $i++) { print '
'.$row[$i].'

'; - print ''; - print '
'.$row[13].'
'; @@ -137,7 +137,7 @@ if (!empty($id)) { print ''; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index a06d2f25d8c..eb2743258d7 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -357,12 +357,6 @@ if ($result) { print ''.$langs->trans("DescVentilTodoCustomer").'

'; - /*$topicmail="Information"; - $modelmail="project"; - $objecttmp=new Project($db); - $trackid='prj'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';*/ - if ($msg) print $msg.'
'; $moreforfilter = ''; diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index ab02592f6b8..67c790a9c36 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -121,7 +121,7 @@ if (!empty($id)) { print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_accountancy'); - dol_fiche_head(); + print dol_get_fiche_head(); print ''; @@ -146,7 +146,7 @@ if (!empty($id)) { print ''; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index f99f1148044..a6cf6f2fc14 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -166,7 +166,7 @@ print ''."\n"; + print ''."\n"; } @@ -208,7 +208,7 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { } -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index a7e7a6f3634..2e74fdde9be 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -65,8 +65,8 @@ $result = $object->fetch($id); if ($result > 0) { $object->fetch_thirdparty(); - $adht = new AdherentType($db); - $result = $adht->fetch($object->typeid); + $adht = new AdherentType($db); + $result = $adht->fetch($object->typeid); } @@ -79,17 +79,17 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $actioncode = ''; - $search_agenda_label = ''; - } + $search_agenda_label = ''; + } } @@ -118,7 +118,7 @@ if ($object->id > 0) { if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = member_prepare_head($object); - dol_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user'); + print dol_get_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user'); $linkback = ''.$langs->trans("BackToList").''; @@ -133,34 +133,34 @@ if ($object->id > 0) { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); - //print '
'; - //print '
'; + //print '
'; + //print '
'; $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 (!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 (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - print '
'; + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + print '
'; - $param = '&id='.$id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + $param = '&id='.$id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); + print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; - // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); - } + // TODO Replace this with same code than into list.php + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } } // End of page diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index aa9797959a7..46c4b07b57c 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -27,15 +27,15 @@ */ abstract class ActionsAdherentCardCommon { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $dirmodule; - public $targetmodule; - public $canvas; - public $card; + public $dirmodule; + public $targetmodule; + public $canvas; + public $card; //! Template container public $tpl = array(); @@ -54,52 +54,52 @@ abstract class ActionsAdherentCardCommon /** - * Get object + * Get object * - * @param int $id Object id - * @return object Object loaded - */ - public function getObject($id) - { - //$ret = $this->getInstanceDao(); + * @param int $id Object id + * @return object Object loaded + */ + public function getObject($id) + { + //$ret = $this->getInstanceDao(); - /*if (is_object($this->object) && method_exists($this->object,'fetch')) + /*if (is_object($this->object) && method_exists($this->object,'fetch')) { if (! empty($id)) $this->object->fetch($id); } else {*/ - $object = new Adherent($this->db); - if (!empty($id)) $object->fetch($id); - $this->object = $object; - //} - } + $object = new Adherent($this->db); + if (!empty($id)) $object->fetch($id); + $this->object = $object; + //} + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set content of ->tpl array, to use into template - * - * @param string $action Type of action - * @param int $id Id - * @return string HTML output - */ - public function assign_values(&$action, $id) - { - // phpcs:enable - global $conf, $langs, $user, $canvas; - global $form, $formcompany, $objsoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set content of ->tpl array, to use into template + * + * @param string $action Type of action + * @param int $id Id + * @return string HTML output + */ + public function assign_values(&$action, $id) + { + // phpcs:enable + global $conf, $langs, $user, $canvas; + global $form, $formcompany, $objsoc; - if ($action == 'add' || $action == 'update') $this->assign_post(); + if ($action == 'add' || $action == 'update') $this->assign_post(); - foreach ($this->object as $key => $value) { - $this->tpl[$key] = $value; - } + foreach ($this->object as $key => $value) { + $this->tpl[$key] = $value; + } - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; - if ($action == 'create' || $action == 'edit') { - if ($conf->use_javascript_ajax) { + if ($action == 'create' || $action == 'edit') { + if ($conf->use_javascript_ajax) { $this->tpl['ajax_selectcountry'] = "\n".''."\n"; } - if (is_object($objsoc) && $objsoc->id > 0) { - $this->tpl['company'] = $objsoc->getNomUrl(1); - $this->tpl['company_id'] = $objsoc->id; - } else { - $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); - } + if (is_object($objsoc) && $objsoc->id > 0) { + $this->tpl['company'] = $objsoc->getNomUrl(1); + $this->tpl['company_id'] = $objsoc->id; + } else { + $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); + } - // Civility - $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); + // Civility + $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); - // Predefined with third party - if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) { - if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; - if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; - if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; - if (dol_strlen(trim($this->object->phone_perso)) == 0) $this->object->phone_perso = $objsoc->phone; - if (dol_strlen(trim($this->object->phone_mobile)) == 0) $this->object->phone_mobile = $objsoc->phone_mobile; - if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; - } + // Predefined with third party + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) { + if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; + if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; + if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; + if (dol_strlen(trim($this->object->phone_perso)) == 0) $this->object->phone_perso = $objsoc->phone; + if (dol_strlen(trim($this->object->phone_mobile)) == 0) $this->object->phone_mobile = $objsoc->phone_mobile; + if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; + } - // Zip - $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + // Zip + $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); - // Town - $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + // Town + $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; + if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; - // Country - $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); - $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + // Country + $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); + $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; - if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - // State - if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); - else $this->tpl['select_state'] = $countrynotdefined; + // State + if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); + else $this->tpl['select_state'] = $countrynotdefined; - // Physical or Moral - $selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral")); - $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0); - } + // Physical or Moral + $selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral")); + $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0); + } - if ($action == 'view' || $action == 'edit' || $action == 'delete') { - // Emailing - if (!empty($conf->mailing->enabled)) { + if ($action == 'view' || $action == 'edit' || $action == 'delete') { + // Emailing + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); } - // Dolibarr user - if ($this->object->user_id) { + // Dolibarr user + if ($this->object->user_id) { $dolibarr_user = new User($this->db); $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); - } + } - if ($action == 'view' || $action == 'delete') { - $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); + if ($action == 'view' || $action == 'delete') { + $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); - if ($this->object->socid > 0) { - $objsoc = new Societe($this->db); + if ($this->object->socid > 0) { + $objsoc = new Societe($this->db); - $objsoc->fetch($this->object->socid); - $this->tpl['company'] = $objsoc->getNomUrl(1); - } else { - $this->tpl['company'] = $langs->trans("AdherentNotLinkedToThirdParty"); - } + $objsoc->fetch($this->object->socid); + $this->tpl['company'] = $objsoc->getNomUrl(1); + } else { + $this->tpl['company'] = $langs->trans("AdherentNotLinkedToThirdParty"); + } - $this->tpl['civility'] = $this->object->getCivilityLabel(); + $this->tpl['civility'] = $this->object->getCivilityLabel(); - $this->tpl['address'] = dol_nl2br($this->object->address); + $this->tpl['address'] = dol_nl2br($this->object->address); - $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); + $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); - $img = picto_from_langcode($this->object->country_code); - $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; + $img = picto_from_langcode($this->object->country_code); + $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; - $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); + $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); - $this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy); + $this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy); - $this->tpl['note'] = nl2br($this->object->note); - } + $this->tpl['note'] = nl2br($this->object->note); + } - if ($action == 'create_user') { - // Full firstname and lastname separated with a dot : firstname.lastname - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $login = dol_buildlogin($this->object->lastname, $this->object->firstname); + if ($action == 'create_user') { + // Full firstname and lastname separated with a dot : firstname.lastname + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $login = dol_buildlogin($this->object->lastname, $this->object->firstname); - $generated_password = getRandomPassword(false); - $password = $generated_password; + $generated_password = getRandomPassword(false); + $password = $generated_password; - // Create a form array - $formquestion = array( - array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), - array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); + // Create a form array + $formquestion = array( + array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), + array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); - $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateAdherent"), "confirm_create_user", $formquestion, 'no'); - } - } + $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateAdherent"), "confirm_create_user", $formquestion, 'no'); + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Assign POST values into object - * - * @return string HTML output - */ - private function assign_post() - { - // phpcs:enable - global $langs, $mysoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Assign POST values into object + * + * @return string HTML output + */ + private function assign_post() + { + // phpcs:enable + global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; - $this->object->fk_soc = $_POST["fk_soc"]; - $this->object->lastname = $_POST["lastname"]; - $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; - $this->object->email = $_POST["email"]; - $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->fk_soc = $_POST["fk_soc"]; + $this->object->lastname = $_POST["lastname"]; + $this->object->firstname = $_POST["firstname"]; + $this->object->civility_id = $_POST["civility_id"]; + $this->object->address = $_POST["address"]; + $this->object->zip = $_POST["zipcode"]; + $this->object->town = $_POST["town"]; + $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; + $this->object->state_id = $_POST["state_id"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; + $this->object->email = $_POST["email"]; + $this->object->note = $_POST["note"]; + $this->object->canvas = $_POST["canvas"]; - // We set country_id, and country_code label of the chosen country - if ($this->object->country_id) { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; - $resql = $this->db->query($sql); - if ($resql) { - $obj = $this->db->fetch_object($resql); + // We set country_id, and country_code label of the chosen country + if ($this->object->country_id) { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_object($resql); - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle; - } else { - dol_print_error($this->db); - } - } - } + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle; + } else { + dol_print_error($this->db); + } + } + } } diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index db2473c55d9..43d6622f8c9 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -31,21 +31,21 @@ include_once DOL_DOCUMENT_ROOT.'/adherents/canvas/actions_adherentcard_common.cl class ActionsAdherentCardDefault extends ActionsAdherentCardCommon { /** - * Constructor - * - * @param DoliDB $db Handler acces data base - * @param string $dirmodule Name of directory of module - * @param string $targetmodule Name of directory of module where canvas is stored - * @param string $canvas Name of canvas - * @param string $card Name of tab (sub-canvas) + * Constructor + * + * @param DoliDB $db Handler acces data base + * @param string $dirmodule Name of directory of module + * @param string $targetmodule Name of directory of module where canvas is stored + * @param string $canvas Name of canvas + * @param string $card Name of tab (sub-canvas) */ public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) { - $this->db = $db; - $this->dirmodule = $dirmodule; - $this->targetmodule = $targetmodule; - $this->canvas = $canvas; - $this->card = $card; + $this->db = $db; + $this->dirmodule = $dirmodule; + $this->targetmodule = $targetmodule; + $this->canvas = $canvas; + $this->card = $card; } /** @@ -67,7 +67,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -77,47 +77,47 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon */ public function assign_values(&$action, $id) { - // phpcs:enable + // phpcs:enable global $limit, $offset, $sortfield, $sortorder; global $conf, $db, $langs, $user; global $form; $ret = $this->getObject($id); - parent::assign_values($action, $id); + parent::assign_values($action, $id); - $this->tpl['title'] = $this->getTitle($action); - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['title'] = $this->getTitle($action); + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; if ($action == 'view') { - // Card header - $head = member_prepare_head($this->object); - $title = $this->getTitle($action); + // Card header + $head = member_prepare_head($this->object); + $title = $this->getTitle($action); - $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent'); - $this->tpl['showend'] = dol_get_fiche_end(); + $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent'); + $this->tpl['showend'] = dol_get_fiche_end(); - $objsoc = new Societe($db); - $objsoc->fetch($this->object->socid); + $objsoc = new Societe($db); + $objsoc->fetch($this->object->socid); - $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); - $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); - } else { + $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); + } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->adherent->supprimer) { - $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); - } + if ($action == 'delete' && $user->rights->adherent->supprimer) { + $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); + } } if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); + $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -129,11 +129,11 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon */ public function LoadListDatas($limit, $offset, $sortfield, $sortorder) { - // phpcs:enable + // phpcs:enable global $conf, $langs; - //$this->getFieldList(); + //$this->getFieldList(); - $this->list_datas = array(); + $this->list_datas = array(); } } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index 8789b2fcb34..539e174681f 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php @@ -118,21 +118,21 @@ if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['acti control->tpl['showend']; if (empty($user->socid)) { - echo '
'; + echo '
'; - if ($user->rights->adherent->creer) { - echo ''.$langs->trans('Modify').''; - } + if ($user->rights->adherent->creer) { + echo ''.$langs->trans('Modify').''; + } - if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { - echo ''.$langs->trans("CreateDolibarrLogin").''; - } + if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { + echo ''.$langs->trans("CreateDolibarrLogin").''; + } - if ($user->rights->adherent->supprimer) { - echo ''.$langs->trans('Delete').''; - } + if ($user->rights->adherent->supprimer) { + echo ''.$langs->trans('Delete').''; + } - echo '

'; + echo '

'; } echo $this->control->tpl['actionstodo']; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index cd432aa12d6..fe6f27ef8b6 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -4,9 +4,9 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2012 Marcos García - * Copyright (C) 2012-2018 Philippe Grand + * Copyright (C) 2012-2020 Philippe Grand * Copyright (C) 2015-2018 Alexandre Spangaro - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -191,6 +191,9 @@ if (empty($reshook)) { if ($result < 0) { $langs->load("errors"); setEventMessages($langs->trans($nuser->error), null, 'errors'); + } else { + setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs'); + $action = ''; } } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -218,7 +221,7 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $birthdate = ''; - if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) + if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) { $birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); } @@ -833,7 +836,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; if ($backtopage) print ''; - dol_fiche_head(''); + print dol_get_fiche_head(''); print ''; print ''; @@ -969,7 +972,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print "
\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1058,7 +1061,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; if ($backtopage) print ''; - dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); + print dol_get_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); print ''; @@ -1229,7 +1232,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1268,11 +1271,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { */ $head = member_prepare_head($object); - dol_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user'); + print dol_get_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user'); // Confirm create user if ($action == 'create_user') { - $login = $object->login; + $login = (GETPOSTISSET('login') ? GETPOST('login', 'alphanohtml') : $object->login); if (empty($login)) { // Full firstname and name separated with a dot : firstname.name include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -1561,7 +1564,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', ''); } else { if ($object->user_id) { - $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none'); + $linkeduser = new User($db); + $linkeduser->fetch($object->user_id); + print $linkeduser->getNomUrl(-1); } else { print $langs->trans("NoDolibarrAccess"); } @@ -1608,7 +1613,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "
\n"; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* @@ -1701,13 +1706,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } - // Delete - if ($user->rights->adherent->supprimer) { - print '\n"; - } else { - print '
'.$langs->trans("Delete")."
"; - } - // Action SPIP if (!empty($conf->mailmanspip->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) { $isinspip = $mailmanspip->is_in_spip($object); @@ -1719,6 +1717,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '\n"; } } + + // Delete + if ($user->rights->adherent->supprimer) { + print '\n"; + } else { + print '
'.$langs->trans("Delete")."
"; + } } } print ''; diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 958750178f1..b62f58117a2 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -56,163 +56,163 @@ $extrafields->fetch_name_optionals_label($object->table_element); */ if ($mode == 'cardlogin' && empty($foruserlogin)) { - $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")); + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")); } if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { - $arrayofmembers = array(); + $arrayofmembers = array(); - // request taking into account member with up to date subscriptions - $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; - $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; - $sql .= " t.libelle as type,"; - $sql .= " c.code as country_code, c.label as country"; - // Add fields from extrafields - if (!empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); - $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; - $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; - $sql .= " AND d.entity IN (".getEntity('adherent').")"; - if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; - if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; - $sql .= " ORDER BY d.rowid ASC"; + // request taking into account member with up to date subscriptions + $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; + $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; + $sql .= " t.libelle as type,"; + $sql .= " c.code as country_code, c.label as country"; + // Add fields from extrafields + if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; + $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; + $sql .= " AND d.entity IN (".getEntity('adherent').")"; + if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; + if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; + $sql .= " ORDER BY d.rowid ASC"; - dol_syslog("Search members", LOG_DEBUG); - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); + dol_syslog("Search members", LOG_DEBUG); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); - if ($objp->country == '-') $objp->country = ''; + if ($objp->country == '-') $objp->country = ''; - $adherentstatic->id = $objp->rowid; - $adherentstatic->lastname = $objp->lastname; - $adherentstatic->firstname = $objp->firstname; + $adherentstatic->id = $objp->rowid; + $adherentstatic->lastname = $objp->lastname; + $adherentstatic->firstname = $objp->firstname; - // Format extrafield so they can be parsed in function complete_substitutions_array - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $adherentstatic->array_options = array(); - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $tmpkey = 'options_'.$key; - if (!empty($objp->$tmpkey)) { - $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey; - } - //if (!empty($objp->$key)) - // $objp->array_options[$tmpkey] = $objp->$key; - //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; - } - } + // Format extrafield so they can be parsed in function complete_substitutions_array + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $adherentstatic->array_options = array(); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $tmpkey = 'options_'.$key; + if (!empty($objp->$tmpkey)) { + $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey; + } + //if (!empty($objp->$key)) + // $objp->array_options[$tmpkey] = $objp->$key; + //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; + } + } - // List of values to scan for a replacement - $substitutionarray = array( - '__ID__'=>$objp->rowid, - '__LOGIN__'=>$objp->login, - '__FIRSTNAME__'=>$objp->firstname, - '__LASTNAME__'=>$objp->lastname, - '__FULLNAME__'=>$adherentstatic->getFullName($langs), - '__COMPANY__'=>$objp->company, - '__ADDRESS__'=>$objp->address, - '__ZIP__'=>$objp->zip, - '__TOWN__'=>$objp->town, - '__COUNTRY__'=>$objp->country, - '__COUNTRY_CODE__'=>$objp->country_code, - '__EMAIL__'=>$objp->email, - '__BIRTH__'=>dol_print_date($objp->birth, 'day'), - '__TYPE__'=>$objp->type, - '__YEAR__'=>$year, - '__MONTH__'=>$month, - '__DAY__'=>$day, - '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, - '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" - ); - complete_substitutions_array($substitutionarray, $langs, $adherentstatic); + // List of values to scan for a replacement + $substitutionarray = array( + '__ID__'=>$objp->rowid, + '__LOGIN__'=>$objp->login, + '__FIRSTNAME__'=>$objp->firstname, + '__LASTNAME__'=>$objp->lastname, + '__FULLNAME__'=>$adherentstatic->getFullName($langs), + '__COMPANY__'=>$objp->company, + '__ADDRESS__'=>$objp->address, + '__ZIP__'=>$objp->zip, + '__TOWN__'=>$objp->town, + '__COUNTRY__'=>$objp->country, + '__COUNTRY_CODE__'=>$objp->country_code, + '__EMAIL__'=>$objp->email, + '__BIRTH__'=>dol_print_date($objp->birth, 'day'), + '__TYPE__'=>$objp->type, + '__YEAR__'=>$year, + '__MONTH__'=>$month, + '__DAY__'=>$day, + '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, + '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" + ); + complete_substitutions_array($substitutionarray, $langs, $adherentstatic); - // For business cards - if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { - $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); - $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); - $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); - $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); + // For business cards + if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { + $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); + $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); + $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); + $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); - if (is_numeric($foruserid) || $foruserlogin) { - $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; - if ($nb <= 0) $nb = 1; // Protection to avoid empty page + if (is_numeric($foruserid) || $foruserlogin) { + $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; + if ($nb <= 0) $nb = 1; // Protection to avoid empty page - for ($j = 0; $j < $nb; $j++) { - $arrayofmembers[] = array( - 'textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo - ); - } - } else { - $arrayofmembers[] = array( - 'textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo - ); - } - } + for ($j = 0; $j < $nb; $j++) { + $arrayofmembers[] = array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo + ); + } + } else { + $arrayofmembers[] = array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo + ); + } + } - // For labels - if ($mode == 'label') { - if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; - $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); - $textheader = ''; - $textfooter = ''; - $textright = ''; + // For labels + if ($mode == 'label') { + if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; + $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); + $textheader = ''; + $textfooter = ''; + $textright = ''; - $arrayofmembers[] = array('textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo); - } + $arrayofmembers[] = array('textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo); + } - $i++; - } + $i++; + } - // Build and output PDF - if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { - if (!count($arrayofmembers)) { - $mesg = $langs->trans("ErrorRecordNotFound"); - } - if (empty($model) || $model == '-1') { - $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE")); - } - if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs); - } elseif ($mode == 'label') { - if (!count($arrayofmembers)) { - $mesg = $langs->trans("ErrorRecordNotFound"); - } - if (empty($modellabel) || $modellabel == '-1') { - $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); - } - if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); - } + // Build and output PDF + if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { + if (!count($arrayofmembers)) { + $mesg = $langs->trans("ErrorRecordNotFound"); + } + if (empty($model) || $model == '-1') { + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE")); + } + if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs); + } elseif ($mode == 'label') { + if (!count($arrayofmembers)) { + $mesg = $langs->trans("ErrorRecordNotFound"); + } + if (empty($modellabel) || $modellabel == '-1') { + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); + } + if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); + } - if ($result <= 0) { - dol_print_error('', $result); - } - } else { - dol_print_error($db); - } + if ($result <= 0) { + dol_print_error('', $result); + } + } else { + dol_print_error($db); + } - if (!$mesg) { - $db->close(); - exit; - } + if (!$mesg) { + $db->close(); + exit; + } } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 95ca2017b21..9bedb1a39ca 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Marcos García - * Copyright (C) 2015-2018 Frédéric France + * Copyright (C) 2015-2020 Frédéric France * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2018-2019 Thibault FOUCART @@ -60,6 +60,9 @@ class Adherent extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var string picto + */ public $picto = 'member'; @@ -70,13 +73,19 @@ class Adherent extends CommonObject */ public $login; - //! Clear password in memory + /** + * @var string Clear password in memory + */ public $pass; - //! Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) + /** + * @var string Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) + */ public $pass_indatabase; - //! Encrypted password in database (always defined) + /** + * @var string Encrypted password in database (always defined) + */ public $pass_indatabase_crypted; /** @@ -169,6 +178,11 @@ class Adherent extends CommonObject */ public $phone_perso; + /** + * @var string Professional Phone number + */ + public $phone_pro; + /** * @var string Mobile phone number */ @@ -184,6 +198,9 @@ class Adherent extends CommonObject */ public $poste; + /** + * @var string mor or phy + */ public $morphy; public $public; @@ -191,6 +208,10 @@ class Adherent extends CommonObject // -1:brouillon, 0:resilie, >=1:valide,paye // def in common object //public $status; + + /** + * @var string photo of member + */ public $photo; /** @@ -209,6 +230,9 @@ class Adherent extends CommonObject public $datevalid; + /** + * @var string gender + */ public $gender; public $birth; @@ -258,7 +282,11 @@ class Adherent extends CommonObject */ public $entity; - public $fields = array('rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), + /** + * @var array fields + */ + public $fields = array( + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), 'ref_ext' => array('type' => 'varchar(128)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20), 'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => -1, 'position' => 25), @@ -296,9 +324,10 @@ class Adherent extends CommonObject 'fk_user_valid' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserValidation', 'enabled' => 1, 'visible' => -1, 'position' => 190), 'canvas' => array('type' => 'varchar(32)', 'label' => 'Canvas', 'enabled' => 1, 'visible' => -1, 'position' => 195), 'statut' => array('type' => 'smallint(6)', 'label' => 'Statut', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 500, - 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', -1 => 'MemberStatusResiliatedShort')), + 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', -1 => 'MemberStatusResiliatedShort')), 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 800), - 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 805)); + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 805) + ); /** @@ -407,7 +436,8 @@ class Adherent extends CommonObject $infos .= $langs->transnoentities("Public").": ".yn($this->public); // Substitutions - $substitutionarray = array('__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(), + $substitutionarray = array( + '__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(), '__FIRSTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname : ''), '__LASTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname : ''), '__FULLNAME__' => $msgishtml ? dol_htmlentitiesbr($this->getFullName($langs)) : $this->getFullName($langs), @@ -422,7 +452,8 @@ class Adherent extends CommonObject '__PHONE__' => $msgishtml ? dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone : ''), '__PHONEPRO__' => $msgishtml ? dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso : ''), '__PHONEMOBILE__' => $msgishtml ? dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile : ''), - '__TYPE__' => $msgishtml ? dol_htmlentitiesbr($this->type) : ($this->type ? $this->type : '')); + '__TYPE__' => $msgishtml ? dol_htmlentitiesbr($this->type) : ($this->type ? $this->type : '') + ); complete_substitutions_array($substitutionarray, $langs, $this); @@ -589,8 +620,7 @@ class Adherent extends CommonObject $this->town = ($this->town ? $this->town : $this->town); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(trim($this->lastname)); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(trim($this->firstname)); + $this->setUpperOrLowerCase(); $this->note_public = ($this->note_public ? $this->note_public : $this->note_public); $this->note_private = ($this->note_private ? $this->note_private : $this->note_private); @@ -1320,7 +1350,7 @@ class Adherent extends CommonObject $this->model_pdf = $obj->model_pdf; - // Retreive all extrafield + // Retrieve all extrafield // fetch optionals attributes and labels if ($fetch_optionals) { $this->fetch_optionals(); @@ -1983,7 +2013,8 @@ class Adherent extends CommonObject } $label .= '
'; - $label .= ''.$langs->trans("Member").''; + $label .= img_picto('', $this->picto).' '.$langs->trans("Member").''; + $label .= ' '.$this->getLibStatut(4); if (!empty($this->ref)) $label .= '
'.$langs->trans('Ref').': '.$this->ref; if (!empty($this->firstname) || !empty($this->lastname)) $label .= '
'.$langs->trans('Name').': '.$this->getFullName($langs); if (!empty($this->company)) $label .= '
'.$langs->trans('Company').': '.$this->company; @@ -2275,14 +2306,16 @@ class Adherent extends CommonObject * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @return void + * @return int */ public function initAsSpecimen() { global $user, $langs; + $now = dol_now(); // Initialise parametres $this->id = 0; + $this->entity = 1; $this->specimen = 1; $this->civility_id = 0; $this->lastname = 'DOLIBARR'; @@ -2299,24 +2332,30 @@ class Adherent extends CommonObject $this->country = 'France'; $this->morphy = 'mor'; $this->email = 'specimen@specimen.com'; - $this->socialnetworks = array('skype' => 'skypepseudo', 'twitter' => 'twitterpseudo', 'facebook' => 'facebookpseudo', 'linkedin' => 'linkedinpseudo'); + $this->socialnetworks = array( + 'skype' => 'skypepseudo', + 'twitter' => 'twitterpseudo', + 'facebook' => 'facebookpseudo', + 'linkedin' => 'linkedinpseudo', + ); $this->phone = '0999999999'; $this->phone_perso = '0999999998'; $this->phone_mobile = '0999999997'; - $this->note_private = 'No comment'; - $this->birth = time(); + $this->note_public = 'This is a public note'; + $this->note_private = 'This is a private note'; + $this->birth = $now; $this->photo = ''; $this->public = 1; $this->statut = 0; - $this->datefin = time(); - $this->datevalid = time(); + $this->datefin = $now; + $this->datevalid = $now; $this->typeid = 1; // Id type adherent $this->type = 'Type adherent'; // Libelle type adherent $this->need_subscription = 0; - $this->first_subscription_date = time(); + $this->first_subscription_date = $now; $this->first_subscription_date_start = $this->first_subscription_date; $this->first_subscription_date_end = dol_time_plus_duree($this->first_subscription_date_start, 1, 'y'); $this->first_subscription_amount = 10; @@ -2325,6 +2364,7 @@ class Adherent extends CommonObject $this->last_subscription_date_start = $this->first_subscription_date; $this->last_subscription_date_end = dol_time_plus_duree($this->last_subscription_date_start, 1, 'y'); $this->last_subscription_amount = 10; + return 1; } @@ -2364,6 +2404,7 @@ class Adherent extends CommonObject global $conf, $langs; $info = array(); + $socialnetworks = getArrayOfSocialNetworks(); $keymodified = false; // Object classes @@ -2378,8 +2419,13 @@ class Adherent extends CommonObject } // Possible LDAP KEY (constname => varname) - $ldapkey = array('LDAP_MEMBER_FIELD_FULLNAME' => 'fullname', 'LDAP_MEMBER_FIELD_NAME' => 'lastname', 'LDAP_MEMBER_FIELD_LOGIN' => 'login', 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' => 'login', - 'LDAP_MEMBER_FIELD_MAIL' => 'email'); + $ldapkey = array( + 'LDAP_MEMBER_FIELD_FULLNAME' => 'fullname', + 'LDAP_MEMBER_FIELD_NAME' => 'lastname', + 'LDAP_MEMBER_FIELD_LOGIN' => 'login', + 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' => 'login', + 'LDAP_MEMBER_FIELD_MAIL' => 'email' + ); // Member foreach ($ldapkey as $constname => $varname) { @@ -2399,10 +2445,11 @@ class Adherent extends CommonObject if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; - if ($this->skype && !empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; - if ($this->twitter && !empty($conf->global->LDAP_MEMBER_FIELD_TWITTER)) $info[$conf->global->LDAP_MEMBER_FIELD_TWITTER] = $this->twitter; - if ($this->facebook && !empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; - if ($this->linkedin && !empty($conf->global->LDAP_MEMBER_FIELD_LINKEDIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LINKEDIN] = $this->linkedin; + foreach ($socialnetworks as $key => $value) { + if ($this->socialnetworks[$value['label']] && !empty($conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])})) { + $info[$conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])}] = $this->socialnetworks[$value['label']]; + } + } if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; @@ -2415,8 +2462,12 @@ class Adherent extends CommonObject // When password is modified if (!empty($this->pass)) { - if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte - if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) + if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) { + $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte + } + if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) { + $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) + } } // Set LDAP password if possible elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 94bf34208ff..b5c701f2ad4 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -85,7 +85,6 @@ class AdherentType extends CommonObject /** * @var int Subsription required (0 or 1) - * @since 5.0 */ public $subscription; @@ -95,9 +94,15 @@ class AdherentType extends CommonObject /** @var integer Can vote */ public $vote; - /** @var string Email sent during validation */ + /** @var string Email sent during validation of member */ public $mail_valid; + /** @var string Email sent after recording a new subscription */ + public $mail_subscription = ''; + + /** @var string Email sent after resiliation */ + public $mail_resiliate = ''; + /** @var array Array of members */ public $members = array(); @@ -116,7 +121,7 @@ class AdherentType extends CommonObject } /** - * Load array this->multilangs + * Load array this->multilangs * * @return int <0 if KO, >0 if OK */ @@ -151,7 +156,7 @@ class AdherentType extends CommonObject } /** - * Update or add a translation for a product + * Update or add a translation for this member type * * @param User $user Object user making update * @return int <0 if KO, >0 if OK @@ -236,12 +241,11 @@ class AdherentType extends CommonObject } /** - * Delete a language for this product + * Delete a language for this member type * - * @param string $langtodelete Language code to delete - * @param User $user Object user making delete - * - * @return int <0 if KO, >0 if OK + * @param string $langtodelete Language code to delete + * @param User $user Object user making delete + * @return int <0 if KO, >0 if OK */ public function delMultiLangs($langtodelete, $user) { @@ -268,9 +272,9 @@ class AdherentType extends CommonObject } /** - * Fonction qui permet de creer le status de l'adherent + * Function to create the member type * - * @param User $user User making creation + * @param User $user User making creation * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ @@ -574,7 +578,7 @@ class AdherentType extends CommonObject public function getmorphylib($morphy = '') { global $langs; - if ($morphy == 'phy') { return $langs->trans("Physical"); } elseif ($morphy == 'mor') { return $langs->trans("Moral"); } else return $langs->trans("MorPhy"); + if ($morphy == 'phy') { return $langs->trans("Physical"); } elseif ($morphy == 'mor') { return $langs->trans("Moral"); } else return $langs->trans("MorAndPhy"); //return $morphy; } @@ -591,7 +595,15 @@ class AdherentType extends CommonObject global $langs; $result = ''; - $label = $langs->trans("ShowTypeCard", $this->label); + + $label = ''; + + $label = img_picto('', $this->picto).' '.$langs->trans("MemberType").''; + $label .= ' '.$this->getLibStatut(4); + $label .= '
'.$langs->trans("Label").': '.$this->label; + if (isset($this->subscription)) { + $label .= '
'.$langs->trans("SubscriptionRequired").': '.yn($this->subscription); + } $linkstart = ''; $linkend = ''; @@ -707,7 +719,7 @@ class AdherentType extends CommonObject */ public function initAsSpecimen() { - global $conf, $user, $langs; + global $user; // Initialise parametres $this->id = 0; @@ -735,8 +747,6 @@ class AdherentType extends CommonObject */ public function getMailOnValid() { - global $conf; - if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) { return $this->mail_valid; } @@ -751,8 +761,6 @@ class AdherentType extends CommonObject */ public function getMailOnSubscription() { - global $conf; - // mail_subscription not defined so never used if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) { // Property not yet defined return $this->mail_subscription; @@ -768,8 +776,6 @@ class AdherentType extends CommonObject */ public function getMailOnResiliate() { - global $conf; - // NOTE mail_resiliate not defined so never used if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined return $this->mail_resiliate; diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index d86a9e21d8c..62d0e03e27e 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -32,18 +32,18 @@ include_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; */ class AdherentStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - public $memberid; - public $socid; - public $userid; + public $memberid; + public $socid; + public $userid; - public $from; - public $field; - public $where; + public $from; + public $field; + public $where; /** @@ -51,15 +51,15 @@ class AdherentStats extends Stats * * @param DoliDB $db Database handler * @param int $socid Id third party - * @param int $userid Id user for filter + * @param int $userid Id user for filter */ public function __construct($db, $socid = 0, $userid = 0) { global $user, $conf; $this->db = $db; - $this->socid = $socid; - $this->userid = $userid; + $this->socid = $socid; + $this->userid = $userid; $object = new Subscription($this->db); @@ -74,16 +74,16 @@ class AdherentStats extends Stats if ($this->memberid) { $this->where .= " AND m.rowid = ".$this->memberid; } - //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; + //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; } /** * Return the number of proposition by month for a given year * - * @param int $year Year - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array Array of nb each month + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array of nb each month */ public function getNbByMonth($year, $format = 0) { @@ -95,7 +95,7 @@ class AdherentStats extends Stats $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByMonth($year, $sql, $format); } @@ -103,7 +103,7 @@ class AdherentStats extends Stats /** * Return the number of subscriptions by year * - * @return array Array of nb each year + * @return array Array of nb each year */ public function getNbByYear() { @@ -114,7 +114,7 @@ class AdherentStats extends Stats //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -122,9 +122,9 @@ class AdherentStats extends Stats /** * Return the number of subscriptions by month for a given year * - * @param int $year Year - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array Array of amount each month + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array of amount each month */ public function getAmountByMonth($year, $format = 0) { @@ -136,7 +136,7 @@ class AdherentStats extends Stats $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAmountByMonth($year, $sql, $format); } @@ -144,8 +144,8 @@ class AdherentStats extends Stats /** * Return average amount each month * - * @param int $year Year - * @return array Array of average each month + * @param int $year Year + * @return array Array of average each month */ public function getAverageByMonth($year) { @@ -157,7 +157,7 @@ class AdherentStats extends Stats $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -177,7 +177,7 @@ class AdherentStats extends Stats //if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 230b839f726..6fa3058dca1 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2016 Xebax Christy * Copyright (C) 2017 Regis Houssin * Copyright (C) 2020 Thibault FOUCART + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,477 +33,481 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; */ class Members extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'morphy', - 'typeid' - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'morphy', + 'typeid' + ); - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + } - /** - * Get properties of a member object - * - * Return an array with member informations - * - * @param int $id ID of member - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id) - { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { - throw new RestException(401); - } + /** + * Get properties of a member object + * + * Return an array with member informations + * + * @param int $id ID of member + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id) + { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } - $member = new Adherent($this->db); - $result = $member->fetch($id); - if (!$result) { - throw new RestException(404, 'member not found'); - } + $member = new Adherent($this->db); + if ($id == 0) { + $result = $member->initAsSpecimen(); + } else { + $result = $member->fetch($id); + } + if (!$result) { + throw new RestException(404, 'member not found'); + } - if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id) && $id > 0) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($member); - } + return $this->_cleanObjectDatas($member); + } - /** - * Get properties of a member object by linked thirdparty - * - * Return an array with member informations - * - * @param int $thirdparty ID of third party - * - * @return array|mixed Data without useless information - * - * @url GET thirdparty/{thirdparty} - * - * @throws RestException 401 - * @throws RestException 404 - */ - public function getByThirdparty($thirdparty) - { - if (! DolibarrApiAccess::$user->rights->adherent->lire) { - throw new RestException(401); - } + /** + * Get properties of a member object by linked thirdparty + * + * Return an array with member informations + * + * @param int $thirdparty ID of third party + * + * @return Object Data without useless information + * + * @url GET thirdparty/{thirdparty} + * + * @throws RestException 401 + * @throws RestException 404 + */ + public function getByThirdparty($thirdparty) + { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } - $member = new Adherent($this->db); - $result = $member->fetch('', '', $thirdparty); - if ( ! $result ) { - throw new RestException(404, 'member not found'); - } + $member = new Adherent($this->db); + $result = $member->fetch('', '', $thirdparty); + if (!$result) { + throw new RestException(404, 'member not found'); + } - if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($member); - } + return $this->_cleanObjectDatas($member); + } - /** - * Get properties of a member object by linked thirdparty email - * - * Return an array with member informations - * - * @param string $email Email of third party - * - * @return array|mixed Data without useless information - * - * @url GET thirdparty/email/{email} - * - * @throws RestException 401 - * @throws RestException 404 - */ - public function getByThirdpartyEmail($email) - { - if (! DolibarrApiAccess::$user->rights->adherent->lire) { - throw new RestException(401); - } + /** + * Get properties of a member object by linked thirdparty email + * + * Return an array with member informations + * + * @param string $email Email of third party + * + * @return Object Data without useless information + * + * @url GET thirdparty/email/{email} + * + * @throws RestException 401 + * @throws RestException 404 + */ + public function getByThirdpartyEmail($email) + { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } - $thirdparty = new Societe($this->db); - $result = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); - if ( ! $result ) { - throw new RestException(404, 'thirdparty not found'); - } + $thirdparty = new Societe($this->db); + $result = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); + if (!$result) { + throw new RestException(404, 'thirdparty not found'); + } - $member = new Adherent($this->db); - $result = $member->fetch('', '', $thirdparty->id); - if ( ! $result ) { - throw new RestException(404, 'member not found'); - } + $member = new Adherent($this->db); + $result = $member->fetch('', '', $thirdparty->id); + if (!$result) { + throw new RestException(404, 'member not found'); + } - if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($member); - } + return $this->_cleanObjectDatas($member); + } - /** - * Get properties of a member object by linked thirdparty barcode - * - * Return an array with member informations - * - * @param string $barcode Barcode of third party - * - * @return array|mixed Data without useless information - * - * @url GET thirdparty/barcode/{barcode} - * - * @throws RestException 401 - * @throws RestException 404 - */ - public function getByThirdpartyBarcode($barcode) - { - if (! DolibarrApiAccess::$user->rights->adherent->lire) { - throw new RestException(401); - } + /** + * Get properties of a member object by linked thirdparty barcode + * + * Return an array with member informations + * + * @param string $barcode Barcode of third party + * + * @return Object Data without useless information + * + * @url GET thirdparty/barcode/{barcode} + * + * @throws RestException 401 + * @throws RestException 404 + */ + public function getByThirdpartyBarcode($barcode) + { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } - $thirdparty = new Societe($this->db); - $result = $thirdparty->fetch('', '', '', $barcode); - if ( ! $result ) { - throw new RestException(404, 'thirdparty not found'); - } + $thirdparty = new Societe($this->db); + $result = $thirdparty->fetch('', '', '', $barcode); + if (!$result) { + throw new RestException(404, 'thirdparty not found'); + } - $member = new Adherent($this->db); - $result = $member->fetch('', '', $thirdparty->id); - if ( ! $result ) { - throw new RestException(404, 'member not found'); - } + $member = new Adherent($this->db); + $result = $member->fetch('', '', $thirdparty->id); + if (!$result) { + throw new RestException(404, 'member not found'); + } - if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($member); - } + return $this->_cleanObjectDatas($member); + } - /** - * List members - * - * Get a list of members - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $typeid ID of the type of member + /** + * List members + * + * Get a list of members + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $typeid ID of the type of member * @param int $category Use this param to filter list by category - * @param string $sqlfilters Other criteria to filter answers separated by a comma. - * Example: "(t.ref:like:'SO-%') and ((t.date_creation:<:'20160101') or (t.nature:is:NULL))" - * @return array Array of member objects - * - * @throws RestException - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $category = 0, $sqlfilters = '') - { - global $db, $conf; + * @param string $sqlfilters Other criteria to filter answers separated by a comma. + * Example: "(t.ref:like:'SO-%') and ((t.date_creation:<:'20160101') or (t.nature:is:NULL))" + * @return array Array of member objects + * + * @throws RestException + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $category = 0, $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } - $sql = "SELECT t.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as t"; - if ($category > 0) { + $sql = "SELECT t.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as t"; + if ($category > 0) { $sql .= ", ".MAIN_DB_PREFIX."categorie_member as c"; - } - $sql .= ' WHERE t.entity IN ('.getEntity('adherent').')'; - if (!empty($typeid)) { - $sql .= ' AND t.fk_adherent_type='.$typeid; - } - // Select members of given category - if ($category > 0) { + } + $sql .= ' WHERE t.entity IN ('.getEntity('adherent').')'; + if (!empty($typeid)) { + $sql .= ' AND t.fk_adherent_type='.$typeid; + } + // Select members of given category + if ($category > 0) { $sql .= " AND c.fk_categorie = ".$this->db->escape($category); $sql .= " AND c.fk_member = t.rowid "; - } - // Add sql filters - if ($sqlfilters) { - if (!DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + } + // Add sql filters + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit + 1, $offset); - } + $sql .= $this->db->plimit($limit + 1, $offset); + } - $result = $this->db->query($sql); - if ($result) { - $i = 0; - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) { - $obj = $this->db->fetch_object($result); - $member = new Adherent($this->db); - if ($member->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($member); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve member list : '.$this->db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No member found'); - } + $result = $this->db->query($sql); + if ($result) { + $i = 0; + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { + $obj = $this->db->fetch_object($result); + $member = new Adherent($this->db); + if ($member->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($member); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve member list : '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No member found'); + } - return $obj_ret; - } + return $obj_ret; + } - /** - * Create member object - * - * @param array $request_data Request data - * @return int ID of member - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validate($request_data); + /** + * Create member object + * + * @param array $request_data Request data + * @return int ID of member + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); - $member = new Adherent($this->db); - foreach ($request_data as $field => $value) { - $member->$field = $value; - } - if ($member->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, 'Error creating member', array_merge(array($member->error), $member->errors)); - } - return $member->id; - } + $member = new Adherent($this->db); + foreach ($request_data as $field => $value) { + $member->$field = $value; + } + if ($member->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, 'Error creating member', array_merge(array($member->error), $member->errors)); + } + return $member->id; + } - /** - * Update member - * - * @param int $id ID of member to update - * @param array $request_data Datas - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } + /** + * Update member + * + * @param int $id ID of member to update + * @param array $request_data Datas + * @return Object Updated object + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } - $member = new Adherent($this->db); - $result = $member->fetch($id); - if (!$result) { - throw new RestException(404, 'member not found'); - } + $member = new Adherent($this->db); + $result = $member->fetch($id); + if (!$result) { + throw new RestException(404, 'member not found'); + } - if (!DolibarrApi::_checkAccessToResource('member', $member->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('member', $member->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - // Process the status separately because it must be updated using - // the validate() and resiliate() methods of the class Adherent. - if ($field == 'statut') { - if ($value == '0') { - $result = $member->resiliate(DolibarrApiAccess::$user); - if ($result < 0) { - throw new RestException(500, 'Error when resiliating member: '.$member->error); - } - } elseif ($value == '1') { - $result = $member->validate(DolibarrApiAccess::$user); - if ($result < 0) { - throw new RestException(500, 'Error when validating member: '.$member->error); - } - } - } else { - $member->$field = $value; - } - } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + // Process the status separately because it must be updated using + // the validate() and resiliate() methods of the class Adherent. + if ($field == 'statut') { + if ($value == '0') { + $result = $member->resiliate(DolibarrApiAccess::$user); + if ($result < 0) { + throw new RestException(500, 'Error when resiliating member: '.$member->error); + } + } elseif ($value == '1') { + $result = $member->validate(DolibarrApiAccess::$user); + if ($result < 0) { + throw new RestException(500, 'Error when validating member: '.$member->error); + } + } + } else { + $member->$field = $value; + } + } - // If there is no error, update() returns the number of affected rows - // so if the update is a no op, the return value is zero. - if ($member->update(DolibarrApiAccess::$user) >= 0) { - return $this->get($id); - } else { - throw new RestException(500, $member->error); - } - } + // If there is no error, update() returns the number of affected rows + // so if the update is a no op, the return value is zero. + if ($member->update(DolibarrApiAccess::$user) >= 0) { + return $this->get($id); + } else { + throw new RestException(500, $member->error); + } + } - /** - * Delete member - * - * @param int $id member ID - * @return array - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->adherent->supprimer) { - throw new RestException(401); - } - $member = new Adherent($this->db); - $result = $member->fetch($id); - if (!$result) { - throw new RestException(404, 'member not found'); - } + /** + * Delete member + * + * @param int $id member ID + * @return array + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->adherent->supprimer) { + throw new RestException(401); + } + $member = new Adherent($this->db); + $result = $member->fetch($id); + if (!$result) { + throw new RestException(404, 'member not found'); + } - if (!DolibarrApi::_checkAccessToResource('member', $member->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('member', $member->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!$member->delete($member->id, DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when deleting member'); - } + if (!$member->delete($member->id, DolibarrApiAccess::$user)) { + throw new RestException(401, 'error when deleting member'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'member deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'member deleted' + ) + ); + } - /** - * Validate fields before creating an object - * - * @param array|null $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $member = array(); - foreach (Members::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $member[$field] = $data[$field]; - } - return $member; - } + /** + * Validate fields before creating an object + * + * @param array|null $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $member = array(); + foreach (Members::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $member[$field] = $data[$field]; + } + return $member; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param object $object Object to clean - * @return array Array of cleaned object properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - // Remove the subscriptions because they are handled as a subresource. - unset($object->subscriptions); - unset($object->fk_incoterms); - unset($object->label_incoterms); - unset($object->location_incoterms); - unset($object->fk_delivery_address); - unset($object->shipping_method_id); + // Remove the subscriptions because they are handled as a subresource. + unset($object->subscriptions); + unset($object->fk_incoterms); + unset($object->label_incoterms); + unset($object->location_incoterms); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); - unset($object->total_ht); - unset($object->total_ttc); - unset($object->total_tva); - unset($object->total_localtax1); - unset($object->total_localtax2); + unset($object->total_ht); + unset($object->total_ttc); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); - return $object; - } + return $object; + } - /** - * List subscriptions of a member - * - * Get a list of subscriptions - * - * @param int $id ID of member - * @return array Array of subscription objects - * - * @throws RestException - * - * @url GET {id}/subscriptions - */ - public function getSubscriptions($id) - { - $obj_ret = array(); + /** + * List subscriptions of a member + * + * Get a list of subscriptions + * + * @param int $id ID of member + * @return array Array of subscription objects + * + * @throws RestException + * + * @url GET {id}/subscriptions + */ + public function getSubscriptions($id) + { + $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + throw new RestException(401); + } - $member = new Adherent($this->db); - $result = $member->fetch($id); - if (!$result) { - throw new RestException(404, 'member not found'); - } + $member = new Adherent($this->db); + $result = $member->fetch($id); + if (!$result) { + throw new RestException(404, 'member not found'); + } - $obj_ret = array(); - foreach ($member->subscriptions as $subscription) { - $obj_ret[] = $this->_cleanObjectDatas($subscription); - } - return $obj_ret; - } + $obj_ret = array(); + foreach ($member->subscriptions as $subscription) { + $obj_ret[] = $this->_cleanObjectDatas($subscription); + } + return $obj_ret; + } - /** - * Add a subscription for a member - * - * @param int $id ID of member - * @param int $start_date Start date {@from body} {@type timestamp} - * @param int $end_date End date {@from body} {@type timestamp} - * @param float $amount Amount (may be 0) {@from body} - * @param string $label Label {@from body} - * @return int ID of subscription - * - * @url POST {id}/subscriptions - */ - public function createSubscription($id, $start_date, $end_date, $amount, $label = '') - { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { - throw new RestException(401); - } + /** + * Add a subscription for a member + * + * @param int $id ID of member + * @param int $start_date Start date {@from body} {@type timestamp} + * @param int $end_date End date {@from body} {@type timestamp} + * @param float $amount Amount (may be 0) {@from body} + * @param string $label Label {@from body} + * @return int ID of subscription + * + * @url POST {id}/subscriptions + */ + public function createSubscription($id, $start_date, $end_date, $amount, $label = '') + { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + throw new RestException(401); + } - $member = new Adherent($this->db); - $result = $member->fetch($id); - if (!$result) { - throw new RestException(404, 'member not found'); - } + $member = new Adherent($this->db); + $result = $member->fetch($id); + if (!$result) { + throw new RestException(404, 'member not found'); + } - return $member->subscription($start_date, $amount, 0, '', $label, '', '', '', $end_date); - } + return $member->subscription($start_date, $amount, 0, '', $label, '', '', '', $end_date); + } - /** - * Get categories for a member - * - * @param int $id ID of member - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * - * @return mixed - * - * @url GET {id}/categories - */ + /** + * Get categories for a member + * + * @param int $id ID of member + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * + * @return mixed + * + * @url GET {id}/categories + */ public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { if (!DolibarrApiAccess::$user->rights->categorie->lire) { diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 682fb9d707c..f9f410f34aa 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -27,289 +27,289 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; */ class MembersTypes extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'label', - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'label', + ); - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + } - /** - * Get properties of a member type object - * - * Return an array with member type informations - * - * @param int $id ID of member type - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id) - { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { - throw new RestException(401); - } + /** + * Get properties of a member type object + * + * Return an array with member type informations + * + * @param int $id ID of member type + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id) + { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } - $membertype = new AdherentType($this->db); - $result = $membertype->fetch($id); - if (!$result) { - throw new RestException(404, 'member type not found'); - } + $membertype = new AdherentType($this->db); + $result = $membertype->fetch($id); + if (!$result) { + throw new RestException(404, 'member type not found'); + } - if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($membertype); - } + return $this->_cleanObjectDatas($membertype); + } - /** - * List members types - * - * Get a list of members types - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')" - * @return array Array of member type objects - * - * @throws RestException - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') - { - global $db, $conf; + /** + * List members types + * + * Get a list of members types + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')" + * @return array Array of member type objects + * + * @throws RestException + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } - $sql = "SELECT t.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; - $sql .= ' WHERE t.entity IN ('.getEntity('member_type').')'; + $sql = "SELECT t.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= ' WHERE t.entity IN ('.getEntity('member_type').')'; - // Add sql filters - if ($sqlfilters) { - if (!DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + // Add sql filters + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit + 1, $offset); - } + $sql .= $this->db->plimit($limit + 1, $offset); + } - $result = $this->db->query($sql); - if ($result) { - $i = 0; - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) { - $obj = $this->db->fetch_object($result); - $membertype = new AdherentType($this->db); - if ($membertype->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($membertype); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve member type list : '.$this->db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No member type found'); - } + $result = $this->db->query($sql); + if ($result) { + $i = 0; + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { + $obj = $this->db->fetch_object($result); + $membertype = new AdherentType($this->db); + if ($membertype->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($membertype); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve member type list : '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No member type found'); + } - return $obj_ret; - } + return $obj_ret; + } - /** - * Create member type object - * - * @param array $request_data Request data - * @return int ID of member type - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->adherent->configurer) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validate($request_data); + /** + * Create member type object + * + * @param array $request_data Request data + * @return int ID of member type + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->adherent->configurer) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); - $membertype = new AdherentType($this->db); - foreach ($request_data as $field => $value) { - $membertype->$field = $value; - } - if ($membertype->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, 'Error creating member type', array_merge(array($membertype->error), $membertype->errors)); - } - return $membertype->id; - } + $membertype = new AdherentType($this->db); + foreach ($request_data as $field => $value) { + $membertype->$field = $value; + } + if ($membertype->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, 'Error creating member type', array_merge(array($membertype->error), $membertype->errors)); + } + return $membertype->id; + } - /** - * Update member type - * - * @param int $id ID of member type to update - * @param array $request_data Datas - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->adherent->configurer) { - throw new RestException(401); - } + /** + * Update member type + * + * @param int $id ID of member type to update + * @param array $request_data Datas + * @return int + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->adherent->configurer) { + throw new RestException(401); + } - $membertype = new AdherentType($this->db); - $result = $membertype->fetch($id); - if (!$result) { - throw new RestException(404, 'member type not found'); - } + $membertype = new AdherentType($this->db); + $result = $membertype->fetch($id); + if (!$result) { + throw new RestException(404, 'member type not found'); + } - if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - // Process the status separately because it must be updated using - // the validate() and resiliate() methods of the class AdherentType. - $membertype->$field = $value; - } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + // Process the status separately because it must be updated using + // the validate() and resiliate() methods of the class AdherentType. + $membertype->$field = $value; + } - // If there is no error, update() returns the number of affected rows - // so if the update is a no op, the return value is zero. - if ($membertype->update(DolibarrApiAccess::$user) >= 0) { - return $this->get($id); - } else { - throw new RestException(500, $membertype->error); - } - } + // If there is no error, update() returns the number of affected rows + // so if the update is a no op, the return value is zero. + if ($membertype->update(DolibarrApiAccess::$user) >= 0) { + return $this->get($id); + } else { + throw new RestException(500, $membertype->error); + } + } - /** - * Delete member type - * - * @param int $id member type ID - * @return array - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->adherent->configurer) { - throw new RestException(401); - } - $membertype = new AdherentType($this->db); - $result = $membertype->fetch($id); - if (!$result) { - throw new RestException(404, 'member type not found'); - } + /** + * Delete member type + * + * @param int $id member type ID + * @return array + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->adherent->configurer) { + throw new RestException(401); + } + $membertype = new AdherentType($this->db); + $result = $membertype->fetch($id); + if (!$result) { + throw new RestException(404, 'member type not found'); + } - if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!$membertype->delete()) { - throw new RestException(401, 'error when deleting member type'); - } + if (!$membertype->delete()) { + throw new RestException(401, 'error when deleting member type'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'member type deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'member type deleted' + ) + ); + } - /** - * Validate fields before creating an object - * - * @param array|null $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $membertype = array(); - foreach (MembersTypes::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $membertype[$field] = $data[$field]; - } - return $membertype; - } + /** + * Validate fields before creating an object + * + * @param array|null $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $membertype = array(); + foreach (MembersTypes::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $membertype[$field] = $data[$field]; + } + return $membertype; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param object $object Object to clean - * @return array Array of cleaned object properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - unset($object->array_options); - unset($object->linkedObjectsIds); - unset($object->context); - unset($object->canvas); - unset($object->fk_project); - unset($object->contact); - unset($object->contact_id); - unset($object->thirdparty); - unset($object->user); - unset($object->origin); - unset($object->origin_id); - unset($object->ref_ext); - unset($object->country); - unset($object->country_id); - unset($object->country_code); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); - unset($object->mode_reglement_id); - unset($object->cond_reglement_id); - unset($object->cond_reglement); - unset($object->fk_delivery_address); - unset($object->shipping_method_id); - unset($object->model_pdf); - unset($object->fk_account); - unset($object->note_public); - unset($object->note_private); - unset($object->fk_incoterms); - unset($object->label_incoterms); - unset($object->location_incoterms); - unset($object->name); - unset($object->lastname); - unset($object->firstname); - unset($object->civility_id); - unset($object->total_ht); - unset($object->total_tva); - unset($object->total_localtax1); - unset($object->total_localtax2); - unset($object->total_ttc); + unset($object->array_options); + unset($object->linkedObjectsIds); + unset($object->context); + unset($object->canvas); + unset($object->fk_project); + unset($object->contact); + unset($object->contact_id); + unset($object->thirdparty); + unset($object->user); + unset($object->origin); + unset($object->origin_id); + unset($object->ref_ext); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); + unset($object->model_pdf); + unset($object->fk_account); + unset($object->note_public); + unset($object->note_private); + unset($object->fk_incoterms); + unset($object->label_incoterms); + unset($object->location_incoterms); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); - return $object; - } + return $object; + } } diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index d5adbb0bc5b..370de13c3a2 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -27,219 +27,219 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; */ class Subscriptions extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'fk_adherent', - 'dateh', - 'datef', - 'amount', - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'fk_adherent', + 'dateh', + 'datef', + 'amount', + ); - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + } - /** - * Get properties of a subscription object - * - * Return an array with subscription informations - * - * @param int $id ID of subscription - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id) - { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { - throw new RestException(401); - } + /** + * Get properties of a subscription object + * + * Return an array with subscription informations + * + * @param int $id ID of subscription + * @return Object data without useless information + * + * @throws RestException + */ + public function get($id) + { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + throw new RestException(401); + } - $subscription = new Subscription($this->db); - $result = $subscription->fetch($id); - if (!$result) { - throw new RestException(404, 'Subscription not found'); - } + $subscription = new Subscription($this->db); + $result = $subscription->fetch($id); + if (!$result) { + throw new RestException(404, 'Subscription not found'); + } - return $this->_cleanObjectDatas($subscription); - } + return $this->_cleanObjectDatas($subscription); + } - /** - * List subscriptions - * - * Get a list of subscriptions - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" - * @return array Array of subscription objects - * - * @throws RestException - */ - public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') - { - global $db, $conf; + /** + * List subscriptions + * + * Get a list of subscriptions + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" + * @return array Array of subscription objects + * + * @throws RestException + */ + public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + throw new RestException(401); + } - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."subscription as t"; - $sql .= ' WHERE 1 = 1'; - // Add sql filters - if ($sqlfilters) { - if (!DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $sql = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription as t"; + $sql .= ' WHERE 1 = 1'; + // Add sql filters + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit + 1, $offset); - } + $sql .= $this->db->plimit($limit + 1, $offset); + } - $result = $this->db->query($sql); - if ($result) { - $i = 0; - $num = $this->db->num_rows($result); - while ($i < min($limit, $num)) { - $obj = $this->db->fetch_object($result); - $subscription = new Subscription($this->db); - if ($subscription->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($subscription); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No Subscription found'); - } + $result = $this->db->query($sql); + if ($result) { + $i = 0; + $num = $this->db->num_rows($result); + while ($i < min($limit, $num)) { + $obj = $this->db->fetch_object($result); + $subscription = new Subscription($this->db); + if ($subscription->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($subscription); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No Subscription found'); + } - return $obj_ret; - } + return $obj_ret; + } - /** - * Create subscription object - * - * @param array $request_data Request data - * @return int ID of subscription - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validate($request_data); + /** + * Create subscription object + * + * @param array $request_data Request data + * @return int ID of subscription + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); - $subscription = new Subscription($this->db); - foreach ($request_data as $field => $value) { - $subscription->$field = $value; - } - if ($subscription->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors)); - } - return $subscription->id; - } + $subscription = new Subscription($this->db); + foreach ($request_data as $field => $value) { + $subscription->$field = $value; + } + if ($subscription->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors)); + } + return $subscription->id; + } - /** - * Update subscription - * - * @param int $id ID of subscription to update - * @param array $request_data Datas - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } + /** + * Update subscription + * + * @param int $id ID of subscription to update + * @param array $request_data Datas + * @return Object + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } - $subscription = new Subscription($this->db); - $result = $subscription->fetch($id); - if (!$result) { - throw new RestException(404, 'Subscription not found'); - } + $subscription = new Subscription($this->db); + $result = $subscription->fetch($id); + if (!$result) { + throw new RestException(404, 'Subscription not found'); + } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - $subscription->$field = $value; - } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + $subscription->$field = $value; + } - if ($subscription->update(DolibarrApiAccess::$user) > 0) { - return $this->get($id); - } else { - throw new RestException(500, $subscription->error); - } - } + if ($subscription->update(DolibarrApiAccess::$user) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $subscription->error); + } + } - /** - * Delete subscription - * - * @param int $id ID of subscription to delete - * @return array - */ - public function delete($id) - { - // The right to delete a subscription comes with the right to create one. - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { - throw new RestException(401); - } - $subscription = new Subscription($this->db); - $result = $subscription->fetch($id); - if (!$result) { - throw new RestException(404, 'Subscription not found'); - } + /** + * Delete subscription + * + * @param int $id ID of subscription to delete + * @return array + */ + public function delete($id) + { + // The right to delete a subscription comes with the right to create one. + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + throw new RestException(401); + } + $subscription = new Subscription($this->db); + $result = $subscription->fetch($id); + if (!$result) { + throw new RestException(404, 'Subscription not found'); + } - if (!$subscription->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when deleting subscription'); - } + if (!$subscription->delete(DolibarrApiAccess::$user)) { + throw new RestException(401, 'error when deleting subscription'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'subscription deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'subscription deleted' + ) + ); + } - /** - * Validate fields before creating an object - * - * @param array|null $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $subscription = array(); - foreach (Subscriptions::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $subscription[$field] = $data[$field]; - } - return $subscription; - } + /** + * Validate fields before creating an object + * + * @param array|null $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $subscription = array(); + foreach (Subscriptions::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $subscription[$field] = $data[$field]; + } + return $subscription; + } } diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 5a75fdbae2e..2ea1c310d5a 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -32,435 +32,435 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class Subscription extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'subscription'; + /** + * @var string ID to identify managed object + */ + public $element = 'subscription'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'subscription'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'subscription'; - /** - * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table - */ - public $ismultientitymanaged = 'fk_adherent@adherent'; + /** + * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 'fk_adherent@adherent'; - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto = 'payment'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'payment'; - /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + /** + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * Date modification record (tms) - * - * @var integer - */ - public $datem; + /** + * Date modification record (tms) + * + * @var integer + */ + public $datem; - /** - * Subscription start date (date subscription) - * - * @var integer - */ - public $dateh; + /** + * Subscription start date (date subscription) + * + * @var integer + */ + public $dateh; - /** - * Subscription end date - * - * @var integer - */ - public $datef; + /** + * Subscription end date + * + * @var integer + */ + public $datef; - /** - * @var int ID - */ - public $fk_type; - public $fk_adherent; + /** + * @var int ID + */ + public $fk_type; + public $fk_adherent; - public $amount; + public $amount; - /** - * @var int ID - */ - public $fk_bank; + /** + * @var int ID + */ + public $fk_bank; - public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20), - 'fk_adherent' =>array('type'=>'integer', 'label'=>'Member', 'enabled'=>1, 'visible'=>-1, 'position'=>25), - 'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30), - 'datef' =>array('type'=>'datetime', 'label'=>'DateEndSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>35), - 'subscription' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'isameasure'=>1), - 'fk_bank' =>array('type'=>'integer', 'label'=>'BankId', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'note' =>array('type'=>'text', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>50), - 'fk_type' =>array('type'=>'integer', 'label'=>'MemberType', 'enabled'=>1, 'visible'=>-1, 'position'=>55), - 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>60), - 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65), - ); + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20), + 'fk_adherent' =>array('type'=>'integer', 'label'=>'Member', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30), + 'datef' =>array('type'=>'datetime', 'label'=>'DateEndSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>35), + 'subscription' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'isameasure'=>1), + 'fk_bank' =>array('type'=>'integer', 'label'=>'BankId', 'enabled'=>1, 'visible'=>-1, 'position'=>45), + 'note' =>array('type'=>'text', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'fk_type' =>array('type'=>'integer', 'label'=>'MemberType', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>60), + 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65), + ); - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Function who permitted cretaion of the subscription - * - * @param User $user User that create - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id subscription created if OK - */ - public function create($user, $notrigger = false) - { - global $langs; + /** + * Function who permitted cretaion of the subscription + * + * @param User $user User that create + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id subscription created if OK + */ + public function create($user, $notrigger = false) + { + global $langs; - $error = 0; + $error = 0; - $now = dol_now(); + $now = dol_now(); - // Check parameters - if ($this->datef <= $this->dateh) { - $this->error = $langs->trans("ErrorBadValueForDate"); - return -1; - } - if (empty($this->datec)) $this->datec = $now; + // Check parameters + if ($this->datef <= $this->dateh) { + $this->error = $langs->trans("ErrorBadValueForDate"); + return -1; + } + if (empty($this->datec)) $this->datec = $now; - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member = new Adherent($this->db); - $result = $member->fetch($this->fk_adherent); + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); - if ($this->fk_type == null) { // If type not defined, we use the type of member - $type = $member->typeid; - } else { - $type = $this->fk_type; - } - $sql .= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; - $sql .= " '".$this->db->idate($this->dateh)."',"; - $sql .= " '".$this->db->idate($this->datef)."',"; - $sql .= " ".$this->amount.","; - $sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')"; + if ($this->fk_type == null) { // If type not defined, we use the type of member + $type = $member->typeid; + } else { + $type = $this->fk_type; + } + $sql .= " VALUES (".$this->fk_adherent.", '".$this->db->escape($type)."', '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->dateh)."',"; + $sql .= " '".$this->db->idate($this->datef)."',"; + $sql .= " ".$this->amount.","; + $sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')"; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror(); + } - if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - $this->fk_type = $type; - } + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + $this->fk_type = $type; + } - if (!$error && !$notrigger) { - $this->context = array('member'=>$member); - // Call triggers - $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error && !$notrigger) { + $this->context = array('member' => $member); + // Call triggers + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Method to load a subscription - * - * @param int $rowid Id subscription - * @return int <0 if KO, =0 if not found, >0 if OK - */ - public function fetch($rowid) - { - $sql = "SELECT rowid, fk_type, fk_adherent, datec,"; - $sql .= " tms,"; - $sql .= " dateadh as dateh,"; - $sql .= " datef,"; - $sql .= " subscription, note, fk_bank"; - $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; - $sql .= " WHERE rowid=".$rowid; + /** + * Method to load a subscription + * + * @param int $rowid Id subscription + * @return int <0 if KO, =0 if not found, >0 if OK + */ + public function fetch($rowid) + { + $sql = "SELECT rowid, fk_type, fk_adherent, datec,"; + $sql .= " tms,"; + $sql .= " dateadh as dateh,"; + $sql .= " datef,"; + $sql .= " subscription, note, fk_bank"; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; + $sql .= " WHERE rowid=".$rowid; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->fk_type = $obj->fk_type; - $this->fk_adherent = $obj->fk_adherent; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->tms); - $this->dateh = $this->db->jdate($obj->dateh); - $this->datef = $this->db->jdate($obj->datef); - $this->amount = $obj->subscription; - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + $this->fk_type = $obj->fk_type; + $this->fk_adherent = $obj->fk_adherent; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->tms); + $this->dateh = $this->db->jdate($obj->dateh); + $this->datef = $this->db->jdate($obj->datef); + $this->amount = $obj->subscription; + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + return 1; + } else { + return 0; + } + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Update subscription - * - * @param User $user User who updated - * @param int $notrigger 0=Disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - $error = 0; + /** + * Update subscription + * + * @param User $user User who updated + * @param int $notrigger 0=Disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + $error = 0; - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; - $sql .= " fk_type = ".$this->fk_type.","; - $sql .= " fk_adherent = ".$this->fk_adherent.","; - $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; - $sql .= " subscription = '".price2num($this->amount)."',"; - $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; - $sql .= " datef='".$this->db->idate($this->datef)."',"; - $sql .= " datec='".$this->db->idate($this->datec)."',"; - $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; + $sql .= " fk_type = ".$this->fk_type.","; + $sql .= " fk_adherent = ".$this->fk_adherent.","; + $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; + $sql .= " subscription = '".price2num($this->amount)."',"; + $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; + $sql .= " datef='".$this->db->idate($this->datef)."',"; + $sql .= " datec='".$this->db->idate($this->datec)."',"; + $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member = new Adherent($this->db); - $result = $member->fetch($this->fk_adherent); - $result = $member->update_end_date($user); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); + $result = $member->update_end_date($user); - if (!$error && !$notrigger) { - $this->context = array('member'=>$member); - // Call triggers - $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); - if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } else { - $error++; - $this->error = $this->db->lasterror(); - } + if (!$error && !$notrigger) { + $this->context = array('member'=>$member); + // Call triggers + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); + if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Delete a subscription - * - * @param User $user User that delete - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function delete($user, $notrigger = false) - { - $error = 0; + /** + * Delete a subscription + * + * @param User $user User that delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function delete($user, $notrigger = false) + { + $error = 0; - // It subscription is linked to a bank transaction, we get it - if ($this->fk_bank > 0) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $accountline = new AccountLine($this->db); - $result = $accountline->fetch($this->fk_bank); - } + // It subscription is linked to a bank transaction, we get it + if ($this->fk_bank > 0) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $accountline = new AccountLine($this->db); + $result = $accountline->fetch($this->fk_bank); + } - $this->db->begin(); + $this->db->begin(); - if (!$error) { - if (!$notrigger) { - // Call triggers - $result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); - if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } + if (!$error) { + if (!$notrigger) { + // Call triggers + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->affected_rows($resql); - if ($num) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member = new Adherent($this->db); - $result = $member->fetch($this->fk_adherent); - $result = $member->update_end_date($user); + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->affected_rows($resql); + if ($num) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); + $result = $member->update_end_date($user); - if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) { // If we found bank account line (this means this->fk_bank defined) + if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) { // If we found bank account line (this means this->fk_bank defined) $result = $accountline->delete($user); // Return false if refused because line is conciliated - if ($result > 0) { - $this->db->commit(); - return 1; - } else { - $this->error = $accountline->error; - $this->db->rollback(); - return -1; - } - } else { - $this->db->commit(); - return 1; - } - } else { - $this->db->commit(); - return 0; - } - } else { - $error++; - $this->error = $this->db->lasterror(); - } - } + if ($result > 0) { + $this->db->commit(); + return 1; + } else { + $this->error = $accountline->error; + $this->db->rollback(); + return -1; + } + } else { + $this->db->commit(); + return 1; + } + } else { + $this->db->commit(); + return 0; + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return 1; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } - /** - * Return clicable name (with picto eventually) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $notooltip 1=Disable tooltip - * @param string $option Page for link ('', 'nolink', ...) - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string Chaine avec URL - */ - public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) - { - global $langs; + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $notooltip 1=Disable tooltip + * @param string $option Page for link ('', 'nolink', ...) + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string Chaine avec URL + */ + public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) + { + global $langs; - $result = ''; + $result = ''; - $langs->load("members"); - $label = $langs->trans("ShowSubscription").': '.$this->ref; + $langs->load("members"); + $label = $langs->trans("ShowSubscription").': '.$this->ref; - $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id; + $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id; - if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; - $picto = 'payment'; + $picto = 'payment'; - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; - return $result; - } + return $result; + } - /** - * Retourne le libelle du statut d'une adhesion - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label - */ - public function getLibStatut($mode = 0) - { - return ''; - } + /** + * Retourne le libelle du statut d'une adhesion + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label + */ + public function getLibStatut($mode = 0) + { + return ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $status Id status - * @return string Label - */ - public function LibStatut($status) - { - // phpcs:enable - global $langs; - $langs->load("members"); - return ''; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Id status + * @return string Label + */ + public function LibStatut($status) + { + // phpcs:enable + global $langs; + $langs->load("members"); + return ''; + } - /** - * Load information of the subscription object - * - * @param int $id Id subscription - * @return void - */ - public function info($id) - { - $sql = 'SELECT c.rowid, c.datec,'; - $sql .= ' c.tms as datem'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; - $sql .= ' WHERE c.rowid = '.$id; + /** + * Load information of the subscription object + * + * @param int $id Id subscription + * @return void + */ + public function info($id) + { + $sql = 'SELECT c.rowid, c.datec,'; + $sql .= ' c.tms as datem'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; + $sql .= ' WHERE c.rowid = '.$id; - $result = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 32630b9e478..f9c14b91ac3 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -86,7 +86,7 @@ $helpurl = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Mi llxHeader("", $title, $helpurl); if ($id > 0) { - $result = $membert->fetch($object->typeid); + $result = $membert->fetch($object->typeid); if ($result > 0) { // Build file list $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -95,47 +95,47 @@ if ($id > 0) { $totalsize += $file['size']; } - if (!empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = member_prepare_head($object); - dol_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user'); + print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'rowid', $linkback); + dol_banner_tab($object, 'rowid', $linkback); - print '
'; + print '
'; - print '
'; + print '
'; print ''; $linkback = ''.$langs->trans("BackToList").''; - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; - } + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; + } - // Type - print '\n"; + // Type + print '\n"; - // Morphy - print ''; - /*print ''; + /*print '';*/ - print ''; + print ''; - // Company - print ''; + // Company + print ''; - // Civility - print ''; - print ''; + // Civility + print ''; + print ''; - // Number of Attached Files + // Number of Attached Files print ''; //Total Size Of Attached Files @@ -145,7 +145,7 @@ if ($id > 0) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'member'; $permission = $user->rights->adherent->creer; @@ -157,7 +157,7 @@ if ($id > 0) { dol_print_error($db); } } else { - $langs->load("errors"); + $langs->load("errors"); print $langs->trans("ErrorRecordNotFound"); } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index c63bb9049ca..35b0fcfb478 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -125,29 +125,29 @@ print '
'; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo // Search contact/address - if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { - $listofsearchfields['search_member'] = array('text'=>'Member'); - } + if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { + $listofsearchfields['search_member'] = array('text'=>'Member'); + } - if (count($listofsearchfields)) { - print '
'; - print ''; - print '
'; - print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Type").''.$membert->getNomUrl(1)."
'.$langs->trans("Type").''.$membert->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; + // Morphy + print '
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; print $form->showphoto('memberphoto',$object); print '
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'; - $i = 0; - foreach ($listofsearchfields as $key => $value) { - if ($i == 0) print ''; - print ''; - print ''; - if ($i == 0) print ''; - print ''; - $i++; - } - print '
'.$langs->trans("Search").'
:
'; - print '
'; - print ''; - print '
'; - } + if (count($listofsearchfields)) { + print '
'; + print ''; + print '
'; + print ''; + $i = 0; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Search").'
:
'; + print '
'; + print '
'; + print '
'; + } } @@ -158,53 +158,53 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel if ($conf->use_javascript_ajax) { print '
'; print ''; - print ''; - print ''; + print ''; - print ''; - print '
'.$langs->trans("Statistics").'
'; + print '
'.$langs->trans("Statistics").'
'; - $SommeA = 0; - $SommeB = 0; - $SommeC = 0; - $SommeD = 0; - $total = 0; - $dataval = array(); - $i = 0; - foreach ($AdherentType as $key => $adhtype) { - $dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0); - $dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0); - $dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0); - $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); - $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; - $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; - $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; - $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; - $i++; - } - $total = $SommeA + $SommeB + $SommeC + $SommeD; - $dataseries = array(); - $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB)); - $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA)); + $SommeA = 0; + $SommeB = 0; + $SommeC = 0; + $SommeD = 0; + $total = 0; + $dataval = array(); + $i = 0; + foreach ($AdherentType as $key => $adhtype) { + $dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0); + $dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0); + $dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0); + $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); + $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; + $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; + $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; + $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + $i++; + } + $total = $SommeA + $SommeB + $SommeC + $SommeD; + $dataseries = array(); + $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB)); + $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC)); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD)); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA)); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); - print '
'.$langs->trans("Total").''; - print $SommeA + $SommeB + $SommeC + $SommeD; - print '
'; - print '
'; + print '
'.$langs->trans("Total").''; + print $SommeA + $SommeB + $SommeC + $SommeD; + print '
'; + print '
'; } print '
'; @@ -223,17 +223,17 @@ $sql .= " AND d.rowid = c.fk_adherent"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); - $year = dol_print_date($db->jdate($objp->dateh), "%Y"); - $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; - $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; - $tot += $objp->subscription; - $numb += 1; - $i++; - } + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); + $year = dol_print_date($db->jdate($objp->dateh), "%Y"); + $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; + $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; + $tot += $objp->subscription; + $numb += 1; + $i++; + } } print '
'; @@ -258,12 +258,12 @@ foreach ($Total as $key=>$value) { break; } print ''; - print "$key"; - print "".$Number[$key].""; - print "".price($value).""; - print "".price(price2num($value / $Number[$key], 'MT')).""; - print "\n"; - $i++; + print "$key"; + print "".$Number[$key].""; + print "".price($value).""; + print "".price(price2num($value / $Number[$key], 'MT')).""; + print "\n"; + $i++; } // Total @@ -284,9 +284,10 @@ print '
'; */ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; -$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; -$sql .= " a.tms as datem, datefin as date_end_subscription,"; -$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription"; +$sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; +$sql .= " a.gender, a.email, a.photo, a.morphy,"; +$sql .= " a.tms as datem, a.datefin as date_end_subscription,"; +$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; $sql .= " WHERE a.entity IN (".getEntity('adherent').")"; $sql .= " AND a.fk_adherent_type = ta.rowid"; @@ -305,10 +306,18 @@ if ($resql) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; + $staticmember->id = $obj->rowid; + $staticmember->ref = $obj->rowid; $staticmember->lastname = $obj->lastname; $staticmember->firstname = $obj->firstname; + $staticmember->gender = $obj->gender; + $staticmember->email = $obj->email; + $staticmember->photo = $obj->photo; + $staticmember->morphy = $obj->morphy; + $staticmember->statut = $obj->status; + $staticmember->need_subscription = $obj->need_subscription; + $staticmember->datefin = $db->jdate($obj->date_end_subscription); if (!empty($obj->fk_soc)) { $staticmember->fk_soc = $obj->fk_soc; $staticmember->fetch_thirdparty(); @@ -316,13 +325,16 @@ if ($resql) { } else { $staticmember->name = $obj->company; } - $staticmember->ref = $staticmember->getFullName($langs); + $statictype->id = $obj->typeid; $statictype->label = $obj->label; - print ''.$staticmember->getNomUrl(1, 32).''; + $statictype->subscription = $obj->need_subscription; + + print ''; + print ''.$staticmember->getNomUrl(-1, 32).''; print ''.$statictype->getNomUrl(1, 32).''; print ''.dol_print_date($db->jdate($obj->datem), 'dayhour').''; - print ''.$staticmember->LibStatut($obj->statut, ($obj->subscription == 'yes' ? 1 : 0), $db->jdate($obj->date_end_subscription), 3).''; + print ''.$staticmember->getLibStatut(3).''; print ''; $i++; } @@ -339,11 +351,14 @@ if ($resql) { */ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; -$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; -$sql .= " datefin as date_end_subscription,"; +$sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; +$sql .= " a.gender, a.email, a.photo, a.morphy,"; +$sql .= " a.datefin as date_end_subscription,"; +$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription,"; $sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta, ".MAIN_DB_PREFIX."subscription as c"; $sql .= " WHERE a.entity IN (".getEntity('adherent').")"; +$sql .= " AND a.fk_adherent_type = ta.rowid"; $sql .= " AND c.fk_adherent = a.rowid"; $sql .= $db->order("c.tms", "DESC"); $sql .= $db->plimit($max, 0); @@ -360,12 +375,18 @@ if ($resql) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; - $subscriptionstatic->id = $obj->cid; - $subscriptionstatic->ref = $obj->cid; + $staticmember->id = $obj->rowid; + $staticmember->ref = $obj->rowid; $staticmember->lastname = $obj->lastname; $staticmember->firstname = $obj->firstname; + $staticmember->gender = $obj->gender; + $staticmember->email = $obj->email; + $staticmember->photo = $obj->photo; + $staticmember->morphy = $obj->morphy; + $staticmember->statut = $obj->status; + $staticmember->need_subscription = $obj->need_subscription; + $staticmember->datefin = $db->jdate($obj->date_end_subscription); if (!empty($obj->fk_soc)) { $staticmember->fk_soc = $obj->fk_soc; $staticmember->fetch_thirdparty(); @@ -373,9 +394,13 @@ if ($resql) { } else { $staticmember->name = $obj->company; } - $staticmember->ref = $staticmember->getFullName($langs); + + $subscriptionstatic->id = $obj->cid; + $subscriptionstatic->ref = $obj->cid; + + print ''; print ''.$subscriptionstatic->getNomUrl(1).''; - print ''.$staticmember->getNomUrl(1, 32, 'subscription').''; + print ''.$staticmember->getNomUrl(-1, 32, 'subscription').''; print ''.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).''; print ''.price($obj->subscription).''; //print ''.$staticmember->LibStatut($obj->statut,($obj->subscription=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).''; diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 3094c6a50ac..6be535b6e3b 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -38,7 +38,7 @@ $action = GETPOST('action', 'aZ09'); // Protection $socid = 0; if ($user->socid > 0) { - $socid = $user->socid; + $socid = $user->socid; } $object = new Adherent($db); @@ -84,7 +84,7 @@ llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adh&eacu $head = member_prepare_head($object); -dol_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user'); +print dol_get_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user'); $linkback = ''.$langs->trans("BackToList").''; @@ -128,7 +128,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); /* * Barre d'actions @@ -165,24 +165,24 @@ if ($result > 0) { $search = "(".$object->_load_ldap_dn($info, 2).")"; if (empty($dn)) { - $langs->load("errors"); - print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).''; + $langs->load("errors"); + print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).''; } else { - $records = $ldap->getAttribute($dn, $search); + $records = $ldap->getAttribute($dn, $search); - //print_r($records); + //print_r($records); - // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (!is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; - } else { - $result = show_ldap_content($records, 0, $records['count'], true); - } - } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; - } - } + // Show tree + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { + if (!is_array($records)) { + print ''.$langs->trans("ErrorFailedToReadLDAP").''; + } else { + $result = show_ldap_content($records, 0, $records['count'], true); + } + } else { + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + } + } $ldap->unbind(); $ldap->close(); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index ef4639e4b5e..c9aaa856d22 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -204,30 +204,30 @@ if (empty($reshook)) { // Close if ($massaction == 'close' && $user->rights->adherent->creer) { - $tmpmember = new Adherent($db); - $error = 0; - $nbclose = 0; + $tmpmember = new Adherent($db); + $error = 0; + $nbclose = 0; - $db->begin(); + $db->begin(); - foreach ($toselect as $idtoclose) { - $tmpmember->fetch($idtoclose); - $result = $tmpmember->resiliate($user); + foreach ($toselect as $idtoclose) { + $tmpmember->fetch($idtoclose); + $result = $tmpmember->resiliate($user); - if ($result < 0 && !count($tmpmember->errors)) { - setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); - } else { - if ($result > 0) $nbclose++; - } - } + if ($result < 0 && !count($tmpmember->errors)) { + setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); + } else { + if ($result > 0) $nbclose++; + } + } - if (!$error) { - setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); + if (!$error) { + setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } + $db->commit(); + } else { + $db->rollback(); + } } // Mass actions @@ -409,7 +409,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; if ($user->rights->adherent->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); } print '
'; @@ -560,7 +560,7 @@ if (!empty($arrayfields['d.email']['checked'])) { // End of subscription date if (!empty($arrayfields['d.datefin']['checked'])) { print ''; - $selectarray=array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); + $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); print $form->selectarray('search_filter', $selectarray, $search_filter); print ''; } @@ -656,6 +656,7 @@ while ($i < min($num, $limit)) { $memberstatic->datefin = $datefin; $memberstatic->socid = $obj->fk_soc; $memberstatic->photo = $obj->photo; + $memberstatic->email = $obj->email; $memberstatic->morphy = $obj->morphy; $memberstatic->note_public = $obj->note_public; $memberstatic->note_private = $obj->note_private; @@ -725,12 +726,10 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['d.morphy']['checked'])) { print ''; $s = ''; - if ($obj->morphy == 'phy') - { + if ($obj->morphy == 'phy') { $s .= ''.dol_substr($langs->trans("Physical"), 0, 1).''; } - if ($obj->morphy == 'mor') - { + if ($obj->morphy == 'mor') { $s .= ''.dol_substr($langs->trans("Moral"), 0, 1).''; } print $s; diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 85becb0aa3d..e611eb3bbcf 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -40,8 +40,8 @@ $result = restrictedArea($user, 'adherent', $id); $object = new Adherent($db); $result = $object->fetch($id); if ($result > 0) { - $adht = new AdherentType($db); - $result = $adht->fetch($object->typeid); + $adht = new AdherentType($db); + $result = $adht->fetch($object->typeid); } $permissionnote = $user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php @@ -66,7 +66,7 @@ $form = new Form($db); if ($id) { $head = member_prepare_head($object); - dol_fiche_head($head, 'note', $langs->trans("Member"), -1, 'user'); + print dol_get_fiche_head($head, 'note', $langs->trans("Member"), -1, 'user'); print ""; print ''; @@ -75,44 +75,44 @@ if ($id) { dol_banner_tab($object, 'id', $linkback); - print '
'; + print '
'; - print '
'; + print '
'; print ''; - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; - } + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; + } - // Type - print '\n"; + // Type + print '\n"; - // Morphy - print ''; - /*print ''; + /*print '';*/ - print ''; + print ''; - // Company - print ''; + // Company + print ''; - // Civility - print ''; - print ''; + // Civility + print ''; + print ''; - print "
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; + // Morphy + print '
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; print $form->showphoto('memberphoto',$member); print '
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
"; + print ""; - print '
'; + print '
'; - $cssclass = 'titlefield'; - $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + $cssclass = 'titlefield'; + $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 62e503f8170..73c32c59684 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -34,8 +34,8 @@ $mode = GETPOST('mode') ?GETPOST('mode') : ''; // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); @@ -69,7 +69,7 @@ $sql .= " d.morphy as code"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut != -1"; // Not draft +$sql .= " AND d.statut != -1"; // Not draft $sql .= " GROUP BY d.morphy"; $foundphy = $foundmor = 0; @@ -100,7 +100,7 @@ $sql .= " d.morphy as code"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0) +$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0) $sql .= " GROUP BY d.morphy"; $foundphy = $foundmor = 0; @@ -128,7 +128,7 @@ if ($resql) { $head = member_stats_prepare_head($adh); -dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'user'); +print dol_get_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'user'); // Print title @@ -173,7 +173,7 @@ foreach ($data as $val) { print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index f7001656bd9..c24cf1fdef4 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -35,8 +35,8 @@ $mode = GETPOST('mode') ?GETPOST('mode') : ''; // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); @@ -68,238 +68,238 @@ print load_fiche_titre($title, '', 'object_group'); dol_mkdir($dir); if ($mode) { - // Define sql - if ($mode == 'memberbycountry') { - $label = $langs->trans("Country"); - $tab = 'statscountry'; + // Define sql + if ($mode == 'memberbycountry') { + $label = $langs->trans("Country"); + $tab = 'statscountry'; - $data = array(); - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY c.label, c.code"; - //print $sql; - } + $data = array(); + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY c.label, c.code"; + //print $sql; + } if ($mode == 'memberbystate') { - $label = $langs->trans("Country"); - $label2 = $langs->trans("State"); - $tab = 'statsstate'; - - $data = array(); - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY co.label, co.code, c.nom"; - //print $sql; - } - if ($mode == 'memberbyregion') { // $label = $langs->trans("Country"); - $label2 = $langs->trans("Region"); //département - $tab = 'statsregion'; //onglet + $label2 = $langs->trans("State"); + $tab = 'statsstate'; - $data = array(); //tableau de donnée - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY co.label, co.code, r.nom"; //+ - //print $sql; - } - if ($mode == 'memberbytown') { - $label = $langs->trans("Country"); - $label2 = $langs->trans("Town"); - $tab = 'statstown'; + $data = array(); + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY co.label, co.code, c.nom"; + //print $sql; + } + if ($mode == 'memberbyregion') { // + $label = $langs->trans("Country"); + $label2 = $langs->trans("Region"); //département + $tab = 'statsregion'; //onglet - $data = array(); - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY c.label, c.code, d.town"; - //print $sql; - } + $data = array(); //tableau de donnée + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY co.label, co.code, r.nom"; //+ + //print $sql; + } + if ($mode == 'memberbytown') { + $label = $langs->trans("Country"); + $label2 = $langs->trans("Town"); + $tab = 'statstown'; - $langsen = new Translate('', $conf); - $langsen->setDefaultLang('en_US'); - $langsen->load("dict"); - //print $langsen->trans("Country"."FI");exit; + $data = array(); + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY c.label, c.code, d.town"; + //print $sql; + } - // Define $data array - dol_syslog("Count member", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($mode == 'memberbycountry') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + $langsen = new Translate('', $conf); + $langsen->setDefaultLang('en_US'); + $langsen->load("dict"); + //print $langsen->trans("Country"."FI");exit; + + // Define $data array + dol_syslog("Count member", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($mode == 'memberbycountry') { + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), 'code'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } - if ($mode == 'memberbyregion') { //+ + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } + if ($mode == 'memberbyregion') { //+ $data[] = array( - 'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), + 'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } - if ($mode == 'memberbystate') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } + if ($mode == 'memberbystate') { + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } - if ($mode == 'memberbytown') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } + if ($mode == 'memberbytown') { + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), + 'nb'=>$obj->nb, + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } - $i++; - } - $db->free($resql); - } else { - dol_print_error($db); - } + $i++; + } + $db->free($resql); + } else { + dol_print_error($db); + } } $head = member_stats_prepare_head($adh); -dol_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user'); +print dol_get_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user'); // Print title if ($mode && !count($data)) { - print $langs->trans("NoValidatedMemberYet").'
'; - print '
'; + print $langs->trans("NoValidatedMemberYet").'
'; + print '
'; } else { - if ($mode == 'memberbycountry') print ''.$langs->trans("MembersByCountryDesc").'
'; - elseif ($mode == 'memberbystate') print ''.$langs->trans("MembersByStateDesc").'
'; - elseif ($mode == 'memberbytown') print ''.$langs->trans("MembersByTownDesc").'
'; - elseif ($mode == 'memberbyregion') print ''.$langs->trans("MembersByRegion").'
'; //+ - else { - print ''.$langs->trans("MembersStatisticsDesc").'
'; - print '
'; - print ''.$langs->trans("MembersStatisticsByCountries").'
'; - print '
'; - print ''.$langs->trans("MembersStatisticsByState").'
'; - print '
'; - print ''.$langs->trans("MembersStatisticsByTown").'
'; - print '
'; //+ + if ($mode == 'memberbycountry') print ''.$langs->trans("MembersByCountryDesc").'
'; + elseif ($mode == 'memberbystate') print ''.$langs->trans("MembersByStateDesc").'
'; + elseif ($mode == 'memberbytown') print ''.$langs->trans("MembersByTownDesc").'
'; + elseif ($mode == 'memberbyregion') print ''.$langs->trans("MembersByRegion").'
'; //+ + else { + print ''.$langs->trans("MembersStatisticsDesc").'
'; + print '
'; + print ''.$langs->trans("MembersStatisticsByCountries").'
'; + print '
'; + print ''.$langs->trans("MembersStatisticsByState").'
'; + print '
'; + print ''.$langs->trans("MembersStatisticsByTown").'
'; + print '
'; //+ print ''.$langs->trans("MembersStatisticsByRegion").'
'; //+ - } - print '
'; + } + print '
'; } // Show graphics if (count($arrayjs) && $mode == 'memberbycountry') { - $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - if (is_readable($color_file)) include_once $color_file; + $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + if (is_readable($color_file)) include_once $color_file; - // Assume we've already included the proper headers so just call our script inline - // More doc: https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr-FR - print "\n\n"; + print "\tvar options = {};\n"; + print "\toptions['dataMode'] = 'regions';\n"; + print "\toptions['showZoomOut'] = false;\n"; + //print "\toptions['zoomOutLabel'] = '".dol_escape_js($langs->transnoentitiesnoconv("Numbers"))."';\n"; + print "\toptions['width'] = ".$graphwidth.";\n"; + print "\toptions['height'] = ".$graphheight.";\n"; + print "\toptions['colors'] = [0x".colorArrayToHex($theme_datacolor[1], 'BBBBBB').", 0x".colorArrayToHex($theme_datacolor[0], '444444')."];\n"; + print "\tvar container = document.getElementById('".$mode."');\n"; + print "\tvar geomap = new google.visualization.GeoMap(container);\n"; + print "\tgeomap.draw(data, options);\n"; + print "};\n"; + print "\n"; - // print the div tag that will contain the map - print '
'."\n"; - print '
'; + // print the div tag that will contain the map + print '
'."\n"; + print '
'; } if ($mode) { - // Print array + // Print array print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; - print ''; - print ''; - if ($label2) print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + if ($label2) print ''; + print ''; + print ''; + print ''; + print ''; - foreach ($data as $val) { - $year = $val['year']; - print ''; - print ''; - if ($label2) print ''; - print ''; - print ''; - print ''; - print ''; - } + foreach ($data as $val) { + $year = $val['year']; + print ''; + print ''; + if ($label2) print ''; + print ''; + print ''; + print ''; + print ''; + } - print '
'.$label.''.$label2.''.$langs->trans("NbOfMembers").' ('.$langs->trans("AllTime").')'.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
'.$label.''.$label2.''.$langs->trans("NbOfMembers").' ('.$langs->trans("AllTime").')'.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
'.$val['label'].''.$val['label2'].''.$val['nb'].''.dol_print_date($val['lastdate'], 'dayhour').''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'
'.$val['label'].''.$val['label2'].''.$val['nb'].''.dol_print_date($val['lastdate'], 'dayhour').''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'
'; - print '
'; + print ''; + print '
'; } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index c6748538264..6ac4e3dd78a 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -36,8 +36,8 @@ $socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0; // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); @@ -79,24 +79,24 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscripti $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { - $px1->SetData($data); - $i = $startyear; - while ($i <= $endyear) { - $legend[] = $i; - $i++; - } - $px1->SetLegend($legend); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); - $px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfSubscriptions")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NbOfSubscriptions")); + $px1->SetData($data); + $i = $startyear; + while ($i <= $endyear) { + $legend[] = $i; + $i++; + } + $px1->SetLegend($legend); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); + $px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + $px1->SetYLabel($langs->trans("NbOfSubscriptions")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->mode = 'depth'; + $px1->SetTitle($langs->trans("NbOfSubscriptions")); - $px1->draw($filenamenb, $fileurlnb); + $px1->draw($filenamenb, $fileurlnb); } // Build graphic amount of object @@ -110,30 +110,30 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscr $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { - $px2->SetData($data); - $i = $startyear; - while ($i <= $endyear) { - $legend[] = $i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfSubscriptions")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode = 'depth'; - $px2->SetTitle($langs->trans("AmountOfSubscriptions")); + $px2->SetData($data); + $i = $startyear; + while ($i <= $endyear) { + $legend[] = $i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("AmountOfSubscriptions")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode = 'depth'; + $px2->SetTitle($langs->trans("AmountOfSubscriptions")); - $px2->draw($filenameamount, $fileurlamount); + $px2->draw($filenameamount, $fileurlamount); } $head = member_stats_prepare_head($adh); -dol_fiche_head($head, 'statssubscription', $langs->trans("Statistics"), -1, 'user'); +print dol_get_fiche_head($head, 'statssubscription', $langs->trans("Statistics"), -1, 'user'); print '
'; @@ -171,31 +171,31 @@ print ''; $oldyear = 0; foreach ($data as $val) { - $year = $val['year']; - while ($oldyear > $year + 1) { // If we have empty year - $oldyear--; - print ''; - print ''; - //print ''; - print $oldyear; - //print ''; - print ''; - print '0'; - print '0'; - print '0'; - print ''; - } - print ''; - print ''; - //print ''; - print $year; - //print ''; - print ''; - print ''.$val['nb'].''; - print ''.price(price2num($val['total'], 'MT'), 1).''; - print ''.price(price2num($val['avg'], 'MT'), 1).''; - print ''; - $oldyear = $year; + $year = $val['year']; + while ($oldyear > $year + 1) { // If we have empty year + $oldyear--; + print ''; + print ''; + //print ''; + print $oldyear; + //print ''; + print ''; + print '0'; + print '0'; + print '0'; + print ''; + } + print ''; + print ''; + //print ''; + print $year; + //print ''; + print ''; + print ''.$val['nb'].''; + print ''.price(price2num($val['total'], 'MT'), 1).''; + print ''.price(price2num($val['avg'], 'MT'), 1).''; + print ''; + $oldyear = $year; } print ''; @@ -208,9 +208,9 @@ print '
'; // Show graphs print '
'; if ($mesg) { print $mesg; } else { - print $px1->show(); - print "
\n"; - print $px2->show(); + print $px1->show(); + print "
\n"; + print $px2->show(); } print '
'; @@ -219,7 +219,7 @@ print '
'; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 67880c303cb..748ac19814c 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -76,26 +76,26 @@ $defaultdelay = 1; $defaultdelayunit = 'y'; if ($rowid) { - // Load member - $result = $object->fetch($rowid); + // Load member + $result = $object->fetch($rowid); - // Define variables to know what current user can do on users - $canadduser = ($user->admin || $user->rights->user->user->creer); - // Define variables to know what current user can do on properties of user linked to edited member - if ($object->user_id) { - // $user is the user editing, $object->user_id is the user's id linked to the edited member - $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) - || (($user->id != $object->user_id) && $user->rights->user->user->creer)); - $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) - || (($user->id != $object->user_id) && $user->rights->user->user->password)); - } + // Define variables to know what current user can do on users + $canadduser = ($user->admin || $user->rights->user->user->creer); + // Define variables to know what current user can do on properties of user linked to edited member + if ($object->user_id) { + // $user is the user editing, $object->user_id is the user's id linked to the edited member + $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) + || (($user->id != $object->user_id) && $user->rights->user->user->creer)); + $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) + || (($user->id != $object->user_id) && $user->rights->user->user->password)); + } } // Define variables to know what current user can do on members $canaddmember = $user->rights->adherent->creer; // Define variables to know what current user can do on properties of a member if ($rowid) { - $caneditfieldmember = $user->rights->adherent->creer; + $caneditfieldmember = $user->rights->adherent->creer; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -130,242 +130,242 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights } if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { - $error = 0; - if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only + $error = 0; + if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) { - $error++; - setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); + $error++; + setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); } - } + } - if (!$error) { - if ($_POST["userid"] != $object->user_id) { // If link differs from currently in database + if (!$error) { + if ($_POST["userid"] != $object->user_id) { // If link differs from currently in database $result = $object->setUserId($_POST["userid"]); - if ($result < 0) dol_print_error('', $object->error); - $_POST['action'] = ''; - $action = ''; - } - } + if ($result < 0) dol_print_error('', $object->error); + $_POST['action'] = ''; + $action = ''; + } + } } if ($action == 'setsocid') { - $error = 0; - if (!$error) { - if (GETPOST('socid', 'int') != $object->fk_soc) { // If link differs from currently in database + $error = 0; + if (!$error) { + if (GETPOST('socid', 'int') != $object->fk_soc) { // If link differs from currently in database $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql .= " WHERE fk_soc = '".GETPOST('socid', 'int')."'"; - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj && $obj->rowid > 0) { - $othermember = new Adherent($db); - $othermember->fetch($obj->rowid); - $thirdparty = new Societe($db); - $thirdparty->fetch(GETPOST('socid', 'int')); - $error++; - setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); - } - } + $sql .= " WHERE fk_soc = '".GETPOST('socid', 'int')."'"; + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj && $obj->rowid > 0) { + $othermember = new Adherent($db); + $othermember->fetch($obj->rowid); + $thirdparty = new Societe($db); + $thirdparty->fetch(GETPOST('socid', 'int')); + $error++; + setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); + } + } - if (!$error) { - $result = $object->setThirdPartyId(GETPOST('socid', 'int')); - if ($result < 0) dol_print_error('', $object->error); - $_POST['action'] = ''; - $action = ''; - } - } - } + if (!$error) { + $result = $object->setThirdPartyId(GETPOST('socid', 'int')); + if ($result < 0) dol_print_error('', $object->error); + $_POST['action'] = ''; + $action = ''; + } + } + } } if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !$_POST["cancel"]) { - $error = 0; + $error = 0; - $langs->load("banks"); + $langs->load("banks"); - $result = $object->fetch($rowid); - $result = $adht->fetch($object->typeid); + $result = $object->fetch($rowid); + $result = $adht->fetch($object->typeid); - // Subscription informations - $datesubscription = 0; - $datesubend = 0; - $paymentdate = 0; - if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"]) { - $datesubscription = dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - } - if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"]) { - $datesubend = dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - } - if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"]) { - $paymentdate = dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]); - } - $amount = price2num(GETPOST("subscription", 'alpha')); // Amount of subscription - $label = $_POST["label"]; + // Subscription informations + $datesubscription = 0; + $datesubend = 0; + $paymentdate = 0; + if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"]) { + $datesubscription = dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + } + if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"]) { + $datesubend = dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + } + if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"]) { + $paymentdate = dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]); + } + $amount = price2num(GETPOST("subscription", 'alpha')); // Amount of subscription + $label = $_POST["label"]; - // Payment informations - $accountid = $_POST["accountid"]; - $operation = $_POST["operation"]; // Payment mode - $num_chq = GETPOST("num_chq", "alphanohtml"); - $emetteur_nom = $_POST["chqemetteur"]; - $emetteur_banque = $_POST["chqbank"]; - $option = $_POST["paymentsave"]; - if (empty($option)) $option = 'none'; - $sendalsoemail = GETPOST("sendmail", 'alpha'); + // Payment informations + $accountid = $_POST["accountid"]; + $operation = $_POST["operation"]; // Payment mode + $num_chq = GETPOST("num_chq", "alphanohtml"); + $emetteur_nom = $_POST["chqemetteur"]; + $emetteur_banque = $_POST["chqbank"]; + $option = $_POST["paymentsave"]; + if (empty($option)) $option = 'none'; + $sendalsoemail = GETPOST("sendmail", 'alpha'); - // Check parameters - if (!$datesubscription) { - $error++; - $langs->load("errors"); - $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription")); - setEventMessages($errmsg, null, 'errors'); - $action = 'addsubscription'; - } - if (GETPOST('end') && !$datesubend) { - $error++; - $langs->load("errors"); - $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription")); - setEventMessages($errmsg, null, 'errors'); - $action = 'addsubscription'; - } - if (!$datesubend) { - $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd'); - } - if (($option == 'bankviainvoice' || $option == 'bankdirect') && !$paymentdate) { - $error++; - $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")); - setEventMessages($errmsg, null, 'errors'); - $action = 'addsubscription'; - } + // Check parameters + if (!$datesubscription) { + $error++; + $langs->load("errors"); + $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription")); + setEventMessages($errmsg, null, 'errors'); + $action = 'addsubscription'; + } + if (GETPOST('end') && !$datesubend) { + $error++; + $langs->load("errors"); + $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription")); + setEventMessages($errmsg, null, 'errors'); + $action = 'addsubscription'; + } + if (!$datesubend) { + $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd'); + } + if (($option == 'bankviainvoice' || $option == 'bankdirect') && !$paymentdate) { + $error++; + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")); + setEventMessages($errmsg, null, 'errors'); + $action = 'addsubscription'; + } - // Check if a payment is mandatory or not - if (!$error && $adht->subscription) { // Member type need subscriptions + // Check if a payment is mandatory or not + if (!$error && $adht->subscription) { // Member type need subscriptions if (!is_numeric($amount)) { - // If field is '' or not a numeric value - $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - setEventMessages($errmsg, null, 'errors'); - $error++; - $action = 'addsubscription'; + // If field is '' or not a numeric value + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + setEventMessages($errmsg, null, 'errors'); + $error++; + $action = 'addsubscription'; } else { - if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') { - if ($_POST["subscription"]) { - if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); - if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); - } else { - if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); - } - if ($errmsg) { - $error++; - setEventMessages($errmsg, null, 'errors'); - $error++; - $action = 'addsubscription'; - } - } - } - } + if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') { + if ($_POST["subscription"]) { + if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); + } else { + if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); + } + if ($errmsg) { + $error++; + setEventMessages($errmsg, null, 'errors'); + $error++; + $action = 'addsubscription'; + } + } + } + } - // Record the subscription then complementary actions - if (!$error && $action == 'subscription') { - $db->begin(); + // Record the subscription then complementary actions + if (!$error && $action == 'subscription') { + $db->begin(); - // Create subscription - $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); - if ($crowid <= 0) { - $error++; - $errmsg = $object->error; - setEventMessages($object->error, $object->errors, 'errors'); - } + // Create subscription + $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); + if ($crowid <= 0) { + $error++; + $errmsg = $object->error; + setEventMessages($object->error, $object->errors, 'errors'); + } - if (!$error) { - $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque); + if (!$error) { + $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque); if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } else { // If an invoice was created, it is into $object->invoice } - } + } - if (!$error) { - $db->commit(); - } else { - $db->rollback(); - $action = 'addsubscription'; - } + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + $action = 'addsubscription'; + } - if (!$error) { - setEventMessages("SubscriptionRecorded", null, 'mesgs'); - } + if (!$error) { + setEventMessages("SubscriptionRecorded", null, 'mesgs'); + } - // Send email - if (!$error) { - // Send confirmation Email - if ($object->email && $sendalsoemail) { // $object is 'Adherent' + // Send email + if (!$error) { + // Send confirmation Email + if ($object->email && $sendalsoemail) { // $object is 'Adherent' $subject = ''; - $msg = ''; + $msg = ''; - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); - // Attach a file ? - $file = ''; - $listofpaths = array(); - $listofnames = array(); - $listofmimes = array(); - if (is_object($object->invoice)) { - $invoicediroutput = $conf->facture->dir_output; - $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; + // Attach a file ? + $file = ''; + $listofpaths = array(); + $listofnames = array(); + $listofmimes = array(); + if (is_object($object->invoice)) { + $invoicediroutput = $conf->facture->dir_output; + $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; - $listofpaths = array($file); - $listofnames = array(basename($file)); - $listofmimes = array(dol_mimetype($file)); - } + $listofpaths = array($file); + $listofnames = array(basename($file)); + $listofmimes = array(dol_mimetype($file)); + } - $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; + $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); - if ($result < 0) { - $errmsg = $object->error; - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); - } - } else { - setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs'); - } - } + $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); + if ($result < 0) { + $errmsg = $object->error; + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); + } + } else { + setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs'); + } + } - // Clean some POST vars - if (!$error) { - $_POST["subscription"] = ''; - $_POST["accountid"] = ''; - $_POST["operation"] = ''; - $_POST["label"] = ''; - $_POST["num_chq"] = ''; - } - } + // Clean some POST vars + if (!$error) { + $_POST["subscription"] = ''; + $_POST["accountid"] = ''; + $_POST["operation"] = ''; + $_POST["label"] = ''; + $_POST["num_chq"] = ''; + } + } } @@ -393,32 +393,32 @@ if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($rowid > 0) { - $res = $object->fetch($rowid); - if ($res < 0) { dol_print_error($db, $object->error); exit; } + $res = $object->fetch($rowid); + if ($res < 0) { dol_print_error($db, $object->error); exit; } - $adht->fetch($object->typeid); + $adht->fetch($object->typeid); - $head = member_prepare_head($object); + $head = member_prepare_head($object); - $rowspan = 10; - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; - if (!empty($conf->societe->enabled)) $rowspan++; + $rowspan = 10; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; + if (!empty($conf->societe->enabled)) $rowspan++; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - dol_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); + print dol_get_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'rowid', $linkback); + dol_banner_tab($object, 'rowid', $linkback); - print '
'; - print '
'; + print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { @@ -443,20 +443,20 @@ if ($rowid > 0) { if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; } - print '
'.$langs->trans("Password").''.preg_replace('/./i', '*', $object->pass); if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) { - $langs->load("errors"); - $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); - print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); + $langs->load("errors"); + $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); + print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); } print '
'; + print ''; - print '
'; - print '
'; + print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; // Birthday print ''; @@ -472,25 +472,25 @@ if ($rowid > 0) { print ''; } - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Date end subscription print ''; @@ -550,100 +550,100 @@ if ($rowid > 0) { } print ''; - print "
'.$langs->trans("Birthday").''.dol_print_date($object->birth, 'day').'
'.$langs->trans("SubscriptionEndDate").''; if ($object->datefin) { - print dol_print_date($object->datefin, 'day'); - if ($object->hasDelay()) { - print " ".img_warning($langs->trans("Late")); - } + print dol_print_date($object->datefin, 'day'); + if ($object->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } } else { - if (!$adht->subscription) { - print $langs->trans("SubscriptionNotRecorded"); - if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled - } else { - print $langs->trans("SubscriptionNotReceived"); - if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled - } + if (!$adht->subscription) { + print $langs->trans("SubscriptionNotRecorded"); + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled + } else { + print $langs->trans("SubscriptionNotReceived"); + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled + } } print '
\n"; + print "\n"; print "
\n"; - print '
'; + print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); - print ''; + print ''; - /* + /* * Action buttons */ - // Button to create a new subscription if member no draft neither resiliated - if ($user->rights->adherent->cotisation->creer) { - if ($action != 'addsubscription' && $action != 'create_thirdparty') { - print '
'; + // Button to create a new subscription if member no draft neither resiliated + if ($user->rights->adherent->cotisation->creer) { + if ($action != 'addsubscription' && $action != 'create_thirdparty') { + print '
'; - if ($object->statut > 0) print '"; - else print ''; + if ($object->statut > 0) print '"; + else print ''; - print '
'; - } - } + print '
'; + } + } - /* + /* * List of subscriptions */ - if ($action != 'addsubscription' && $action != 'create_thirdparty') { - $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; - $sql .= " c.rowid as crowid, c.subscription,"; - $sql .= " c.datec, c.fk_type as cfk_type,"; - $sql .= " c.dateadh as dateh,"; - $sql .= " c.datef,"; - $sql .= " c.fk_bank,"; - $sql .= " b.rowid as bid,"; - $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid; + if ($action != 'addsubscription' && $action != 'create_thirdparty') { + $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; + $sql .= " c.rowid as crowid, c.subscription,"; + $sql .= " c.datec, c.fk_type as cfk_type,"; + $sql .= " c.dateadh as dateh,"; + $sql .= " c.datef,"; + $sql .= " c.fk_bank,"; + $sql .= " b.rowid as bid,"; + $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid; $sql .= $db->order($sortfield, $sortorder); - $result = $db->query($sql); - if ($result) { - $subscriptionstatic = new Subscription($db); + $result = $db->query($sql); + if ($result) { + $subscriptionstatic = new Subscription($db); - $num = $db->num_rows($result); + $num = $db->num_rows($result); - print ''."\n"; + print '
'."\n"; - print ''; - print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->banque->enabled)) { - print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - } - print "\n"; + print ''; + print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($conf->banque->enabled)) { + print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + } + print "\n"; - $accountstatic = new Account($db); - $adh = new Adherent($db); - $adht = new AdherentType($db); + $accountstatic = new Account($db); + $adh = new Adherent($db); + $adht = new AdherentType($db); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); - $adh->id = $objp->rowid; - $adh->typeid = $objp->type; + $adh->id = $objp->rowid; + $adh->typeid = $objp->type; - $subscriptionstatic->ref = $objp->crowid; - $subscriptionstatic->id = $objp->crowid; + $subscriptionstatic->ref = $objp->crowid; + $subscriptionstatic->id = $objp->crowid; - $typeid = $objp->cfk_type; - if ($typeid > 0) { - $adht->fetch($typeid); - } + $typeid = $objp->cfk_type; + if ($typeid > 0) { + $adht->fetch($typeid); + } - print ''; - print ''; - print '\n"; - print ''; - print '\n"; - print '\n"; - print ''; + print ''; + print ''; + print '\n"; + print ''; + print '\n"; + print '\n"; + print ''; if (!empty($conf->banque->enabled)) { print ''; - } - print ""; - $i++; - } + $accountstatic->ref = $objp->ref; + print $accountstatic->getNomUrl(1); + } else { + print ' '; + } + print ''; + } + print ""; + $i++; + } - if (empty($num)) { - $colspan = 6; - if (!empty($conf->banque->enabled)) $colspan++; - print ''; - } + if (empty($num)) { + $colspan = 6; + if (!empty($conf->banque->enabled)) $colspan++; + print ''; + } - print "
'.$subscriptionstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec), 'dayhour')."'; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''.dol_print_date($db->jdate($objp->dateh), 'day')."'.dol_print_date($db->jdate($objp->datef), 'day')."'.price($objp->subscription).'
'.$subscriptionstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec), 'dayhour')."'; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''.dol_print_date($db->jdate($objp->dateh), 'day')."'.dol_print_date($db->jdate($objp->datef), 'day')."'.price($objp->subscription).''; if ($objp->bid) { @@ -660,71 +660,71 @@ if ($rowid > 0) { $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } - $accountstatic->ref = $objp->ref; - print $accountstatic->getNomUrl(1); - } else { - print ' '; - } - print '
'.$langs->trans("None").'
'.$langs->trans("None").'
"; - } else { - dol_print_error($db); - } - } + print ""; + } else { + dol_print_error($db); + } + } - if (($action != 'addsubscription' && $action != 'create_thirdparty')) { - // Shon online payment link - $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); + if (($action != 'addsubscription' && $action != 'create_thirdparty')) { + // Shon online payment link + $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); - if ($useonlinepayment) { - print '
'; + if ($useonlinepayment) { + print '
'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - print showOnlinePaymentUrl('membersubscription', $object->ref); - print '
'; - } - } + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('membersubscription', $object->ref); + print '
'; + } + } - /* + /* * Add new subscription form */ - if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { - print '
'; + if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { + print '
'; - print load_fiche_titre($langs->trans("NewCotisation")); + print load_fiche_titre($langs->trans("NewCotisation")); - // Define default choice for complementary actions - $bankdirect = 0; // 1 means option by default is write to bank direct with no invoice - $invoiceonly = 0; // 1 means option by default is invoice only - $bankviainvoice = 0; // 1 means option by default is write to bank via invoice - if (GETPOST('paymentsave')) { - if (GETPOST('paymentsave') == 'bankdirect') $bankdirect = 1; - if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly = 1; - if (GETPOST('paymentsave') == 'bankviainvoice') $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)) $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)) $invoiceonly = 1; - } + // Define default choice for complementary actions + $bankdirect = 0; // 1 means option by default is write to bank direct with no invoice + $invoiceonly = 0; // 1 means option by default is invoice only + $bankviainvoice = 0; // 1 means option by default is write to bank via invoice + if (GETPOST('paymentsave')) { + if (GETPOST('paymentsave') == 'bankdirect') $bankdirect = 1; + if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly = 1; + if (GETPOST('paymentsave') == 'bankviainvoice') $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)) $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)) $invoiceonly = 1; + } - print "\n\n\n"; + print "\n\n\n"; - if ($conf->use_javascript_ajax) { - //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); - print "\n".''."\n"; - } + if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);'; + print '});'; + print ''."\n"; + } // Confirm create third party @@ -778,16 +778,16 @@ if ($rowid > 0) { if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { $tmpcompany = new Societe($db); $tmpcompany->name = $companyname; - $tmpcompany->get_codeclient($tmpcompany, 0); + $tmpcompany->get_codeclient($tmpcompany, 0); $customercode = $tmpcompany->code_client; $formquestion[] = array( - 'label' => $langs->trans("CustomerCode"), - 'type' => 'text', - 'name' => 'customercode', - 'value' => $customercode, - 'morecss' => 'minwidth300', - 'moreattr' => 'maxlength="128"', - ); + 'label' => $langs->trans("CustomerCode"), + 'type' => 'text', + 'name' => 'customercode', + 'value' => $customercode, + 'morecss' => 'minwidth300', + 'moreattr' => 'maxlength="128"', + ); } // @todo Add other extrafields mandatory for thirdparty creation @@ -795,99 +795,99 @@ if ($rowid > 0) { } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - dol_fiche_head(''); + print dol_get_fiche_head(''); print "\n"; - print ''; + print ''; $today = dol_now(); - $datefrom = 0; - $dateto = 0; - $paymentdate = -1; + $datefrom = 0; + $dateto = 0; + $paymentdate = -1; - // Date payment - if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { - $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); - } + // Date payment + if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { + $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); + } - print ''; - // Date start subscription - print '"; + print ''; + // Date start subscription + print '"; - // Date end subscription - if (GETPOST('endday')) { - $dateto = dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - } - if (!$dateto) { - $dateto = -1; // By default, no date is suggested - } - print '"; + // Date end subscription + if (GETPOST('endday')) { + $dateto = dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); + } + if (!$dateto) { + $dateto = -1; // By default, no date is suggested + } + print '"; - if ($adht->subscription) { - // Amount - print ''; + if ($adht->subscription) { + // Amount + print ''; - // Label - print ''; - print ''; + // Label + print ''; + print ''; - // Complementary action - if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { - $company = new Societe($db); - if ($object->fk_soc) { - $result = $company->fetch($object->fk_soc); - } + // Complementary action + if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { + $company = new Societe($db); + if ($object->fk_soc) { + $result = $company->fetch($object->fk_soc); + } - // Title payments - //print ''; + // Title payments + //print ''; - // No more action - print ''; - print ''; + print ''; + print '
'; + } + print ''; - // Bank account - print '\n"; + // Bank account + print '\n"; - // Payment mode - print '\n"; + // Payment mode + print '\n"; - // Date of payment - print '\n"; + // Date of payment + print '\n"; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; - } - } + print ''; + print ''; + } + } - print ''; + print ''; - print ''; - print ''; + print ''; - print ''; - print '
'.$langs->trans("DateSubscription").''; - if (GETPOST('reday')) { - $datefrom = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - } - if (!$datefrom) { - $datefrom = $object->datevalid; - if ($object->datefin > 0) { - $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); - } - } - print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); - print "
'.$langs->trans("DateSubscription").''; + if (GETPOST('reday')) { + $datefrom = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + } + if (!$datefrom) { + $datefrom = $object->datevalid; + if ($object->datefin > 0) { + $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + } + } + print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); + print "
'.$langs->trans("DateEndSubscription").''; - print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0); - print "
'.$langs->trans("DateEndSubscription").''; + print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0); + print "
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Payment").'
'.$langs->trans("Payment").'
'.$langs->trans('MoreActions'); - print ''; - print ' '.$langs->trans("None").'
'; - // Add entry into bank accoun - if (!empty($conf->banque->enabled)) { - print ' '.$langs->trans("MoreActionBankDirect").'
'; - } - // Add invoice with no payments - if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { - print 'fk_soc)) print ' disabled'; - print '> '.$langs->trans("MoreActionInvoiceOnly"); - if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else { - print ' ('; - if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); - print $langs->trans("NoThirdPartyAssociatedToMember"); - print ' - '; - print $langs->trans("CreateDolibarrThirdParty"); - print ')'; - } - if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; + // No more action + print '
'.$langs->trans('MoreActions'); + print ''; + print ' '.$langs->trans("None").'
'; + // Add entry into bank accoun + if (!empty($conf->banque->enabled)) { + print ' '.$langs->trans("MoreActionBankDirect").'
'; + } + // Add invoice with no payments + if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { + print 'fk_soc)) print ' disabled'; + print '> '.$langs->trans("MoreActionInvoiceOnly"); + if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + else { + print ' ('; + if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); + print $langs->trans("NoThirdPartyAssociatedToMember"); + print ' - '; + print $langs->trans("CreateDolibarrThirdParty"); + print ')'; + } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $prodtmp = new Product($db); $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); @@ -896,23 +896,23 @@ if ($rowid > 0) { } print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } - print '
'; - } - // Add invoice with payments - if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { - print 'fk_soc)) print ' disabled'; - print '> '.$langs->trans("MoreActionBankViaInvoice"); - if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else { - print ' ('; - if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); - print $langs->trans("NoThirdPartyAssociatedToMember"); - print ' - '; - print $langs->trans("CreateDolibarrThirdParty"); - print ')'; - } - if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; + print '
'; + } + // Add invoice with payments + if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { + print 'fk_soc)) print ' disabled'; + print '> '.$langs->trans("MoreActionBankViaInvoice"); + if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + else { + print ' ('; + if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); + print $langs->trans("NoThirdPartyAssociatedToMember"); + print ' - '; + print $langs->trans("CreateDolibarrThirdParty"); + print ')'; + } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $prodtmp = new Product($db); $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); @@ -921,123 +921,123 @@ if ($rowid > 0) { } print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } - print '
'; - } - print '
'.$langs->trans("FinancialAccount").''; - $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 1); - print "
'.$langs->trans("FinancialAccount").''; + $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); + print "
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); - print "
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); + print "
'.$langs->trans("DatePayment").''; - print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); - print "
'.$langs->trans("DatePayment").''; + print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); + print "
'.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print '
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans('CheckTransmitter'); - print ' ('.$langs->trans("ChequeMaker").')'; - print '
'.$langs->trans('CheckTransmitter'); + print ' ('.$langs->trans("ChequeMaker").')'; + print '
'.$langs->trans('Bank'); - print ' ('.$langs->trans("ChequeBank").')'; - print '
'.$langs->trans('Bank'); + print ' ('.$langs->trans("ChequeBank").')'; + print '
'.$langs->trans("SendAcknowledgementByMail").''; - if (!$object->email) { - print $langs->trans("NoEMail"); - } else { - $adht = new AdherentType($db); - $adht->fetch($object->typeid); + print '
'.$langs->trans("SendAcknowledgementByMail").''; + if (!$object->email) { + print $langs->trans("NoEMail"); + } else { + $adht = new AdherentType($db); + $adht->fetch($object->typeid); - // Send subscription email - $subject = ''; - $msg = ''; + // Send subscription email + $subject = ''; + $msg = ''; - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); - $tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; - $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; - $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; - $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; - if ($subjecttosend) { - $helpcontent .= $subjecttosend."\n"; - } else { - $langs->load("errors"); - $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; - } - $helpcontent .= "
"; - $helpcontent .= ''.$langs->trans("MailText").':
'; - if ($texttosend) { - $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; - } else { - $langs->load("errors"); - $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; - } - print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); - } - print '
'; + $tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; + $helpcontent = ''; + $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; + if ($subjecttosend) { + $helpcontent .= $subjecttosend."\n"; + } else { + $langs->load("errors"); + $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; + } + $helpcontent .= "
"; + $helpcontent .= ''.$langs->trans("MailText").':
'; + if ($texttosend) { + $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; + } else { + $langs->load("errors"); + $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; + } + print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); + } + print ''; + print ''; + print ''; - dol_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; - print '
'; + print ''; - print "\n\n\n"; - } + print "\n\n\n"; + } - //print ''; - //print ''; + //print ''; + //print ''; } else { - $langs->load("errors"); - print $langs->trans("ErrorRecordNotFound"); + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); } // End of page diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 017962701e4..c97c502abaf 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,10 +40,13 @@ $object = new Subscription($db); $errmsg = ''; $action = GETPOST("action", 'alpha'); -$rowid = GETPOST("rowid", "int") ?GETPOST("rowid", "int") : GETPOST("id", "int"); +$rowid = GETPOST("rowid", "int") ? GETPOST("rowid", "int") : GETPOST("id", "int"); $typeid = GETPOST("typeid", "int"); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm'); +$note = GETPOST('note', 'alpha'); +$typeid = (int) GETPOST('typeid', 'int'); +$amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (!$user->rights->adherent->cotisation->lire) accessforbidden(); @@ -84,7 +87,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance } else { $accountline->datev = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); $accountline->dateo = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $accountline->amount = $_POST["amount"]; + $accountline->amount = $amount; $result = $accountline->update($user); if ($result < 0) { $errmsg = $accountline->error; @@ -96,9 +99,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance // Modify values $object->dateh = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); $object->datef = dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']); - $object->fk_type = $_POST["typeid"]; - $object->note = $_POST["note"]; - $object->amount = $_POST["amount"]; + $object->fk_type = $typeid; + $object->note = $note; + $object->amount = $amount; //print 'datef='.$object->datef.' '.$_POST['datesubendday']; $result = $object->update($user); @@ -170,7 +173,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') { print ""; print "fk_bank."\">"; - dol_fiche_head($head, 'general', $langs->trans("Subscription"), 0, 'payment'); + print dol_get_fiche_head($head, 'general', $langs->trans("Subscription"), 0, 'payment'); $linkback = ''.$langs->trans("BackToList").''; @@ -216,23 +219,21 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') { print ''; // Bank line - if (!empty($conf->banque->enabled)) { - if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { - print ''.$langs->trans("BankTransactionLine").''; - if ($object->fk_bank) { - $bankline = new AccountLine($db); - $result = $bankline->fetch($object->fk_bank); - print $bankline->getNomUrl(1, 0, 'showall'); - } else { - print $langs->trans("NoneF"); - } - print ''; + if (!empty($conf->banque->enabled) && ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)) { + print ''.$langs->trans("BankTransactionLine").''; + if ($object->fk_bank) { + $bankline = new AccountLine($db); + $result = $bankline->fetch($object->fk_bank); + print $bankline->getNomUrl(1, 0, 'showall'); + } else { + print $langs->trans("NoneF"); } + print ''; } print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -256,7 +257,7 @@ if ($rowid && $action != 'edit') { $head = subscription_prepare_head($object); - dol_fiche_head($head, 'general', $langs->trans("Subscription"), -1, 'payment'); + print dol_get_fiche_head($head, 'general', $langs->trans("Subscription"), -1, 'payment'); // Confirmation to delete subscription if ($action == 'delete') { @@ -316,18 +317,16 @@ if ($rowid && $action != 'edit') { print ''.$langs->trans("Label").''.$object->note.''; // Bank line - if (!empty($conf->banque->enabled)) { - if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { - print ''.$langs->trans("BankTransactionLine").''; - if ($object->fk_bank) { - $bankline = new AccountLine($db); - $result = $bankline->fetch($object->fk_bank); - print $bankline->getNomUrl(1, 0, 'showall'); - } else { - print $langs->trans("NoneF"); - } - print ''; + if (!empty($conf->banque->enabled) && ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)) { + print ''.$langs->trans("BankTransactionLine").''; + if ($object->fk_bank) { + $bankline = new AccountLine($db); + $result = $bankline->fetch($object->fk_bank); + print $bankline->getNomUrl(1, 0, 'showall'); + } else { + print $langs->trans("NoneF"); } + print ''; } print "\n"; @@ -335,7 +334,7 @@ if ($rowid && $action != 'edit') { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Barre d'actions diff --git a/htdocs/adherents/subscription/info.php b/htdocs/adherents/subscription/info.php index 78b3fd4384b..a7a4a897505 100644 --- a/htdocs/adherents/subscription/info.php +++ b/htdocs/adherents/subscription/info.php @@ -51,7 +51,7 @@ $result = $object->fetch($rowid); $head = subscription_prepare_head($object); -dol_fiche_head($head, 'info', $langs->trans("Subscription"), -1, 'payment'); +print dol_get_fiche_head($head, 'info', $langs->trans("Subscription"), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; @@ -72,7 +72,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 364a7854fb7..92e495ad93b 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -110,22 +110,22 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_type = ""; - $search_ref = ""; - $search_lastname = ""; - $search_firstname = ""; - $search_login = ""; - $search_note = ""; - $search_amount = ""; - $search_account = ""; - $toselect = ''; - $search_array_options = array(); - } + $search_ref = ""; + $search_lastname = ""; + $search_firstname = ""; + $search_login = ""; + $search_note = ""; + $search_amount = ""; + $search_account = ""; + $toselect = ''; + $search_array_options = array(); + } } @@ -142,6 +142,7 @@ $now = dol_now(); // List of subscriptions $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut,"; +$sql .= " d.gender, d.email, d.morphy,"; $sql .= " c.rowid as crowid, c.fk_type, c.subscription,"; $sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,"; $sql .= " c.fk_bank as bank, c.note,"; @@ -151,10 +152,9 @@ $sql .= " JOIN ".MAIN_DB_PREFIX."subscription as c on d.rowid = c.fk_adherent"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -if (isset($date_select) && $date_select != '') -{ - $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'"; - $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'"; +if (isset($date_select) && $date_select != '') { + $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'"; + $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'"; } if ($search_ref) { if (is_numeric($search_ref)) $sql .= " AND (c.rowid = ".$db->escape($search_ref).")"; @@ -181,13 +181,13 @@ $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)) { - $resql = $db->query($sql); - if ($resql) $nbtotalofrecords = $db->num_rows($resql); - else dol_print_error($db); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + $resql = $db->query($sql); + if ($resql) $nbtotalofrecords = $db->num_rows($resql); + 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; - } + $offset = 0; + } } // Add limit $sql .= $db->plimit($limit + 1, $offset); @@ -241,7 +241,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; if ($user->rights->adherent->cotisation->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); } print '
'; @@ -403,11 +403,14 @@ while ($i < min($num, $limit)) { $adherent->statut = $obj->statut; $adherent->login = $obj->login; $adherent->photo = $obj->photo; + $adherent->gender = $obj->gender; + $adherent->morphy = $obj->morphy; + $adherent->email = $obj->email; $adherent->typeid = $obj->type; $typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid); - $adht = new AdherentType($db); - $adht->fetch($typeid); + $adht = new AdherentType($db); + $adht->fetch($typeid); print ''; @@ -416,14 +419,14 @@ while ($i < min($num, $limit)) { print ''.$subscription->getNomUrl(1).''; if (!$i) $totalarray['nbfield']++; } - // Type - if (!empty($arrayfields['d.fk_type']['checked'])) { - print ''; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''; - if (!$i) $totalarray['nbfield']++; + // Type + if (!empty($arrayfields['d.fk_type']['checked'])) { + print ''; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''; + if (!$i) $totalarray['nbfield']++; } // Lastname diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index 136c1dab8f4..0414bf20a14 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -33,12 +33,12 @@ $langs->load("members"); $total = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - echo ''; - echo ''.$langs->trans("Subscription").''; - echo ''.$objectlink->getNomUrl(1).''; - echo ''; - echo ''.dol_print_date($objectlink->dateh, 'day').''; - echo ''; + echo ''; + echo ''.$langs->trans("Subscription").''; + echo ''.$objectlink->getNomUrl(1).''; + echo ''; + echo ''.dol_print_date($objectlink->dateh, 'day').''; + echo ''; if ($user->rights->adherent->lire) { $total = $total + $objectlink->amount; echo price($objectlink->amount); @@ -46,7 +46,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo ''; echo ''; echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; - echo ''; + echo ''; } echo "\n"; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index ecd709bdd17..fc1d7ecb1d9 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -207,7 +207,7 @@ llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Modul // List of members type if (!$rowid && $action != 'create' && $action != 'edit') { - //dol_fiche_head(''); + //print dol_get_fiche_head(''); $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut as status, d.morphy"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; @@ -247,7 +247,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; print ''.$langs->trans("Ref").''; print ''.$langs->trans("Label").''; - print ''.$langs->trans("MemberNature").''; + print ''.$langs->trans("MembersNature").''; print ''.$langs->trans("SubscriptionRequired").''; print ''.$langs->trans("VoteAllowed").''; print ''.$langs->trans("Status").''; @@ -263,6 +263,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $membertype->ref = $objp->rowid; $membertype->label = $objp->rowid; $membertype->status = $objp->status; + $membertype->subscription = $objp->subscription; print ''; print ''; @@ -271,7 +272,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; print ''.dol_escape_htmltag($objp->label).''; print ''; - if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorPhy"); + if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorAndPhy"); print ''; print ''.yn($objp->subscription).''; print ''.yn($objp->vote).''; @@ -308,7 +309,7 @@ if ($action == 'create') { print ''; print ''; - dol_fiche_head(''); + print dol_get_fiche_head(''); print ''; print ''; @@ -321,10 +322,10 @@ if ($action == 'create') { // Morphy $morphys = array(); - $morphys[""] = $langs->trans("MorPhy"); - $morphys["phy"] = $langs->trans("Physical"); + $morphys[""] = $langs->trans("MorAndPhy"); + $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); - print '"; @@ -343,12 +344,12 @@ if ($action == 'create') { print ''; @@ -358,7 +359,7 @@ if ($action == 'create') { print ''; print "
'.$langs->trans("MemberNature").''; + print '
'.$langs->trans("MembersNature").''; print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy'); print "
'.$langs->trans("Description").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('comment', $object->note, '', 200, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print '
'.$langs->trans("WelcomeEMail").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print '
\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -389,7 +390,7 @@ if ($rowid > 0) { $head = member_type_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group'); + print dol_get_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group'); $linkback = ''.$langs->trans("BackToList").''; @@ -401,7 +402,7 @@ if ($rowid > 0) { print ''; // Morphy - print ''; + print ''; print ''; print '
'.$langs->trans("MemberNature").''.$object->getmorphylib($object->morphy).'
'.$langs->trans("MembersNature").''.$object->getmorphylib($object->morphy).'
'.$langs->trans("SubscriptionRequired").''; @@ -433,7 +434,7 @@ if ($rowid > 0) { print '
'; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Buttons @@ -614,13 +615,16 @@ if ($rowid > 0) { $adh = new Adherent($db); $adh->lastname = $objp->lastname; $adh->firstname = $objp->firstname; + $adh->datefin = $datefin; + $adh->need_subscription = $objp->subscription; + $adh->statut = $objp->status; // Lastname print ''; if ($objp->company != '') { - print ''.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).''."\n"; + print ''.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->company, 12).''."\n"; } else { - print ''.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).''."\n"; + print ''.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 32).''."\n"; } // Login @@ -640,9 +644,9 @@ if ($rowid > 0) { // EMail print "".dol_print_email($objp->email, 0, 0, 1)."\n"; - // Statut + // Status print ''; - print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2); + print $adh->getLibStatut(2); print ""; // Date end subscription @@ -668,11 +672,10 @@ if ($rowid > 0) { // Actions print ''; if ($user->rights->adherent->creer) { - print ''.img_edit().''; + print ''.img_edit().''; } - print ' '; if ($user->rights->adherent->supprimer) { - print ''.img_picto($langs->trans("Resiliate"), 'disable.png').''; + print ''.img_picto($langs->trans("Resiliate"), 'disable.png').''; } print ""; @@ -710,7 +713,7 @@ if ($rowid > 0) { print ''; print ''; - dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); + print dol_get_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); print ''; @@ -723,11 +726,11 @@ if ($rowid > 0) { print ''; // Morphy - $morphys[""] = $langs->trans("MorPhy"); + $morphys[""] = $langs->trans("MorAndPhy"); $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); - print '"; print '
'.$langs->trans("MemberNature").''; - print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy); + print '
'.$langs->trans("MembersNature").''; + print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : $object->morphy); print "
'.$langs->trans("SubscriptionRequired").''; @@ -759,7 +762,7 @@ if ($rowid > 0) { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index 5e745293050..1d37f337a78 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -86,7 +86,7 @@ $form = new Form($db); $head = member_type_prepare_head($object); -dol_fiche_head($head, 'ldap', $langs->trans("MemberType"), -1, 'group'); +print dol_get_fiche_head($head, 'ldap', $langs->trans("MemberType"), -1, 'group'); $linkback = ''.$langs->trans("BackToList").''; @@ -114,7 +114,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); /* * Action bar @@ -123,7 +123,7 @@ dol_fiche_end(); print '
'; if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) { - print ''.$langs->trans("ForceSynchronize").''; + print ''.$langs->trans("ForceSynchronize").''; } print "
\n"; @@ -146,27 +146,27 @@ print ''; $ldap = new Ldap(); $result = $ldap->connect_bind(); if ($result > 0) { - $info = $object->_load_ldap_info(); - $dn = $object->_load_ldap_dn($info, 1); - $search = "(".$object->_load_ldap_dn($info, 2).")"; + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info, 1); + $search = "(".$object->_load_ldap_dn($info, 2).")"; - $records = $ldap->getAttribute($dn, $search); + $records = $ldap->getAttribute($dn, $search); - //print_r($records); + //print_r($records); - // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (!is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; - } else { - $result = show_ldap_content($records, 0, $records['count'], true); - } - } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; - } + // Show tree + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { + if (!is_array($records)) { + print ''.$langs->trans("ErrorFailedToReadLDAP").''; + } else { + $result = show_ldap_content($records, 0, $records['count'], true); + } + } else { + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + } - $ldap->unbind(); - $ldap->close(); + $ldap->unbind(); + $ldap->close(); } else { setEventMessages($ldap->error, $ldap->errors, 'errors'); } diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 10c43dadbe3..3aafef6f216 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -154,19 +154,19 @@ $titre = $langs->trans("MemberType".$object->type); // Calculate $cnt_trans $cnt_trans = 0; if (!empty($object->multilangs)) { - foreach ($object->multilangs as $key => $value) { - $cnt_trans++; - } + foreach ($object->multilangs as $key => $value) { + $cnt_trans++; + } } -dol_fiche_head($head, 'translation', $titre, 0, 'group'); +print dol_get_fiche_head($head, 'translation', $titre, 0, 'group'); $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'rowid', $linkback); -dol_fiche_end(); +print dol_get_fiche_end(); @@ -179,10 +179,10 @@ dol_fiche_end(); print "\n
\n"; if ($action == '') { - if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''.$langs->trans("Add").''; - if ($cnt_trans > 0) print ''.$langs->trans("Update").''; - } + if ($user->rights->produit->creer || $user->rights->service->creer) { + print ''.$langs->trans("Add").''; + if ($cnt_trans > 0) print ''.$langs->trans("Update").''; + } } print "\n
\n"; @@ -258,11 +258,11 @@ if ($action == 'add' && $user->rights->adherent->configurer) { print ''; print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print ''; print ''; print ''; print '
'.$langs->trans('Language').''; - print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); + print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; @@ -272,7 +272,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php index 6f2a274aed9..dbdbbc687ea 100644 --- a/htdocs/adherents/vcard.php +++ b/htdocs/adherents/vcard.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,8 +40,7 @@ $result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objc $result = $adherent->fetch($id); -if ($result <= 0) -{ +if ($result <= 0) { dol_print_error($adherent->error); exit; } @@ -48,8 +48,7 @@ if ($result <= 0) $physicalperson = 1; $company = new Societe($db); -if ($adherent->socid) -{ +if ($adherent->socid) { $result = $company->fetch($adherent->socid); } @@ -66,43 +65,41 @@ $v->setPhoneNumber($adherent->phone_pro, "TYPE=WORK;VOICE"); $v->setPhoneNumber($adherent->phone_mobile, "TYPE=CELL;VOICE"); $v->setPhoneNumber($adherent->fax, "TYPE=WORK;FAX"); -$country = $adherent->country_code ? $adherent->country : '' ; +$country = $adherent->country_code ? $adherent->country : ''; $v->setAddress("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK;POSTAL"); $v->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK"); $v->setEmail($adherent->email); -$v->setNote($adherent->note); +$v->setNote($adherent->note_public); $v->setTitle($adherent->poste); // Data from linked company -if ($company->id) -{ +if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (! $adherent->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); - if (! $adherent->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); - if (! $adherent->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); - + if (!$adherent->phone_pro) { + $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); + } + if (!$adherent->fax) { + $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); + } + if (!$adherent->zip) { + $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + } // when company e-mail is empty, use only adherent e-mail - if (empty(trim($company->email))) - { + if (empty(trim($company->email))) { // was set before, don't set twice - } - // when adherent e-mail is empty, use only company e-mail - elseif (empty(trim($adherent->email))) - { + } elseif (empty(trim($adherent->email))) { + // when adherent e-mail is empty, use only company e-mail $v->setEmail($company->email); - } - // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second) - elseif (strtolower(end(explode("@", $adherent->email))) == strtolower(end(explode("@", $company->email)))) - { + } elseif (strtolower(end(explode("@", $adherent->email))) == strtolower(end(explode("@", $company->email)))) { + // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second) $v->setEmail($adherent->email); // support by Microsoft Outlook (2019 and possible earlier) $v->setEmail($company->email, 'INTERNET'); - } - // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second) - else { + } else { + // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second) $v->setEmail($company->email); // support by Microsoft Outlook (2019 and possible earlier) @@ -110,12 +107,16 @@ if ($company->id) } // Si adherent lie a un tiers non de type "particulier" - if ($adherent->typent_code != 'TE_PRIVATE') $v->setOrg($company->name); + if ($company->typent_code != 'TE_PRIVATE') { + $v->setOrg($company->name); + } } // Personal informations $v->setPhoneNumber($adherent->phone_perso, "TYPE=HOME;VOICE"); -if ($adherent->birthday) $v->setBirthday($adherent->birthday); +if ($adherent->birth) { + $v->setBirthday($adherent->birth); +} $db->close(); @@ -124,7 +125,7 @@ $db->close(); $output = $v->getVCard(); -$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" +$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); //$filename = dol_sanitizeFileName($filename); diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index b039032b9c2..cbf9fdbaa50 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -82,7 +82,7 @@ print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup'); $head = company_admin_prepare_head(); -dol_fiche_head($head, 'accountant', $langs->trans("Company"), -1, 'company'); +print dol_get_fiche_head($head, 'accountant', $langs->trans("Company"), -1, 'company'); $form = new Form($db); $formother = new FormOther($db); diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 2cc79be297d..1f4236df666 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'agenda')); @@ -86,9 +86,9 @@ if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') | if ($action == "save" && empty($cancel)) { - $i = 0; + $i = 0; - $db->begin(); + $db->begin(); foreach ($triggers as $trigger) { @@ -102,13 +102,13 @@ if ($action == "save" && empty($cancel)) } if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - $db->commit(); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - $db->rollback(); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + $db->commit(); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + $db->rollback(); + } } @@ -132,7 +132,7 @@ $param .= '&search_event='.urlencode($search_event); $head = agenda_prepare_head(); -dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action'); +print dol_get_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action'); print ''.$langs->trans("AgendaAutoActionDesc")." ".$langs->trans("OnlyActiveElementsAreShown", 'modules.php').'
'; print "
\n"; @@ -197,7 +197,7 @@ if (!empty($triggers)) print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index 605f3c76519..36c7bc3edf8 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -74,19 +74,19 @@ print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup'); $head = agenda_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Agenda"), -1, 'action'); +print dol_get_fiche_head($head, 'attributes', $langs->trans("Agenda"), -1, 'action'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -111,10 +111,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index e7e5edefaab..3cf0d49b960 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -54,9 +54,9 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', ' if ($actionsave) { - $db->begin(); + $db->begin(); - $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); + $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); $res = dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity); $i = 1; $errorsaved = 0; @@ -103,14 +103,14 @@ if ($actionsave) $MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB; } - if (!$error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* @@ -136,7 +136,7 @@ print ''; $head = agenda_prepare_head(); -dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action'); +print dol_get_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action'); print ''.$langs->trans("AgendaExtSitesDesc")."
\n"; print "
\n"; @@ -224,7 +224,7 @@ while ($i <= $MAXAGENDA) print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 48368af45f2..c390796a55b 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'agenda', 'users')); @@ -80,49 +80,49 @@ if ($action == 'set') $getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE'); $defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter; dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); } elseif ($action == 'specimen') // For orders { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); - $commande->thirdparty = $specimenthirdparty; + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + $commande->thirdparty = $specimenthirdparty; - // 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/action/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // 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/action/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $commande); + $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($commande, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -135,7 +135,7 @@ elseif ($action == 'setmodel') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); } } @@ -175,7 +175,7 @@ print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup'); $head = agenda_prepare_head(); -dol_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action'); +print dol_get_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action'); /* @@ -194,115 +194,115 @@ $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++; - } + $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); + dol_print_error($db); } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print load_fiche_titre($langs->trans("AgendaModelModule"), '', ''); + print load_fiche_titre($langs->trans("AgendaModelModule"), '', ''); - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''; - print ''."\n"; + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Default").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + print ''."\n"; - clearstatcache(); + clearstatcache(); - foreach ($dirmodels as $reldir) - { - $dir = dol_buildpath($reldir."core/modules/action/doc"); + foreach ($dirmodels as $reldir) + { + $dir = dol_buildpath($reldir."core/modules/action/doc"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $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, new ActionComm($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new ActionComm($db)); - print ''."\n"; - print "\n"; - print "\n"; + print ''."\n"; + print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print '"; - } else { - print '"; - } + // Active + if (in_array($name, $def)) + { + print '"; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $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); - print ''; - print ''; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $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); + print ''; + print ''; - print "\n"; - } - } - closedir($handle); - } - } - } - 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"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) - print $module->info($langs); - else print $module->description; - print "
"; + print (empty($module->name) ? $name : $module->name); + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) + print $module->info($langs); + else print $module->description; + print "'."\n"; - if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") - { - print 'scandir.'&label='.urlencode($module->name).'&type=action">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - } else { - print img_picto($langs->trans("Enabled"), 'switch_on'); - } - print "'."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") + { + print 'scandir.'&label='.urlencode($module->name).'&type=action">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + } else { + print img_picto($langs->trans("Enabled"), 'switch_on'); + } + print "'."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print '

'; + print "\n"; + } + } + closedir($handle); + } + } + } + print '
'; } print ''; @@ -343,13 +343,13 @@ print ''."\n"; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''; - print ''."\n"; - print ''.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").''."\n"; - print ' '."\n"; - print ''."\n"; - $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1); - print ''."\n"; + print ''; + print ''."\n"; + print ''.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").''."\n"; + print ' '."\n"; + print ''."\n"; + $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1); + print ''."\n"; } // AGENDA_DEFAULT_FILTER_TYPE @@ -359,8 +359,8 @@ print ' '."\n"; print ''."\n"; $multiselect = 0; if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) { - // We use an option here because it adds bugs when used on agenda page "peruser" and "list" - $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); + // We use an option here because it adds bugs when used on agenda page "peruser" and "list" + $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); } $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AGENDA_DEFAULT_FILTER_TYPE", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 1, $multiselect); print ''."\n"; @@ -376,7 +376,7 @@ print ''."\n"; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index e4b3c59781c..e34536e648a 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array("admin", "other", "agenda")); @@ -73,49 +73,49 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if ($action == 'set') { dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); } elseif ($action == 'specimen') // For orders { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); - $commande->thirdparty = $specimenthirdparty; + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + $commande->thirdparty = $specimenthirdparty; - // 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/action/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // 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/action/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $commande); + $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($commande, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -128,7 +128,7 @@ elseif ($action == 'setmodel') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); } } @@ -166,7 +166,7 @@ print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup'); $head = agenda_prepare_head(); -dol_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action'); +print dol_get_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action'); print ''; print ''; @@ -200,36 +200,36 @@ if ($conf->global->MAIN_FEATURES_LEVEL == 2) // AGENDA REMINDER BROWSER if ($conf->global->MAIN_FEATURES_LEVEL == 2) { - print ''."\n"; - print ''.$langs->trans('AGENDA_REMINDER_BROWSER').''."\n"; - print ' '."\n"; - print ''."\n"; + print ''."\n"; + print ''.$langs->trans('AGENDA_REMINDER_BROWSER').''."\n"; + print ' '."\n"; + print ''."\n"; - if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { - print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; - print ''."\n"; - } else { - print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; - print ''."\n"; + if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { + print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; + print ''."\n"; + } else { + print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; + print ''."\n"; - print ''."\n"; - print ''.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').''."\n"; - print ' '."\n"; - print ''."\n"; + print ''."\n"; + print ''.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').''."\n"; + print ' '."\n"; + print ''."\n"; - if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { - print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; - } else { - print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; - } + if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { + print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; + } else { + print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; + } - print ''."\n"; - } + print ''."\n"; + } } print ''; -dol_fiche_end(); +print dol_get_fiche_end(); //print '
'; diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 5b747260a05..61116a0f18f 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array("admin", "other", "agenda")); @@ -41,23 +41,23 @@ $actionsave = GETPOST('save', 'alpha'); // Sauvegardes parametres if ($actionsave) { - $i = 0; + $i = 0; - $db->begin(); + $db->begin(); - $i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity); - $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity); - $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity); - $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity); - if ($i >= 4) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($langs->trans("SaveFailed"), null, 'errors'); - } + if ($i >= 4) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($langs->trans("SaveFailed"), null, 'errors'); + } } @@ -80,7 +80,7 @@ print ''; $head = agenda_prepare_head(); -dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action'); +print dol_get_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action'); print ''.$langs->trans("AgendaSetupOtherDesc")."
\n"; print "
\n"; @@ -135,7 +135,7 @@ print ""; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print "trans("Save")."\">"; @@ -163,7 +163,7 @@ $urlvcal .= $urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentit $message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'vcal', $urlvcal); $message .= '
'; $urlical = ''; -$urlical .=$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').''; +$urlical .= $urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').''; $message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', $urlical); $message .= '
'; $urlrss = ''; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 772ef604ab5..c8157a40d81 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -215,7 +215,7 @@ print ''; print ''; $head = bank_admin_prepare_head(null); -dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'); +print dol_get_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'); //Show bank account order print load_fiche_titre($langs->trans("BankOrderShow"), '', ''); @@ -495,7 +495,7 @@ if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { print "\n"; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index 312da228f50..aff2b90d897 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -71,19 +71,19 @@ print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup $head = bank_admin_prepare_head(null); -dol_fiche_head($head, 'attributes', $langs->trans("BankSetupModule"), -1, 'account'); +print dol_get_fiche_head($head, 'attributes', $langs->trans("BankSetupModule"), -1, 'account'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -93,9 +93,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -103,10 +103,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 529e3289a31..0e7a23ae679 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -44,11 +44,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setbarcodeproducton') { - $barcodenumberingmodule = GETPOST('value', 'alpha'); + $barcodenumberingmodule = GETPOST('value', 'alpha'); $res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) { - $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); } } elseif ($action == 'setbarcodeproductoff') { @@ -76,45 +76,45 @@ if ($action == 'setcoder') $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity); if ($res > 0) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'updateengine') { - $sql = "SELECT rowid, coder"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; - $sql .= " WHERE entity = ".$conf->entity; - $sql .= " ORDER BY code"; + $sql = "SELECT rowid, coder"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " ORDER BY code"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - if (GETPOST('coder'.$obj->rowid, 'alpha')) - { - $coder = GETPOST('coder'.$obj->rowid, 'alpha'); - $code_id = $obj->rowid; + if (GETPOST('coder'.$obj->rowid, 'alpha')) + { + $coder = GETPOST('coder'.$obj->rowid, 'alpha'); + $code_id = $obj->rowid; - $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; - $sqlp .= " SET coder = '".$db->escape($coder)."'"; - $sqlp .= " WHERE rowid = ".((int) $code_id); - $sqlp .= " AND entity = ".$conf->entity; + $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; + $sqlp .= " SET coder = '".$db->escape($coder)."'"; + $sqlp .= " WHERE rowid = ".((int) $code_id); + $sqlp .= " AND entity = ".$conf->entity; - $upsql = $db->query($sqlp); - if (!$upsql) dol_print_error($db); - } + $upsql = $db->query($sqlp); + if (!$upsql) dol_print_error($db); + } - $i++; - } - } + $i++; + } + } } @@ -142,11 +142,11 @@ $dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_pa foreach ($dirbarcode as $reldir) { - $dir = dol_buildpath($reldir); - $newdir = dol_osencode($dir); + $dir = dol_buildpath($reldir); + $newdir = dol_osencode($dir); - // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) - if (!is_dir($newdir)) continue; + // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) + if (!is_dir($newdir)) continue; $handle = @opendir($newdir); if (is_resource($handle)) @@ -190,9 +190,9 @@ print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', ''); if (empty($conf->use_javascript_ajax)) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } print ''; @@ -236,11 +236,11 @@ if ($resql) foreach ($dirbarcode as $reldir) { - $dir = dol_buildpath($reldir, 0); - $newdir = dol_osencode($dir); + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); - // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) - if (!is_dir($newdir)) continue; + // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) + if (!is_dir($newdir)) continue; $result = @include_once $newdir.$obj->coder.'.modules.php'; if ($result) break; @@ -254,7 +254,7 @@ if ($resql) if ($module->encodingIsSupported($obj->encoding)) { // Build barcode on disk (not used, this is done to make debug easier) - $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); + $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); // Generate on the fly and output barcode with generator $url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding); //print $url; @@ -282,8 +282,8 @@ print "
\n"; if (empty($conf->use_javascript_ajax)) { - print '
'; - print ''; + print '
'; + print ''; } print "
"; @@ -371,48 +371,48 @@ if ($conf->product->enabled) $dir = dol_buildpath($dirroot, 0); $handle = @opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^mod_barcode_product_.*php$/', $file)) - { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/^mod_barcode_product_.*php$/', $file)) + { + $file = substr($file, 0, dol_strlen($file) - 4); - try { - dol_include_once($dirroot.$file.'.php'); - } catch (Exception $e) - { - dol_syslog($e->getMessage(), LOG_ERR); - } + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } - $modBarCode = new $file(); + $modBarCode = new $file(); - print ''; - print ''.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; - print $modBarCode->info($langs); - print ''; - print ''.$modBarCode->getExample($langs)."\n"; + print ''; + print ''.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; + print $modBarCode->info($langs); + print ''; + print ''.$modBarCode->getExample($langs)."\n"; - if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") - { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - $s = $modBarCode->getToolTip($langs, null, -1); - print $form->textwithpicto('', $s, 1); - print ''; - print "\n"; - } - } - closedir($handle); - } + if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") + { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + $s = $modBarCode->getToolTip($langs, null, -1); + print $form->textwithpicto('', $s, 1); + print ''; + print "\n"; + } + } + closedir($handle); + } } print "\n"; } diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index 3f331286aa2..db3bc348716 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -181,7 +181,7 @@ print load_fiche_titre($langs->trans("BOMsSetup"), $linkback, 'title_setup'); $head = bomAdminPrepareHead(); -dol_fiche_head($head, 'settings', $langs->trans("BOMs"), -1, 'bom'); +print dol_get_fiche_head($head, 'settings', $langs->trans("BOMs"), -1, 'bom'); /* * BOMs Numbering model diff --git a/htdocs/admin/bom_extrafields.php b/htdocs/admin/bom_extrafields.php index 7ec50d9d7db..f2022229305 100644 --- a/htdocs/admin/bom_extrafields.php +++ b/htdocs/admin/bom_extrafields.php @@ -70,19 +70,19 @@ print load_fiche_titre($langs->trans("BOMsSetup"), $linkback, 'title_setup'); $head = bomAdminPrepareHead(); -dol_fiche_head($head, 'bom_extrafields', $langs->trans("ExtraFields"), -1, 'account'); +print dol_get_fiche_head($head, 'bom_extrafields', $langs->trans("ExtraFields"), -1, 'account'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -92,9 +92,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -102,10 +102,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 6de752518c0..4fee30d274e 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -99,7 +99,7 @@ $linkback = 'trans("BankSetupModule"), -1, 'account'); +print dol_get_fiche_head($head, 'checkreceipts', $langs->trans("BankSetupModule"), -1, 'account'); /* * Numbering module @@ -266,7 +266,7 @@ print "
"; print ''."\n"; -dol_fiche_end(); +print dol_get_fiche_end(); print ''; diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index 5fa7b78ca8b..566d6b845e8 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -33,7 +33,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'aZ09'); -if (! in_array('clicktodial', $conf->modules)) { +if (!in_array('clicktodial', $conf->modules)) { accessforbidden($langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name"))); } @@ -44,15 +44,15 @@ if (! in_array('clicktodial', $conf->modules)) { if ($action == 'setvalue' && $user->admin) { - $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); - $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); + $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); + $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); - if ($result1 >= 0 && $result2 >= 0) - { + if ($result1 >= 0 && $result2 >= 0) + { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -125,7 +125,7 @@ if (!empty($conf->global->CLICKTODIAL_URL)) if (GETPOST('phonefortest')) $phonefortest = GETPOST('phonefortest'); print '
'; - print ''; + print ''; print $langs->trans("LinkToTestClickToDial", $user->login).' : '; print ''; print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index b920d9e6f9e..594052500ca 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -246,7 +246,7 @@ print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); $head = order_admin_prepare_head(); -dol_fiche_head($head, 'general', $langs->trans("Orders"), -1, 'order'); +print dol_get_fiche_head($head, 'general', $langs->trans("Orders"), -1, 'order'); /* * Orders Numbering model diff --git a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php index e1ec33c02d4..98a98a7ec2c 100644 --- a/htdocs/admin/commande_fournisseur_dispatch_extrafields.php +++ b/htdocs/admin/commande_fournisseur_dispatch_extrafields.php @@ -79,11 +79,11 @@ print "
\n"; $head = reception_admin_prepare_head(); -dol_fiche_head($head, 'attributeslines_reception', $langs->trans("Receptions"), -1, 'sending'); +print dol_get_fiche_head($head, 'attributeslines_reception', $langs->trans("Receptions"), -1, 'sending'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index a099547fbc0..2705ede5540 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -88,9 +88,9 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dolibarr_del_const($db, "MAIN_INFO_SOCIETE_STATE", $conf->entity); } - $db->begin(); + $db->begin(); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); + 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_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alphanohtml'), 'chaine', 0, '', $conf->entity); @@ -141,8 +141,8 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) // Create thumbs of logo (Note that PDF use original file and not thumbs) if ($isimage > 0) { - // Create thumbs - //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retreive value with get... + // Create thumbs + //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... // Create small thumb, Used on logon for example $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); @@ -269,8 +269,8 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb $reg = array(); - // Create thumbs - //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retreive value with get... + // Create thumbs + //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... // Create small thumb. Used on logon for example $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality); @@ -373,7 +373,7 @@ print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup'); $head = company_admin_prepare_head(); -dol_fiche_head($head, 'company', $langs->trans("Company"), -1, 'company'); +print dol_get_fiche_head($head, 'company', $langs->trans("Company"), -1, 'company'); print ''.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."
\n"; print "
\n"; @@ -777,8 +777,8 @@ if ($mysoc->useLocalTax(2)) $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."\n" : ""); if (!isOnlyOneLocalTax(2)) { - print '
: '; - $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); + print '
: '; + $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); } print '
: '; print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2); diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index faf38f44b16..a647d096037 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -40,14 +40,14 @@ $action = GETPOST('action', 'aZ09'); // Other parameters ACCOUNTING_* $list = array( - 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', - 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', - 'ACCOUNTING_SERVICE_BUY_ACCOUNT', - 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_BUY_ACCOUNT', - 'ACCOUNTING_ACCOUNT_CUSTOMER', - 'ACCOUNTING_ACCOUNT_SUPPLIER' + 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', + 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', + 'ACCOUNTING_SERVICE_BUY_ACCOUNT', + 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_BUY_ACCOUNT', + 'ACCOUNTING_ACCOUNT_CUSTOMER', + 'ACCOUNTING_ACCOUNT_SUPPLIER' ); /* @@ -58,52 +58,52 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : if ($action == 'update') { - $error = 0; + $error = 0; - $accounting_modes = array( - 'RECETTES-DEPENSES', - 'CREANCES-DETTES' - ); + $accounting_modes = array( + 'RECETTES-DEPENSES', + 'CREANCES-DETTES' + ); - $accounting_mode = GETPOST('accounting_mode', 'alpha'); + $accounting_mode = GETPOST('accounting_mode', 'alpha'); - if (in_array($accounting_mode, $accounting_modes)) { - if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } else { - $error++; - } + if (in_array($accounting_mode, $accounting_modes)) { + if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + $error++; + } - foreach ($list as $constname) { - $constvalue = GETPOST($constname, 'alpha'); + foreach ($list as $constname) { + $constvalue = GETPOST($constname, 'alpha'); - if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } - $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha'); - if (!empty($report_include_varpay)) - if ($report_include_varpay == 'yes') - if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) $error++; - if ($report_include_varpay == 'no') - if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) $error++; + $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha'); + if (!empty($report_include_varpay)) + if ($report_include_varpay == 'yes') + if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) $error++; + if ($report_include_varpay == 'no') + if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) $error++; - $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha'); - if (!empty($report_include_loan)) - if ($report_include_loan == 'yes') - if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) $error++; - if ($report_include_loan == 'no') - if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) $error++; + $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha'); + if (!empty($report_include_loan)) + if ($report_include_loan == 'yes') + if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) $error++; + if ($report_include_loan == 'no') + if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php index 3f1eb8d9651..0eadfa2c629 100644 --- a/htdocs/admin/confexped.php +++ b/htdocs/admin/confexped.php @@ -67,12 +67,12 @@ if ($action == 'disable_sending') if ($action == 'activate_delivery') { dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this - dolibarr_set_const($db, "MAIN_SUBMODULE_LIVRAISON", "1", 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_SUBMODULE_DELIVERY", "1", 'chaine', 0, '', $conf->entity); header("Location: confexped.php"); exit; } elseif ($action == 'disable_delivery') { - dolibarr_del_const($db, "MAIN_SUBMODULE_LIVRAISON", $conf->entity); + dolibarr_del_const($db, "MAIN_SUBMODULE_DELIVERY", $conf->entity); header("Location: confexped.php"); exit; } @@ -92,7 +92,7 @@ print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup') print '
'; $head = expedition_admin_prepare_head(); -dol_fiche_head($head, 'general', $langs->trans("Sendings"), -1, 'shipment'); +print dol_get_fiche_head($head, 'general', $langs->trans("Sendings"), -1, 'shipment'); // Miscellaneous parameters @@ -121,7 +121,7 @@ else print ""; print ''; -// Bon de livraison activation/desactivation +// Delivery note activate/deactivate Bon de livraison activation/desactivation print ''; print ''; print $langs->trans("DeliveriesOrderAbility"); @@ -131,7 +131,7 @@ print ''; print ''; print ''; -if (empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) +if (empty($conf->global->MAIN_SUBMODULE_DELIVERY)) { print '
'.img_picto($langs->trans("Disabled"), 'switch_off').''; } else { diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 4aacdb3cfc2..baf5fae0b34 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -155,7 +155,7 @@ llxHeader('', $langs->trans("Setup"), $wikihelp); // Add logic to show/hide buttons if ($conf->use_javascript_ajax) { - ?> + ?> '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php index ae7faafa937..5dd541b34b5 100644 --- a/htdocs/admin/export.php +++ b/htdocs/admin/export.php @@ -71,7 +71,7 @@ $head[$h][1] = $langs->trans("Setup"); $head[$h][2] = 'setup'; $h++; -dol_fiche_head($head, 'setup', $langs->trans("ExportsArea"), -1, "technic"); +print dol_get_fiche_head($head, 'setup', $langs->trans("ExportsArea"), -1, "technic"); print ''; print ''; @@ -103,7 +103,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 7f5bcde4b3d..48db3ee4429 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -55,31 +55,31 @@ $sql .= " WHERE ".$db->decrypt('name')." LIKE 'EXTERNAL_RSS_URLRSS_%'"; $result = $db->query($sql); // We can't use SELECT MAX() because EXTERNAL_RSS_URLRSS_10 is lower than EXTERNAL_RSS_URLRSS_9 if ($result) { - while ($obj = $db->fetch_object($result)) - { - preg_match('/([0-9]+)$/i', $obj->name, $reg); - if ($reg[1] && $reg[1] > $lastexternalrss) $lastexternalrss = $reg[1]; - } + while ($obj = $db->fetch_object($result)) + { + preg_match('/([0-9]+)$/i', $obj->name, $reg); + if ($reg[1] && $reg[1] > $lastexternalrss) $lastexternalrss = $reg[1]; + } } else { - dol_print_error($db); + dol_print_error($db); } if ($action == 'add' || GETPOST("modify")) { - $external_rss_title = "external_rss_title_".GETPOST("norss", 'int'); - $external_rss_urlrss = "external_rss_urlrss_".GETPOST("norss", 'int'); + $external_rss_title = "external_rss_title_".GETPOST("norss", 'int'); + $external_rss_urlrss = "external_rss_urlrss_".GETPOST("norss", 'int'); - if (!empty($_POST[$external_rss_urlrss])) - { - $boxlabel = '(ExternalRSSInformations)'; - //$external_rss_url = "external_rss_url_" . $_POST["norss"]; + if (!empty($_POST[$external_rss_urlrss])) + { + $boxlabel = '(ExternalRSSInformations)'; + //$external_rss_url = "external_rss_url_" . $_POST["norss"]; - $db->begin(); + $db->begin(); if ($_POST["modify"]) { // Supprime boite box_external_rss de definition des boites - /* $sql = "UPDATE ".MAIN_DB_PREFIX."boxes_def"; + /* $sql = "UPDATE ".MAIN_DB_PREFIX."boxes_def"; $sql.= " SET name = '".$db->escape($boxlabel)."'"; $sql.= " WHERE file ='box_external_rss.php' AND note like '".$db->escape($_POST["norss"])." %'"; @@ -92,56 +92,56 @@ if ($action == 'add' || GETPOST("modify")) */ } else { // Ajoute boite box_external_rss dans definition des boites - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)"; $sql .= " VALUES ('box_external_rss.php','".$db->escape(GETPOST("norss", 'int').' ('.GETPOST($external_rss_title, 'alpha')).")')"; - if (!$db->query($sql)) - { - dol_print_error($db); - $err++; - } + if (!$db->query($sql)) + { + dol_print_error($db); + $err++; + } } $result1 = dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), GETPOST($external_rss_title, 'alpha'), 'chaine', 0, '', $conf->entity); if ($result1) $result2 = dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), GETPOST($external_rss_urlrss, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result1 && $result2) - { - $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - $db->rollback(); - dol_print_error($db); - } - } + if ($result1 && $result2) + { + $db->commit(); + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + $db->rollback(); + dol_print_error($db); + } + } } if ($_POST["delete"]) { - if (GETPOST("norss", 'int')) - { - $db->begin(); + if (GETPOST("norss", 'int')) + { + $db->begin(); // Supprime boite box_external_rss de definition des boites - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes_def"; - $sql .= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOST("norss", 'int'))." %'"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes_def"; + $sql .= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOST("norss", 'int'))." %'"; $resql = $db->query($sql); if ($resql) - { + { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; - $sql .= " WHERE entity = ".$conf->entity; - $sql .= " AND box_id = ".$obj->rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " AND box_id = ".$obj->rowid; $resql = $db->query($sql); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; - $sql .= " WHERE rowid = ".$obj->rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; + $sql .= " WHERE rowid = ".$obj->rowid; $resql = $db->query($sql); if (!$resql) @@ -159,22 +159,22 @@ if ($_POST["delete"]) $db->rollback(); dol_print_error($db, "sql=".$sql); exit; - } + } $result1 = dolibarr_del_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), $conf->entity); if ($result1) $result2 = dolibarr_del_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), $conf->entity); - if ($result1 && $result2) - { - $db->commit(); - header("Location: external_rss.php"); - exit; - } else { - $db->rollback(); - dol_print_error($db); - } - } + if ($result1 && $result2) + { + $db->commit(); + header("Location: external_rss.php"); + exit; + } else { + $db->rollback(); + dol_print_error($db); + } + } } @@ -242,9 +242,9 @@ if ($resql) $idrss = $reg[1]; $keyrsstitle = "EXTERNAL_RSS_TITLE_".$idrss; $keyrssurl = "EXTERNAL_RSS_URLRSS_".$idrss; - //print "x".$idrss; + //print "x".$idrss; - $rssparser = new RssParser($db); + $rssparser = new RssParser($db); $result = $rssparser->parser($conf->global->$keyrssurl, 5, 300, $conf->externalrss->dir_temp); print "
"; @@ -255,8 +255,8 @@ if ($resql) print ''; print "".$langs->trans("RSS")." ".($i + 1).""; - print ''; - print ''; + print ''; + print ''; print "   "; print ''; print ''; @@ -279,8 +279,8 @@ if ($resql) print ''; print "".$langs->trans("Status").""; print ""; - if ($result > 0 && empty($rss->error)) - { + if ($result > 0 && empty($rss->error)) + { print ''.$langs->trans("Online").'
'; } else { print ''.$langs->trans("Offline"); @@ -292,8 +292,8 @@ if ($resql) print ''."\n"; // Logo - if ($result > 0 && empty($rss->error)) - { + if ($result > 0 && empty($rss->error)) + { print ''; print "".$langs->trans("Logo").""; print ''; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 0c12f11b4a3..35dd1002b12 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -245,7 +245,7 @@ $linkback = 'trans("Invoices"), -1, 'invoice'); +print dol_get_fiche_head($head, 'general', $langs->trans("Invoices"), -1, 'invoice'); /* * Numbering module @@ -802,7 +802,7 @@ print ''; print "
\n"; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index 61969651634..31966cdb585 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -60,8 +60,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader( - "", $langs->trans("BillsSetup"), - 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura' + "", $langs->trans("BillsSetup"), + 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura' ); $form = new Form($db); @@ -71,7 +71,7 @@ $linkback = 'trans("InvoiceSituation"), -1, 'invoice'); +print dol_get_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice'); print ''.$langs->trans("InvoiceFirstSituationDesc").'

'; @@ -104,12 +104,7 @@ $arrayAvailableType = array( Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"), Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"), ); -$selected = array(); -$implodeglue = '+'; -if (!empty($conf->global->{$confkey}) && !is_array($conf->global->{$confkey})) { - $selected = explode('+', $conf->global->{$confkey}); -} - +$selected = $conf->global->$confkey; $curentInput = (empty($inputCount) ? 1 : ($inputCount + 1)); $formSelectInvoiceType = $form->selectarray('value'.$curentInput, $arrayAvailableType, $selected, 1); _printInputFormPart($confkey, $langs->trans('AllowedInvoiceForRetainedWarranty'), '', array(), $formSelectInvoiceType); @@ -118,10 +113,10 @@ _printInputFormPart($confkey, $langs->trans('AllowedInvoiceForRetainedWarranty') _printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituationFinal')); $metas = array( - 'type' => 'number', - 'step' => '0.01', - 'min' => 0, - 'max' => 100 + 'type' => 'number', + 'step' => '0.01', + 'min' => 0, + 'max' => 100 ); _printInputFormPart('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT', $langs->trans('RetainedwarrantyDefaultPercent'), '', $metas); @@ -145,7 +140,7 @@ _updateBtn(); print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); @@ -158,10 +153,10 @@ $db->close(); */ function _updateBtn() { - global $langs; - print '
'; - print ''; - print '
'; + global $langs; + print '
'; + print ''; + print '
'; } /** @@ -175,18 +170,18 @@ function _updateBtn() */ function _printOnOff($confkey, $title = false, $desc = '') { - global $langs; + global $langs; - print ''; - print ''.($title ? $title : $langs->trans($confkey)); - if (!empty($desc)) { - print '
'.$langs->trans($desc).''; - } - print ''; - print ' '; - print ''; - print ajax_constantonoff($confkey); - print ''; + print ''; + print ''.($title ? $title : $langs->trans($confkey)); + if (!empty($desc)) { + print '
'.$langs->trans($desc).''; + } + print ''; + print ' '; + print ''; + print ajax_constantonoff($confkey); + print ''; } @@ -204,53 +199,53 @@ function _printOnOff($confkey, $title = false, $desc = '') */ function _printInputFormPart($confkey, $title = false, $desc = '', $metas = array(), $type = 'input', $help = false) { - global $langs, $conf, $db, $inputCount; + global $langs, $conf, $db, $inputCount; - $inputCount = empty($inputCount) ? 1 : ($inputCount + 1); - $form = new Form($db); + $inputCount = empty($inputCount) ? 1 : ($inputCount + 1); + $form = new Form($db); - $defaultMetas = array( - 'name' => 'value'.$inputCount - ); + $defaultMetas = array( + 'name' => 'value'.$inputCount + ); - if ($type != 'textarea') { - $defaultMetas['type'] = 'text'; - $defaultMetas['value'] = $conf->global->{$confkey}; - } + if ($type != 'textarea') { + $defaultMetas['type'] = 'text'; + $defaultMetas['value'] = $conf->global->{$confkey}; + } - $metas = array_merge($defaultMetas, $metas); - $metascompil = ''; - foreach ($metas as $key => $values) { - $metascompil .= ' '.$key.'="'.$values.'" '; - } + $metas = array_merge($defaultMetas, $metas); + $metascompil = ''; + foreach ($metas as $key => $values) { + $metascompil .= ' '.$key.'="'.$values.'" '; + } - print ''; - print ''; + print ''; + print ''; - if (!empty($help)) { - print $form->textwithtooltip(($title ? $title : $langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, '')); - } else { - print $title ? $title : $langs->trans($confkey); - } + if (!empty($help)) { + print $form->textwithtooltip(($title ? $title : $langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, '')); + } else { + print $title ? $title : $langs->trans($confkey); + } - if (!empty($desc)) { - print '
'.$langs->trans($desc).''; - } + if (!empty($desc)) { + print '
'.$langs->trans($desc).''; + } - print ''; - print ' '; - print ''; - print ''; + print ''; + print ' '; + print ''; + print ''; - print ''; - if ($type == 'textarea') { - print ''; + print ''; + if ($type == 'textarea') { + print ''; } elseif ($type == 'input') { - print ''; - } else { + print ''; + } else { // custom print $type; - } - print ''; + } + print ''; } diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 4c1e495939a..8f4ea7ec9c4 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -82,23 +82,23 @@ $picto = array( foreach ($modules as $const => $desc) { - if ($action == 'activate_'.strtolower($const)) - { - dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity); - // Si fckeditor est active dans la description produit/service, on l'active dans les formulaires - if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM)) - { - dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity); - } - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - if ($action == 'disable_'.strtolower($const)) - { - dolibarr_del_const($db, "FCKEDITOR_ENABLE_".$const, $conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } + if ($action == 'activate_'.strtolower($const)) + { + dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity); + // Si fckeditor est active dans la description produit/service, on l'active dans les formulaires + if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity); + } + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + if ($action == 'disable_'.strtolower($const)) + { + dolibarr_del_const($db, "FCKEDITOR_ENABLE_".$const, $conf->entity); + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } } if (GETPOST('save', 'alpha')) @@ -115,7 +115,7 @@ if (GETPOST('save', 'alpha')) } $fckeditor_test = GETPOST('formtestfield'); - if (!empty($fckeditor_test)) { + if (!empty($fckeditor_test)) { if (!dolibarr_set_const($db, 'FCKEDITOR_TEST', $fckeditor_test, 'chaine', 0, '', $conf->entity)) { $error++; } @@ -124,11 +124,11 @@ if (GETPOST('save', 'alpha')) } if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* @@ -145,80 +145,79 @@ if (empty($conf->use_javascript_ajax)) { setEventMessages(array($langs->trans("NotAvailable"), $langs->trans("JavascriptDisabled")), null, 'errors'); } else { - print ''; - print ''; - print ''; - print ''; - print "\n"; + print '
'.$langs->trans("ActivateFCKeditor").''.$langs->trans("Action").'
'; + print ''; + print ''; + print ''; + print "\n"; - // Modules - foreach ($modules as $const => $desc) - { - // Si condition non remplie, on ne propose pas l'option - if (!$conditions[$const]) continue; + // Modules + foreach ($modules as $const => $desc) + { + // Si condition non remplie, on ne propose pas l'option + if (!$conditions[$const]) continue; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print '"; - print ''; - } + print ""; + print ''; + } - print '
'.$langs->trans("ActivateFCKeditor").''.$langs->trans("Action").'
'.img_object("", $picto[$const]).''.$langs->trans($desc).''; - $constante = 'FCKEDITOR_ENABLE_'.$const; - $value = (isset($conf->global->$constante) ? $conf->global->$constante : 0); - if ($value == 0) - { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } elseif ($value == 1) - { - print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; - } + print '
'.img_object("", $picto[$const]).''.$langs->trans($desc).''; + $constante = 'FCKEDITOR_ENABLE_'.$const; + $value = (isset($conf->global->$constante) ? $conf->global->$constante : 0); + if ($value == 0) + { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } elseif ($value == 1) + { + print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; + } - print "
'."\n"; + print ''."\n"; print '
'."\n"; print '
'."\n"; - print ''; + print ''; // Skins - show_skin(null, 1); - print '
'."\n"; + show_skin(null, 1); + print '
'."\n"; - $listofmodes = array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline'); - $linkstomode = ''; - foreach ($listofmodes as $newmode) - { - if ($linkstomode) $linkstomode .= ' - '; - $linkstomode .= '
'; - if ($mode == $newmode) $linkstomode .= ''; - $linkstomode .= $newmode; - if ($mode == $newmode) $linkstomode .= ''; - $linkstomode .= ''; - } - $linkstomode .= ''; + $listofmodes = array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline'); + $linkstomode = ''; + foreach ($listofmodes as $newmode) + { + if ($linkstomode) $linkstomode .= ' - '; + $linkstomode .= ''; + if ($mode == $newmode) $linkstomode .= ''; + $linkstomode .= $newmode; + if ($mode == $newmode) $linkstomode .= ''; + $linkstomode .= ''; + } + $linkstomode .= ''; print load_fiche_titre($langs->trans("TestSubmitForm"), $linkstomode, ''); - print ''; - if ($mode != 'Full_inline') - { - $uselocalbrowser = true; - $readonly = ($mode == 'dolibarr_readonly' ? 1 : 0); - $editor = new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST) ? $conf->global->FCKEDITOR_TEST : 'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); - $editor->Create(); - } else { - print '
'; - print $conf->global->FCKEDITOR_TEST; - print '
'; - } - print '
'."\n"; - print '
'; - print '
'."\n"; + print ''; + if ($mode != 'Full_inline') + { + $uselocalbrowser = true; + $readonly = ($mode == 'dolibarr_readonly' ? 1 : 0); + $editor = new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST) ? $conf->global->FCKEDITOR_TEST : 'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); + $editor->Create(); + } else { + print '
'; + print $conf->global->FCKEDITOR_TEST; + print '
'; + } + print '
'."\n"; + print '
'; + print ''."\n"; - // Add env of ckeditor - // This is to show how CKEditor detect browser to understand why editor is disabled or not - if (1 == 2) // Change this to enable output - { + // Add env of ckeditor + // This is to show how CKEditor detect browser to understand why editor is disabled or not. To help debug. + /* print '
'; } + */ } // End of page diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 5199165d4f4..64660b67365 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -61,11 +61,11 @@ if ($action == 'updateMask') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'specimen') // For fiche inter { $modele = GETPOST('module', 'alpha'); @@ -78,7 +78,7 @@ if ($action == 'updateMask') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { $filefound = 1; @@ -116,7 +116,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->FICHEINTER_ADDON_PDF == "$value") dolibarr_del_const($db, 'FICHEINTER_ADDON_PDF', $conf->entity); + if ($conf->global->FICHEINTER_ADDON_PDF == "$value") dolibarr_del_const($db, 'FICHEINTER_ADDON_PDF', $conf->entity); } } @@ -150,11 +150,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_FICHINTER_DRAFT_WATERMARK') { $draft = GETPOST('FICHINTER_DRAFT_WATERMARK', 'alpha'); @@ -163,11 +163,11 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS') { $val = GETPOST('FICHINTER_PRINT_PRODUCTS', 'alpha'); @@ -176,14 +176,14 @@ elseif ($action == 'setdoc') if (!$res > 0) $error++; if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_FICHINTER_USE_SERVICE_DURATION') { $val = GETPOST('FICHINTER_USE_SERVICE_DURATION', 'alpha'); - $res = dolibarr_set_const($db, "FICHINTER_USE_SERVICE_DURATION", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "FICHINTER_USE_SERVICE_DURATION", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity); if (!$res > 0) { $error++; @@ -195,31 +195,31 @@ elseif ($action == 'setdoc') setEventMessages($langs->trans("Error"), null, 'errors'); } } elseif ($action == 'set_FICHINTER_WITHOUT_DURATION') { - $val = GETPOST('FICHINTER_WITHOUT_DURATION', 'alpha'); - $res = dolibarr_set_const($db, "FICHINTER_WITHOUT_DURATION", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity); + $val = GETPOST('FICHINTER_WITHOUT_DURATION', 'alpha'); + $res = dolibarr_set_const($db, "FICHINTER_WITHOUT_DURATION", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } + if (!$res > 0) { + $error++; + } - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set_FICHINTER_DATE_WITHOUT_HOUR') { - $val = GETPOST('FICHINTER_DATE_WITHOUT_HOUR', 'alpha'); - $res = dolibarr_set_const($db, "FICHINTER_DATE_WITHOUT_HOUR", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity); + $val = GETPOST('FICHINTER_DATE_WITHOUT_HOUR', 'alpha'); + $res = dolibarr_set_const($db, "FICHINTER_DATE_WITHOUT_HOUR", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } + if (!$res > 0) { + $error++; + } - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -240,7 +240,7 @@ print load_fiche_titre($langs->trans("InterventionsSetup"), $linkback, 'title_se $head = fichinter_admin_prepare_head(); -dol_fiche_head($head, 'ficheinter', $langs->trans("Interventions"), -1, 'intervention'); +print dol_get_fiche_head($head, 'ficheinter', $langs->trans("Interventions"), -1, 'intervention'); // Interventions numbering model @@ -288,13 +288,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering model - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering model + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->FICHEINTER_ADDON == $classname) @@ -312,16 +312,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $ficheinter); - 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).'
'; - } - } + 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 $form->textwithpicto('', $htmltooltip, 1, 0); print ''; @@ -399,83 +399,83 @@ foreach ($dirmodels as $reldir) 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); + { + 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); + 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; + $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 ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ""; - } else { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ""; + } else { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ""; - if ($conf->global->FICHEINTER_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 ''; + // Default + print ""; + if ($conf->global->FICHEINTER_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 ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $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("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, -1, 0); - print ''; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + print ''; + print $form->textwithpicto('', $htmltooltip, -1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'intervention').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'intervention').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print ''; - } - } - } - } + print ''; + } + } + } + } } } } @@ -509,11 +509,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnInterventions"), $langs $variablename = 'FICHINTER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php index 6b8fe0ab3b7..63d15169da2 100644 --- a/htdocs/admin/geoipmaxmind.php +++ b/htdocs/admin/geoipmaxmind.php @@ -47,7 +47,7 @@ if ($action == 'set') $gimcdf = GETPOST("GEOIPMAXMIND_COUNTRY_DATAFILE"); - if (!$error && $gimcdf && ! preg_match('/\.(dat|mmdb)$/', $gimcdf)) { + if (!$error && $gimcdf && !preg_match('/\.(dat|mmdb)$/', $gimcdf)) { setEventMessages($langs->trans("ErrorFileMustHaveFormat", '.dat|.mmdb'), null, 'errors'); $error++; } diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 23a0cec8130..44b7034064b 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -177,7 +177,7 @@ print load_fiche_titre($langs->trans("HolidaySetup"), $linkback, 'title_setup'); $head = holiday_admin_prepare_head(); -dol_fiche_head($head, 'holiday', $langs->trans("Holidays"), -1, 'holiday'); +print dol_get_fiche_head($head, 'holiday', $langs->trans("Holidays"), -1, 'holiday'); /* * Holiday Numbering model @@ -282,7 +282,7 @@ print '
'; if ($conf->global->MAIN_FEATURES_LEVEL < 2) { - dol_fiche_end(); + print dol_get_fiche_end(); // End of page llxFooter(); $db->close(); @@ -501,7 +501,7 @@ print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/holiday_extrafields.php b/htdocs/admin/holiday_extrafields.php index 30eb707782b..077ad08a12a 100644 --- a/htdocs/admin/holiday_extrafields.php +++ b/htdocs/admin/holiday_extrafields.php @@ -70,19 +70,19 @@ print load_fiche_titre($langs->trans("HolidaySetup"), $linkback, 'title_setup'); $head = holiday_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Holidays"), -1, 'holiday'); +print dol_get_fiche_head($head, 'attributes', $langs->trans("Holidays"), -1, 'holiday'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -107,10 +107,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index f220d83ebcd..4fd8963344d 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2016 Juanjo Menent @@ -122,7 +122,7 @@ if ($action == 'update') if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val, 'chaine', 0, '', $conf->entity); - $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLELINK'), array())))); + $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLELINK'), array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLELINK', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLELINK', $val, 'chaine', 0, '', $conf->entity); diff --git a/htdocs/admin/import.php b/htdocs/admin/import.php index d36ffd5265f..e70d8eadbba 100644 --- a/htdocs/admin/import.php +++ b/htdocs/admin/import.php @@ -70,7 +70,7 @@ $head[$h][1] = $langs->trans("Setup"); $head[$h][2] = 'setup'; $h++; -dol_fiche_head($head, 'setup', $langs->trans("ImportArea"), -1, "technic"); +print dol_get_fiche_head($head, 'setup', $langs->trans("ImportArea"), -1, "technic"); print '
'; print ''; @@ -93,7 +93,7 @@ print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 1a27d61e55d..44bfd678fb4 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -47,24 +47,24 @@ print load_fiche_titre($langs->trans("SetupArea"), '', 'tools'); if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { - $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('//i', '
', $conf->global->MAIN_MOTD_SETUPPAGE); - if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) - { - $i = 0; - while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100) - { - $tmp = explode('|', $reg[1]); - if (!empty($tmp[1])) $langs->load($tmp[1]); - $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/__\('.preg_quote($reg[1]).'\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_MOTD_SETUPPAGE); - $i++; - } + $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('//i', '
', $conf->global->MAIN_MOTD_SETUPPAGE); + if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) + { + $i = 0; + while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100) + { + $tmp = explode('|', $reg[1]); + if (!empty($tmp[1])) $langs->load($tmp[1]); + $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/__\('.preg_quote($reg[1]).'\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_MOTD_SETUPPAGE); + $i++; + } - print "\n\n"; - print '
'; - print dol_htmlentitiesbr($conf->global->MAIN_MOTD_SETUPPAGE); - print '

'; - print "\n\n"; - } + print "\n\n"; + print '
'; + print dol_htmlentitiesbr($conf->global->MAIN_MOTD_SETUPPAGE); + print '

'; + print "\n\n"; + } } print ''; @@ -109,7 +109,7 @@ print $hookmanager->resPrint; if (empty($reshook)) { // Show into other - print ''.$langs->trans("SetupDescription5")."
"; + print ''.$langs->trans("SetupDescription5")."
"; print "
"; // Show logo diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 951b93f908c..b8c207644c6 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -108,7 +108,7 @@ $form = new Form($db); print '
'; print ''; -dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'ldap', $langs->trans("LDAPSetup"), -1); print ''; @@ -251,7 +251,7 @@ print ''; print '
'.$langs->trans('Password').' (ex: secret)
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index 54de74c6371..b29fa00e49e 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -105,7 +105,7 @@ if (!function_exists("ldap_connect")) setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -dol_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescContact").'
'; @@ -246,7 +246,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 4e0c430fb90..61d2e8b69e9 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -61,19 +61,19 @@ if ($action == 'setvalue' && $user->admin) if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; // This one must be after the others - $valkey = ''; - $key = GETPOST("key"); - if ($key) $valkey = $conf->global->$key; - if (!dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + $valkey = ''; + $key = GETPOST("key"); + if ($key) $valkey = $conf->global->$key; + if (!dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; - if (!$error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - dol_print_error($db); - } + if (!$error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + dol_print_error($db); + } } @@ -95,7 +95,7 @@ if (!function_exists("ldap_connect")) setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -dol_fiche_head($head, 'groups', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'groups', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescGroups").'
'; @@ -180,7 +180,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index 0cd09d27f7e..214a4f2cb9b 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -125,7 +125,7 @@ if (!function_exists("ldap_connect")) print ''; print ''; -dol_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescMembers").'
'; @@ -366,7 +366,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 371437e1640..489e6047f9b 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -93,7 +93,7 @@ if (!function_exists("ldap_connect")) setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } -dol_fiche_head($head, 'memberstypes', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'memberstypes', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescMembersTypes").'
'; @@ -162,7 +162,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index d5778fbfb1c..efb34cca413 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -121,7 +121,7 @@ print ''; print ''; -dol_fiche_head($head, 'users', $langs->trans("LDAPSetup"), -1); +print dol_get_fiche_head($head, 'users', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescUsers").'
'; print '
'; @@ -336,7 +336,7 @@ print ''; print info_admin($langs->trans("LDAPDescValues")); -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index db29deef9d7..ce918583d96 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -35,8 +35,8 @@ $action = GETPOST('action', 'aZ09'); $currencycode = GETPOST('currencycode', 'alpha'); if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { - // When MULTICURRENCY_USE_LIMIT_BY_CURRENCY is on, we use always a defined currency code instead of '' even for default. - $currencycode = (!empty($currencycode) ? $currencycode : $conf->currency); + // When MULTICURRENCY_USE_LIMIT_BY_CURRENCY is on, we use always a defined currency code instead of '' even for default. + $currencycode = (!empty($currencycode) ? $currencycode : $conf->currency); } $mainmaxdecimalsunit = 'MAIN_MAX_DECIMALS_UNIT'.(!empty($currencycode) ? '_'.$currencycode : ''); @@ -56,41 +56,41 @@ if ($action == 'update') if ($_POST[$mainmaxdecimalsunit] > $MAXDEC || $_POST[$mainmaxdecimalstot] > $MAXDEC || $_POST[$mainmaxdecimalsshown] > $MAXDEC) - { - $error++; - setEventMessages($langs->trans("ErrorDecimalLargerThanAreForbidden", $MAXDEC), null, 'errors'); - } + { + $error++; + setEventMessages($langs->trans("ErrorDecimalLargerThanAreForbidden", $MAXDEC), null, 'errors'); + } - if ($_POST[$mainmaxdecimalsunit].(!empty($currencycode) ? '_'.$currencycode : '') < 0 - || $_POST[$mainmaxdecimalstot] < 0 - || $_POST[$mainmaxdecimalsshown] < 0) - { - $langs->load("errors"); - $error++; - setEventMessages($langs->trans("ErrorNegativeValueNotAllowed"), null, 'errors'); - } + if ($_POST[$mainmaxdecimalsunit].(!empty($currencycode) ? '_'.$currencycode : '') < 0 + || $_POST[$mainmaxdecimalstot] < 0 + || $_POST[$mainmaxdecimalsshown] < 0) + { + $langs->load("errors"); + $error++; + setEventMessages($langs->trans("ErrorNegativeValueNotAllowed"), null, 'errors'); + } - if ($valmainroundingruletot) - { - if ($valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1) - { - $langs->load("errors"); - $error++; - setEventMessages($langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT"), null, 'errors'); - } - } + if ($valmainroundingruletot) + { + if ($valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1) + { + $langs->load("errors"); + $error++; + setEventMessages($langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT"), null, 'errors'); + } + } - if (!$error) - { - dolibarr_set_const($db, $mainmaxdecimalsunit, $valmainmaxdecimalsunit, 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, $mainmaxdecimalstot, $valmainmaxdecimalstot, 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, $mainmaxdecimalsshown, $valmainmaxdecimalsshown, 'chaine', 0, '', $conf->entity); + if (!$error) + { + dolibarr_set_const($db, $mainmaxdecimalsunit, $valmainmaxdecimalsunit, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, $mainmaxdecimalstot, $valmainmaxdecimalstot, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, $mainmaxdecimalsshown, $valmainmaxdecimalsshown, 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, $mainroundingruletot, $valmainroundingruletot, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, $mainroundingruletot, $valmainroundingruletot, 'chaine', 0, '', $conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(!empty($currencycode) ? '¤cycode='.$currencycode : '')); - exit; - } + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(!empty($currencycode) ? '¤cycode='.$currencycode : '')); + exit; + } } @@ -125,7 +125,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY if (!empty($aCurrencies) && count($aCurrencies) > 1) { $head = multicurrencyLimitPrepareHead($aCurrencies); - dol_fiche_head($head, $currencycode, '', -1, "multicurrency"); + print dol_get_fiche_head($head, $currencycode, '', -1, "multicurrency"); } } @@ -134,74 +134,74 @@ print "
\n"; if ($action == 'edit') { - print ''; - print ''; - print ''; - if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { - print ''; - } + print ''; + print ''; + print ''; + if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { + print ''; + } - clearstatcache(); + clearstatcache(); - print ''; - print ''; + print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; - print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly")); - print '
'; + print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly")); + print '
'; - print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); - print '
'; + print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); + print '
'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'
'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'
'; - print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); - print '
'; + print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); + print '
'; + print ''; - print '
'; - print '
'; - print ''; - print '
'; + print '
'; + print '
'; + print ''; + print '
'; print '
'; - print '
'; - print '
'; + print ''; + print '
'; } else { - print ''; - print ''; + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''.(isset($conf->global->$mainmaxdecimalsunit) ? $conf->global->$mainmaxdecimalsunit : $conf->global->MAIN_MAX_DECIMALS_UNIT).'
'; + print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly")); + print ''.(isset($conf->global->$mainmaxdecimalsunit) ? $conf->global->$mainmaxdecimalsunit : $conf->global->MAIN_MAX_DECIMALS_UNIT).'
'; - print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''.(isset($conf->global->$mainmaxdecimalstot) ? $conf->global->$mainmaxdecimalstot : $conf->global->MAIN_MAX_DECIMALS_TOT).'
'; + print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); + print ''.(isset($conf->global->$mainmaxdecimalstot) ? $conf->global->$mainmaxdecimalstot : $conf->global->MAIN_MAX_DECIMALS_TOT).'
'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").''.(isset($conf->global->$mainmaxdecimalsshown) ? $conf->global->$mainmaxdecimalsshown : $conf->global->MAIN_MAX_DECIMALS_SHOWN).'
'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").''.(isset($conf->global->$mainmaxdecimalsshown) ? $conf->global->$mainmaxdecimalsshown : $conf->global->MAIN_MAX_DECIMALS_SHOWN).'
'; - print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); - print ''.(isset($conf->global->$mainroundingruletot) ? $conf->global->$mainroundingruletot : $conf->global->MAIN_ROUNDING_RULE_TOT).'
'; + print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"), $langs->trans("ParameterActiveForNextInputOnly")); + print ''.(isset($conf->global->$mainroundingruletot) ? $conf->global->$mainroundingruletot : $conf->global->MAIN_ROUNDING_RULE_TOT).'
'; + print ''; - print '
'; - print ''.$langs->trans("Modify").''; - print '
'; + print '
'; + print ''.$langs->trans("Modify").''; + print '
'; } if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { if (!empty($aCurrencies) && count($aCurrencies) > 1) { - dol_fiche_end(); + print dol_get_fiche_end(); } } @@ -248,59 +248,59 @@ if (empty($mysoc->country_code)) $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - if ($num) - { - for ($i = 0; $i < $num; $i++) - { - $obj = $db->fetch_object($resql); - $vat_rates[] = array('vat_rate'=>$obj->vat_rate, 'code'=>$obj->vat_code, 'localtax_rate1'=>$obj->localtax_rate1, 'locltax_rate2'=>$obj->localtax_rate2); - } - } + $num = $db->num_rows($resql); + if ($num) + { + for ($i = 0; $i < $num; $i++) + { + $obj = $db->fetch_object($resql); + $vat_rates[] = array('vat_rate'=>$obj->vat_rate, 'code'=>$obj->vat_code, 'localtax_rate1'=>$obj->localtax_rate1, 'locltax_rate2'=>$obj->localtax_rate2); + } + } } else dol_print_error($db); if (count($vat_rates)) { - foreach ($vat_rates as $vatarray) - { - $vat = $vatarray['vat_rate']; - for ($qty = 1; $qty <= 2; $qty++) - { - $vattxt = $vat.($vatarray['code'] ? ' ('.$vatarray['code'].')' : ''); + foreach ($vat_rates as $vatarray) + { + $vat = $vatarray['vat_rate']; + for ($qty = 1; $qty <= 2; $qty++) + { + $vattxt = $vat.($vatarray['code'] ? ' ('.$vatarray['code'].')' : ''); - $localtax_array = getLocalTaxesFromRate($vattxt, 0, $mysoc, $mysoc); + $localtax_array = getLocalTaxesFromRate($vattxt, 0, $mysoc, $mysoc); - $s = 10 / 3; - $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array); - print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); - print " x ".$langs->trans("Quantity").": ".$qty; - print " - ".$langs->trans("VAT").": ".$vat.'%'; - print ($vatarray['code'] ? ' ('.$vatarray['code'].')' : ''); - print '   ->   '.$langs->trans("TotalPriceAfterRounding").": "; - print $tmparray[0].' / '.$tmparray[1].($tmparray[9] ? '+'.$tmparray[9] : '').($tmparray[10] ? '+'.$tmparray[10] : '').' / '.$tmparray[2]; - print "
\n"; - } - } + $s = 10 / 3; + $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array); + print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); + print " x ".$langs->trans("Quantity").": ".$qty; + print " - ".$langs->trans("VAT").": ".$vat.'%'; + print ($vatarray['code'] ? ' ('.$vatarray['code'].')' : ''); + print '   ->   '.$langs->trans("TotalPriceAfterRounding").": "; + print $tmparray[0].' / '.$tmparray[1].($tmparray[9] ? '+'.$tmparray[9] : '').($tmparray[10] ? '+'.$tmparray[10] : '').' / '.$tmparray[2]; + print "
\n"; + } + } } else { - // More examples if not specific vat rate found - // This example must be kept for test purpose with current value because value used (2/7, 10/3, and vat 0, 10) - // were calculated to show all possible cases of rounding. If we change this, examples becomes useless or show the same rounding rule. + // More examples if not specific vat rate found + // This example must be kept for test purpose with current value because value used (2/7, 10/3, and vat 0, 10) + // were calculated to show all possible cases of rounding. If we change this, examples becomes useless or show the same rounding rule. - $localtax_array = array(); + $localtax_array = array(); - $s = 10 / 3; $qty = 1; $vat = 10; - $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array); - print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); - print " x ".$langs->trans("Quantity").": ".$qty; - print " - ".$langs->trans("VAT").": ".$vat.'%'; - print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; + $s = 10 / 3; $qty = 1; $vat = 10; + $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array); + print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); + print " x ".$langs->trans("Quantity").": ".$qty; + print " - ".$langs->trans("VAT").": ".$vat.'%'; + print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; - $s = 10 / 3; $qty = 2; $vat = 10; - $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array); - print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); - print " x ".$langs->trans("Quantity").": ".$qty; - print " - ".$langs->trans("VAT").": ".$vat.'%'; - print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; + $s = 10 / 3; $qty = 2; $vat = 10; + $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array); + print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); + print " x ".$langs->trans("Quantity").": ".$qty; + print " - ".$langs->trans("VAT").": ".$vat.'%'; + print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; } } diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php deleted file mode 100644 index f3477e151a2..00000000000 --- a/htdocs/admin/livraison.php +++ /dev/null @@ -1,460 +0,0 @@ - - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2014 Regis Houssin - * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2011-2018 Philippe Grand - * Copyright (C) 2015 Claudio Aschieri - * - * 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/admin/livraison.php - * \ingroup livraison - * \brief Page d'administration/configuration du module Livraison - */ -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array("admin", "sendings", "deliveries", "other")); - -if (!$user->admin) accessforbidden(); - -$action = GETPOST('action', 'alpha'); -$value = GETPOST('value', 'alpha'); -$label = GETPOST('label', 'alpha'); -$scandir = GETPOST('scan_dir', 'alpha'); -$type = 'delivery'; - - -/* - * Actions - */ - -include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; - -if ($action == 'updateMask') -{ - $maskconstdelivery = GETPOST('maskconstdelivery', 'alpha'); - $maskdelivery = GETPOST('maskdelivery', 'alpha'); - if ($maskconstdelivery) $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity); - - if (!$res > 0) $error++; - - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - -if ($action == 'set_DELIVERY_FREE_TEXT') -{ - $free = GETPOST('DELIVERY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string - $res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity); - - if (!$res > 0) $error++; - - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - -if ($action == 'specimen') -{ - $modele = GETPOST('module', 'alpha'); - - $sending = new Livraison($db); - $sending->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/livraison/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($sending, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=livraison&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } -} - -if ($action == 'set') -{ - $ret = addDocumentModel($value, $type, $label, $scandir); -} - -if ($action == 'del') -{ - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->LIVRAISON_ADDON_PDF == "$value") dolibarr_del_const($db, 'LIVRAISON_ADDON_PDF', $conf->entity); - } -} - -if ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "LIVRAISON_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent - $conf->global->LIVRAISON_ADDON_PDF = $value; - } - - // On active le modele - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - $ret = addDocumentModel($value, $type, $label, $scandir); - } -} - -if ($action == 'setmod') -{ - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated - - dolibarr_set_const($db, "LIVRAISON_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); -} - - -/* - * View - */ - -$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - -llxHeader("", ""); - -$form = new Form($db); - -$linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup'); -print '
'; -$head = expedition_admin_prepare_head(); - -dol_fiche_head($head, 'receivings', $langs->trans("Receivings"), -1, 'shipment'); - - -// Delivery numbering model - -print load_fiche_titre($langs->trans("DeliveryOrderNumberingModules"), '', ''); - -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''."\n"; - -clearstatcache(); - -foreach ($dirmodels as $reldir) -{ - $dir = dol_buildpath($reldir."core/modules/livraison/"); - - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file) - 3, 3) == 'php') - { - $file = substr($file, 0, dol_strlen($file) - 4); - - require_once $dir.$file.'.php'; - - $module = new $file; - - if ($module->isEnabled()) - { - // 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; - - - print ''; - - // Show example of numbering module - print ''."\n"; - - print ''; - - $livraison = new Livraison($db); - $livraison->initAsSpecimen(); - - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $livraison); - 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 ''; - } - } - } - closedir($handle); - } - } -} - -print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->nom."\n"; - print $module->info(); - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print '
'; - if ($conf->global->LIVRAISON_ADDON_NUMBER == "$file") - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print '
'; - - -/* - * Documents Models for delivery - */ -print '
'; -print load_fiche_titre($langs->trans("DeliveryOrderModel"), '', ''); - -// Defini tableau def de modele -$type = "delivery"; -$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 ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; - -clearstatcache(); - -foreach ($dirmodels as $reldir) -{ - $dir = dol_buildpath($reldir."core/modules/livraison/doc/"); - - 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("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $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); - print ''; - - // Preview - print ''; - - print ''; - } - } - } - } - } - } -} - -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 'scandir.'&label='.urlencode($module->name).'">'; - 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 ""; - if ($conf->global->LIVRAISON_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 ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'sending').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print '
'; -/* - * Autres Options - */ -print "
"; -print load_fiche_titre($langs->trans("OtherOptions"), '', ''); - -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; - -$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); -$htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; -$htmltext .= '
'; - -print ''; -print ''; -print ''; -print '\n"; -print ''; - -print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; -print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename = 'DELIVERY_FREE_TEXT'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) -{ - print ''; -} else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); -} -print '
'; -print ''; -print "
'; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index a138d9d0bf2..ee358300ca4 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -33,7 +33,7 @@ $langs->loadLangs(array('admin', 'loan')); // Security check if (!$user->admin) - accessforbidden(); + accessforbidden(); $action = GETPOST('action', 'aZ09'); @@ -50,22 +50,22 @@ $list = array( if ($action == 'update') { - $error = 0; + $error = 0; - foreach ($list as $constname) { - $constvalue = GETPOST($constname, 'alpha'); + foreach ($list as $constname) { + $constvalue = GETPOST($constname, 'alpha'); - if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php index d9d3ae8142d..8070beab59b 100644 --- a/htdocs/admin/mailman.php +++ b/htdocs/admin/mailman.php @@ -63,53 +63,53 @@ if ($action == 'update' || $action == 'add') } if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } // Action activation d'un sous module du module adherent if ($action == 'set') { - $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); - if ($result < 0) - { - dol_print_error($db); - } + $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); + if ($result < 0) + { + dol_print_error($db); + } } // Action desactivation d'un sous module du module adherent if ($action == 'unset') { - $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); - if ($result < 0) - { - dol_print_error($db); - } + $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); + if ($result < 0) + { + dol_print_error($db); + } } if (($action == 'testsubscribe' || $action == 'testunsubscribe') && !empty($conf->global->ADHERENT_USE_MAILMAN)) { - $email = GETPOST($action.'email'); - if (!isValidEmail($email)) - { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors'); - } else { - include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; - $mailmanspip = new MailmanSpip($db); + $email = GETPOST($action.'email'); + if (!isValidEmail($email)) + { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors'); + } else { + include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; + $mailmanspip = new MailmanSpip($db); - $object = new stdClass(); - $object->email = $email; - $object->pass = $email; - /*$object->element='member'; + $object = new stdClass(); + $object->email = $email; + $object->pass = $email; + /*$object->element='member'; $object->type='Preferred Partners'; */ - if ($action == 'testsubscribe') - { - $result = $mailmanspip->add_to_mailman($object); + if ($action == 'testsubscribe') + { + $result = $mailmanspip->add_to_mailman($object); if ($result < 0) { $error++; @@ -117,19 +117,19 @@ if (($action == 'testsubscribe' || $action == 'testunsubscribe') && !empty($conf } else { setEventMessages($langs->trans("MailmanCreationSuccess"), null); } - } - if ($action == 'testunsubscribe') - { - $result = $mailmanspip->del_to_mailman($object); - if ($result < 0) + } + if ($action == 'testunsubscribe') + { + $result = $mailmanspip->del_to_mailman($object); + if ($result < 0) { $error++; setEventMessages($mailmanspip->error, $mailmanspip->errors, 'errors'); } else { setEventMessages($langs->trans("MailmanDeletionSuccess"), null); } - } - } + } + } } @@ -149,31 +149,31 @@ $head = mailmanspip_admin_prepare_head(); if (!empty($conf->global->ADHERENT_USE_MAILMAN)) { - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - dol_fiche_head($head, 'mailman', $langs->trans("Setup"), -1, 'user'); + print dol_get_fiche_head($head, 'mailman', $langs->trans("Setup"), -1, 'user'); - //$link=img_picto($langs->trans("Active"),'tick').' '; - $link = ''; - //$link.=$langs->trans("Disable"); - $link .= img_picto($langs->trans("Activated"), 'switch_on'); - $link .= ''; - // Edition des varibales globales - $constantes = array( - 'ADHERENT_MAILMAN_ADMINPW', - 'ADHERENT_MAILMAN_URL', - 'ADHERENT_MAILMAN_UNSUB_URL', - 'ADHERENT_MAILMAN_LISTS' - ); + //$link=img_picto($langs->trans("Active"),'tick').' '; + $link = ''; + //$link.=$langs->trans("Disable"); + $link .= img_picto($langs->trans("Activated"), 'switch_on'); + $link .= ''; + // Edition des varibales globales + $constantes = array( + 'ADHERENT_MAILMAN_ADMINPW', + 'ADHERENT_MAILMAN_URL', + 'ADHERENT_MAILMAN_UNSUB_URL', + 'ADHERENT_MAILMAN_LISTS' + ); - print load_fiche_titre($langs->trans('MailmanTitle'), $link, ''); + print load_fiche_titre($langs->trans('MailmanTitle'), $link, ''); - print '
'; + print '
'; - // JQuery activity - print ''; - form_constantes($constantes, 2); + form_constantes($constantes, 2); - print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; - print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL%
'; + print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; + print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL%
'; - dol_fiche_end(); + print dol_get_fiche_end(); - print '
'; + print '
'; - print '
'; + print ''; } else { - dol_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user'); + print dol_get_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user'); - $link = ''; - //$link.=img_$langs->trans("Activate") - $link .= img_picto($langs->trans("Disabled"), 'switch_off'); - $link .= ''; - print load_fiche_titre($langs->trans('MailmanTitle'), $link, ''); + $link = ''; + //$link.=img_$langs->trans("Activate") + $link .= img_picto($langs->trans("Disabled"), 'switch_off'); + $link .= ''; + print load_fiche_titre($langs->trans('MailmanTitle'), $link, ''); - dol_fiche_end(); + print dol_get_fiche_end(); } if (!empty($conf->global->ADHERENT_USE_MAILMAN)) { - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - print $langs->trans("TestSubscribe").'
'; - print $langs->trans("EMail").'
'; + print $langs->trans("TestSubscribe").'
'; + print $langs->trans("EMail").'
'; - print '
'; + print ''; - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - print $langs->trans("TestUnSubscribe").'
'; - print $langs->trans("EMail").'
'; + print $langs->trans("TestUnSubscribe").'
'; + print $langs->trans("EMail").'
'; - print '
'; + print ''; } // End of page diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 55316e47332..9292f387673 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -67,18 +67,18 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && !$cancel) { - if (! $error && ! GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) { + if (!$error && !GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MAIN_MAIL_EMAIL_FROM")), null, 'errors'); $action = 'edit'; } - if (! $error && ! isValidEmail(GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'))) { + if (!$error && !isValidEmail(GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'))) { $error++; setEventMessages($langs->trans("ErrorBadEMail", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')), null, 'errors'); $action = 'edit'; } - if (! $error) { + if (!$error) { dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT", 'int'), 'chaine', 0, '', $conf->entity); @@ -188,13 +188,13 @@ if ($action == 'edit') jQuery("#smtp_server_mess").show(); jQuery("#smtp_port_mess").show();'; } else { - print ' + print ' jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true); jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true); jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide();'; - } - print ' + } + print ' } if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\') { @@ -266,14 +266,14 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0); }); })'; - print ''."\n"; + print ''."\n"; } print '
'; print ''; print ''; - dol_fiche_head($head, 'common', '', -1); + print dol_get_fiche_head($head, 'common', '', -1); print ''.$langs->trans("EMailsDesc")."
\n"; print "
\n"; @@ -409,8 +409,8 @@ if ($action == 'edit') print ''; } - // TLS - print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; + // TLS + print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { if (function_exists('openssl_open')) @@ -453,20 +453,20 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - // DKIM Domain - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; - print ''; + // DKIM Domain + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; + print ''; - // DKIM Selector - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; - print ''; + // DKIM Selector + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; + print ''; - // DKIM PRIVATE KEY - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; - print ''; - print ''; + // DKIM PRIVATE KEY + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; + print ''; + print ''; print ''; @@ -506,7 +506,7 @@ if ($action == 'edit') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -516,7 +516,7 @@ if ($action == 'edit') print ''; } else { - dol_fiche_head($head, 'common', '', -1); + print dol_get_fiche_head($head, 'common', '', -1); print ''.$langs->trans("EMailsDesc")."
\n"; print "
\n"; @@ -529,211 +529,215 @@ if ($action == 'edit') if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) print img_warning($langs->trans("Disabled")); print ''; - // Force e-mail recipient - print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''.$conf->global->MAIN_MAIL_FORCE_SENDTO; - if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) - { - if (!isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); - else print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue")); + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { + // Force e-mail recipient + print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''.$conf->global->MAIN_MAIL_FORCE_SENDTO; + if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) + { + if (!isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); + else print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue")); + } + print ''; } - print ''; print ''; - print '
'; + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { + print '
'; - print ''; - print ''; + print '
'.$langs->trans("MAIN_MAIL_SENDMODE").'
'; + print ''; - // Method - print ''; + print ''; - // Host server - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) - { - print ''; - } else { - print ''; - } - - // Port - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) - { - print ''; - } else { - print ''; - } - - // SMTPS ID - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) - { - print ''; - } - - // SMTPS PW - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) - { - print ''; - } - - // TLS - print ''; + print ''; + } else { + print ''; + } - // STARTTLS - print ''; + print ''; + } else { + print ''; + } - // SMTP_ALLOW_SELF_SIGNED - print ''; + print ''; + } + // SMTPS PW + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) + { + print ''; + } - if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') - { - // DKIM - print ''; - // Domain - print ''; - print ''; - - // Selector - print ''; - print ''; - - // PRIVATE KEY - print ''; - print ''; - } - - print '
'.$langs->trans("MAIN_MAIL_SENDMODE").'
'.$langs->trans("MAIN_MAIL_SENDMODE").''; - $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; - if (empty($text)) $text = $langs->trans("Undefined").img_warning(); - print $text; + // Method + print '
'.$langs->trans("MAIN_MAIL_SENDMODE").''; + $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; + if (empty($text)) $text = $langs->trans("Undefined").img_warning(); + print $text; - if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { - print $form->textwithpicto('', $langs->trans("WarningPHPMail").'
'.$langs->trans("WarningPHPMailA").'
'.$langs->trans("WarningPHPMailB").'
'.$langs->trans("WarningPHPMailC").'

'.$langs->trans("WarningPHPMailD"), 1, 'warning'); - } + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { + print $form->textwithpicto('', $langs->trans("WarningPHPMail").'
'.$langs->trans("WarningPHPMailA").'
'.$langs->trans("WarningPHPMailB").'
'.$langs->trans("WarningPHPMailC").'

'.$langs->trans("WarningPHPMailD"), 1, 'warning'); + } - print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').'
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) - { - if (function_exists('openssl_open')) + // Host server + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { - print yn($conf->global->MAIN_MAIL_EMAIL_TLS); - } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; - } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; - print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').'
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) - { - if (function_exists('openssl_open')) + // Port + if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { - print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS); - } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; - } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; - print '
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'
'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").''; - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) - { - if (function_exists('openssl_open')) + // SMTPS ID + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { - print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED); - } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; - } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; - print '
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").''; - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))) + // TLS + print '
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { if (function_exists('openssl_open')) { - print yn($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED); + print yn($conf->global->MAIN_MAIL_EMAIL_TLS); } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; - } else print yn(0).' ('.$langs->trans("NotSupported").')'; + } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; - print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; - print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; - print '
'; - - if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { - print info_admin($langs->trans("WarningPHPMail").'
'.$langs->trans("WarningPHPMailA").'
'.$langs->trans("WarningPHPMailB").'
'.$langs->trans("WarningPHPMailC").'

'.$langs->trans("WarningPHPMailD"), 0, 0, 'warning'); - } - - print '
'; - - print ''; - print ''; - - // From - print ''; - print ''; - - // Default from type - $liste = array(); - $liste['user'] = $langs->trans('UserEmail'); - $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')'; - $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile'; - $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) + // STARTTLS + print ''; - print ''; - print ''; + + + if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') + { + // DKIM + print ''; + + // Domain + print ''; + print ''; + + // Selector + print ''; + print ''; + + // PRIVATE KEY + print ''; + print ''; } + + print '
'.$langs->trans("OtherOptions").'
'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_EMAIL_FROM; - if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && !isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); - print '
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { - $obj = $db->fetch_object($resql); - if ($obj) + if (function_exists('openssl_open')) { - $liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>'; - } - $i++; - } - } else dol_print_error($db); + print yn($conf->global->MAIN_MAIL_EMAIL_STARTTLS); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; + print '
'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; - if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'robot') - { - print $langs->trans('RobotEmail'); - } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user') - { - print $langs->trans('UserEmail'); - } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'company') - { - print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>'); - } else { - $id = preg_replace('/senderprofile_/', '', $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE); - if ($id > 0) + // SMTP_ALLOW_SELF_SIGNED + print '
'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { - include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php'; - $emailsenderprofile = new EmailSenderProfile($db); - $emailsenderprofile->fetch($id); - print $emailsenderprofile->label.' '.dol_escape_htmltag('<'.$emailsenderprofile->email.'>'); + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print ''.yn(0).' ('.$langs->trans("NotSupported").')'; + print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").''; + if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))) + { + if (function_exists('openssl_open')) + { + print yn($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED); + } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; + } else print yn(0).' ('.$langs->trans("NotSupported").')'; + print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; + print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; + print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; + print '
'; + + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail' && empty($conf->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { + print info_admin($langs->trans("WarningPHPMail").'
'.$langs->trans("WarningPHPMailA").'
'.$langs->trans("WarningPHPMailB").'
'.$langs->trans("WarningPHPMailC").'

'.$langs->trans("WarningPHPMailD"), 0, 0, 'warning'); + } + + print '
'; + + print ''; + print ''; + + // From + print ''; + print ''; + + // Default from type + $liste = array(); + $liste['user'] = $langs->trans('UserEmail'); + $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')'; + $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile'; + $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>'; + } + $i++; + } + } else dol_print_error($db); + + print ''; + print ''; + + // Errors To + print ''; + print ''; + + // Autocopy to + print ''; + print ''; + + //Add user to select destinaries list + print ''; + + print '
'.$langs->trans("OtherOptions").'
'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_EMAIL_FROM; + if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && !isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); + print '
'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; + if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'robot') + { + print $langs->trans('RobotEmail'); + } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user') + { + print $langs->trans('UserEmail'); + } elseif ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'company') + { + print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>'); + } else { + $id = preg_replace('/senderprofile_/', '', $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE); + if ($id > 0) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php'; + $emailsenderprofile = new EmailSenderProfile($db); + $emailsenderprofile->fetch($id); + print $emailsenderprofile->label.' '.dol_escape_htmltag('<'.$emailsenderprofile->email.'>'); + } + } + print '
'.$langs->trans("MAIN_MAIL_ERRORS_TO").''.$conf->global->MAIN_MAIL_ERRORS_TO; + if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); + print '
'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) + { + print $conf->global->MAIN_MAIL_AUTOCOPY_TO; + if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); + } else { + print ' '; + } + print '
'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).'
'; } - print ''; - // Errors To - print ''.$langs->trans("MAIN_MAIL_ERRORS_TO").''; - print ''.$conf->global->MAIN_MAIL_ERRORS_TO; - if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); - print ''; - - // Autocopy to - print ''.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; - print ''; - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) - { - print $conf->global->MAIN_MAIL_AUTOCOPY_TO; - if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); - } else { - print ' '; - } - print ''; - - //Add user to select destinaries list - print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).''; - - print ''; - - dol_fiche_end(); + print dol_get_fiche_end(); // Actions button @@ -741,21 +745,23 @@ if ($action == 'edit') print ''.$langs->trans("Modify").''; - if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || !$linuxlike) - { - if (function_exists('fsockopen') && $port && $server) + if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { + if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || !$linuxlike) { - print ''.$langs->trans("DoTestServerAvailability").''; + if (function_exists('fsockopen') && $port && $server) + { + print ''.$langs->trans("DoTestServerAvailability").''; + } + } else { + print ''.$langs->trans("DoTestServerAvailability").''; } - } else { - print ''.$langs->trans("DoTestServerAvailability").''; - } - print ''.$langs->trans("DoTestSend").''; + print ''.$langs->trans("DoTestSend").''; - if (!empty($conf->fckeditor->enabled)) - { - print ''.$langs->trans("DoTestSendHTML").''; + if (!empty($conf->fckeditor->enabled)) + { + print ''.$langs->trans("DoTestSendHTML").''; + } } print '
'; @@ -789,7 +795,7 @@ if ($action == 'edit') { if (!empty($conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD)) { - // List of string to add in SPF if the setup use the mail method + // List of string to add in SPF if the setup use the mail method. Example 'include:sendgrid.net include:spf.mydomain.com' $text .= ($text ? '

' : '').$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD); } else { // MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS is list of IPs where email is sent from. Example: '1.2.3.4, [aaaa:bbbb:cccc:dddd]'. @@ -802,12 +808,13 @@ if ($action == 'edit') } else { if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) { - // List of IP show as record to add as allowed IP if we use the smtp method + // List of IP show as record to add as allowed IP if we use the smtp method. Value is '1.2.3.4, [aaaa:bbbb:cccc:dddd]' + // TODO Add a key to allow to show the IP/name of server detected dynamically $text .= ($text ? '

' : '').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); } - if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) // Should be required only if you have set to use your own SMTP and wat to warn users to update their domain name to match your SMTP server. + if (!empty($conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD)) // Should be required only if you have preset the Dolibarr to use your own SMTP and you want to warn users to update their domain name to match your SMTP server. { - // List of string to add in SPF if we use the smtp method + // List of string to add in SPF if we use the smtp method. Example 'include:spf.mydomain.com' $text .= ($text ? '

' : '').$langs->trans("WarningPHPMailSPF", $conf->global->MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD); } } @@ -843,7 +850,7 @@ if ($action == 'edit') print '
'; print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); - dol_fiche_head(''); + print dol_get_fiche_head(''); // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; @@ -886,7 +893,7 @@ if ($action == 'edit') print $formmail->get_form('addfile', 'removefile'); - dol_fiche_end(); + print dol_get_fiche_end(); // References print ''.$langs->trans("EMailsWillHaveMessageID").': '; diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index b97437216d6..6a42e14bff6 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -60,7 +60,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && empty($_POST["cancel"])) { - // Send mode parameters + // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"), 'chaine', 0, '', $conf->entity); @@ -226,7 +226,7 @@ if ($action == 'edit') print ''; print ''; - dol_fiche_head($head, 'common_emailing', '', -1); + print dol_get_fiche_head($head, 'common_emailing', '', -1); print ''.$langs->trans("EMailsDesc")."
\n"; print "
\n"; @@ -382,22 +382,22 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - print ''; + print ''; - dol_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; } else { - dol_fiche_head($head, 'common_emailing', '', -1); + print dol_get_fiche_head($head, 'common_emailing', '', -1); - print ''.$langs->trans("EMailsDesc")."
\n"; - print "
\n"; + print ''.$langs->trans("EMailsDesc")."
\n"; + print "
\n"; print ''; print ''; @@ -475,13 +475,13 @@ if ($action == 'edit') print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - dol_fiche_end(); + print dol_get_fiche_end(); - if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) - { - print '
'; - /* + if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) + { + print '
'; + /* // Warning 1 if ($linuxlike) { @@ -491,12 +491,12 @@ if ($action == 'edit') print info_admin($langs->trans("SendmailOptionNotComplete")); } }*/ - // Warning 2 - print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); - } + // Warning 2 + print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); + } - // Buttons for actions + // Buttons for actions print '
'; @@ -527,8 +527,8 @@ if ($action == 'edit') if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) { - $text = $langs->trans("WarningPHPMail"); - print info_admin($text); + $text = $langs->trans("WarningPHPMail"); + print info_admin($text); } // Run the test to connect @@ -556,10 +556,10 @@ if ($action == 'edit') // Show email send test form if ($action == 'test' || $action == 'testhtml') { - print '
'; + print '
'; print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); - dol_fiche_head(''); + print dol_get_fiche_head(''); // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; @@ -592,14 +592,14 @@ if ($action == 'edit') $formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode") == 'init') + if (GETPOST("mode") == 'init') { $formmail->clear_attached_files(); } print $formmail->get_form('addfile', 'removefile'); - dol_fiche_end(); + print dol_get_fiche_end(); } } diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 16ae12ffcc5..d9540d30995 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -205,7 +205,7 @@ print load_fiche_titre($title, $linkback, $titlepicto); $head = email_admin_prepare_head(); -dol_fiche_head($head, 'senderprofiles', '', -1); +print dol_get_fiche_head($head, 'senderprofiles', '', -1); print ''.$langs->trans("EMailsSenderProfileDesc")."
\n"; print "
\n"; @@ -427,7 +427,7 @@ print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorde $topicmail = "Information"; //$modelmail="subscription"; $objecttmp = new EmailSenderProfile($db); -//$trackid='sub'.$object->id; +//$trackid = (($action == 'testhtml') ? "testhtml" : "test"); include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) @@ -474,7 +474,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; @@ -645,7 +645,7 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n print $formfile->showdocuments('massfilesarea_emailsenderprofile', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 1158ee56655..f63af39e985 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -11,7 +11,7 @@ * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,7 +67,6 @@ $actl[1] = img_picto($langs->trans("Activated"), 'switch_on'); $listoffset = GETPOST('listoffset', 'alpha'); $listlimit = GETPOST('listlimit', 'alpha') > 0 ?GETPOST('listlimit', 'alpha') : 1000; -$active = 1; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -140,36 +139,77 @@ if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabhelp = array(); -$tabhelp[25] = array('topic'=>$helpsubstit, 'joinfiles'=>$langs->trans('AttachMainDocByDefault'), 'content'=>$helpsubstit, 'content_lines'=>$helpsubstitforlines, 'type_template'=>$langs->trans("TemplateForElement"), 'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList")); +$tabhelp[25] = array( + 'topic'=>$helpsubstit, + 'joinfiles'=>$langs->trans('AttachMainDocByDefault'), + 'content'=>$helpsubstit, + 'content_lines'=>$helpsubstitforlines, + 'type_template'=>$langs->trans("TemplateForElement"), + 'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), + 'position'=>$langs->trans("PositionIntoComboList") +); // List of check for fields (NOT USED YET) $tabfieldcheck = array(); $tabfieldcheck[25] = array(); -// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); -$sourceList = array(); // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']" $elementList = array(); -if ($conf->propal->enabled && $user->rights->propal->lire) $elementList['propal_send'] = $langs->trans('MailToSendProposal'); -if ($conf->commande->enabled && $user->rights->commande->lire) $elementList['order_send'] = $langs->trans('MailToSendOrder'); -if ($conf->facture->enabled && $user->rights->facture->lire) $elementList['facture_send'] = $langs->trans('MailToSendInvoice'); -if ($conf->expedition->enabled) $elementList['shipping_send'] = $langs->trans('MailToSendShipment'); -if ($conf->reception->enabled) $elementList['reception_send'] = $langs->trans('MailToSendReception'); -if ($conf->ficheinter->enabled) $elementList['fichinter_send'] = $langs->trans('MailToSendIntervention'); -if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send'] = $langs->trans('MailToSendSupplierRequestForQuotation'); -if (($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ($conf->supplier_order->enabled && $user->rights->supplier_order->lire)) $elementList['order_supplier_send'] = $langs->trans('MailToSendSupplierOrder'); -if (($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ($conf->supplier_invoice->enabled && $user->rights->supplier_invoice->lire)) $elementList['invoice_supplier_send'] = $langs->trans('MailToSendSupplierInvoice'); -if ($conf->societe->enabled && $user->rights->societe->lire) $elementList['thirdparty'] = $langs->trans('MailToThirdparty'); -if ($conf->adherent->enabled && $user->rights->adherent->lire) $elementList['member'] = $langs->trans('MailToMember'); -if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementList['contract'] = $langs->trans('MailToSendContract'); -if ($conf->projet->enabled) $elementList['project'] = $langs->trans('MailToProject'); -if ($conf->ticket->enabled && $user->rights->ticket->read) $elementList['ticket_send'] = $langs->trans('MailToTicket'); -if ($conf->recruitment->enabled && $user->rights->recruitment->recruitmentjobposition->read) $elementList['recruitmentcandidature_send'] = $langs->trans('RecruitmentCandidatures'); -if ($conf->agenda->enabled) $elementList['actioncomm_send'] = $langs->trans('MailToSendEventPush'); -$elementList['user'] = $langs->trans('MailToUser'); +// Add all and none after the sort +$elementList['all'] = '-- '.dol_escape_htmltag($langs->trans("All")).' --'; +$elementList['none'] = '-- '.dol_escape_htmltag($langs->trans("None")).' --'; +$elementList['user'] = img_picto('', 'user', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToUser')); +if ($conf->adherent->enabled && $user->rights->adherent->lire) { + $elementList['member'] = img_picto('', 'object_member', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToMember')); +} +if ($conf->recruitment->enabled && $user->rights->recruitment->recruitmentjobposition->read) { + $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="paddingright"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures')); +} +if ($conf->societe->enabled && $user->rights->societe->lire) { + $elementList['thirdparty'] = img_picto('', 'company', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToThirdparty')); +} +if ($conf->projet->enabled) { + $elementList['project'] = img_picto('', 'project', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToProject')); +} +if ($conf->propal->enabled && $user->rights->propal->lire) { + $elementList['propal_send'] = img_picto('', 'propal', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendProposal')); +} +if ($conf->commande->enabled && $user->rights->commande->lire) { + $elementList['order_send'] = img_picto('', 'order', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendOrder')); +} +if ($conf->facture->enabled && $user->rights->facture->lire) { + $elementList['facture_send'] = img_picto('', 'bill', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendInvoice')); +} +if ($conf->expedition->enabled) { + $elementList['shipping_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendShipment')); +} +if ($conf->reception->enabled) { + $elementList['reception_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendReception')); +} +if ($conf->ficheinter->enabled) { + $elementList['fichinter_send'] = img_picto('', 'intervention', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendIntervention')); +} +if ($conf->supplier_proposal->enabled) { + $elementList['supplier_proposal_send'] = img_picto('', 'propal', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierRequestForQuotation')); +} +if (($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ($conf->supplier_order->enabled && $user->rights->supplier_order->lire)) { + $elementList['order_supplier_send'] = img_picto('', 'order', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierOrder')); +} +if (($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ($conf->supplier_invoice->enabled && $user->rights->supplier_invoice->lire)) { + $elementList['invoice_supplier_send'] = img_picto('', 'bill', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierInvoice')); +} +if ($conf->contrat->enabled && $user->rights->contrat->lire) { + $elementList['contract'] = img_picto('', 'contract', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendContract')); +} +if ($conf->ticket->enabled && $user->rights->ticket->read) { + $elementList['ticket_send'] = img_picto('', 'ticket', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTicket')); +} +if ($conf->agenda->enabled) { + $elementList['actioncomm_send'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventPush')); +} $parameters = array('elementList'=>$elementList); $reshook = $hookmanager->executeHooks('emailElementlist', $parameters); // Note that $action and $object may have been modified by some hooks @@ -179,11 +219,7 @@ if ($reshook == 0) { } } -// Add all and none after the sort -$elementList['all'] = '-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')'; -$elementList['none'] = '-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')'; - -asort($elementList); +//asort($elementList); $id = 25; @@ -192,18 +228,22 @@ $id = 25; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; +} if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // All tests are required to be compatible with all browsers $search_label = ''; $search_type_template = ''; $search_lang = ''; @@ -214,8 +254,7 @@ if (empty($reshook)) } // Actions add or modify an entry into a dictionary - if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) - { + if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); $listfieldinsert = explode(',', $tabfieldinsert[$id]); $listfieldmodify = explode(',', $tabfieldinsert[$id]); @@ -223,8 +262,7 @@ if (empty($reshook)) // Check that all fields are filled $ok = 1; - foreach ($listfield as $f => $value) - { + foreach ($listfield as $f => $value) { // Not mandatory fields if ($value == 'joinfiles') continue; if ($value == 'content') continue; @@ -277,9 +315,15 @@ if (empty($reshook)) if ($i) $sql .= ", "; if (GETPOST($keycode) == '' && $keycode != 'langcode') $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work - elseif ($keycode == 'content') { + elseif ($keycode == 'fk_user') { + if (!$user->admin) { // A non admin user can only edit its own template + $sql .= " ".((int) $user->id); + } else { + $sql .= " ".((int) GETPOST($keycode, 'fk_user')); + } + } elseif ($keycode == 'content') { $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; - } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { + } elseif (in_array($keycode, array('joinfile', 'private', 'position'))) { $sql .= (int) GETPOST($keycode, 'int'); } else { $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; @@ -303,7 +347,7 @@ if (empty($reshook)) } } - // Si verif ok et action modify, on modifie la ligne + // We modify the line if ($ok && GETPOST('actionmodify')) { $rowidcol = "rowid"; @@ -330,9 +374,15 @@ if (empty($reshook)) if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work - elseif ($keycode == 'content') { + elseif ($keycode == 'fk_user') { + if (!$user->admin) { // A non admin user can only edit its own template + $sql .= " ".((int) $user->id); + } else { + $sql .= " ".((int) GETPOST($keycode, 'fk_user')); + } + } elseif ($keycode == 'content') { $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'"; - } elseif (in_array($keycode, array('joinfile', 'private', 'position', 'scale'))) { + } elseif (in_array($keycode, array('joinfile', 'private', 'position'))) { $sql .= (int) GETPOST($keycode, 'int'); } else { $sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'"; @@ -342,6 +392,9 @@ if (empty($reshook)) } $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); + if (!$user->admin) { // A non admin user can only edit its own template + $sql .= " AND fk_user = ".$user->id; + } //print $sql;exit; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; @@ -360,7 +413,9 @@ if (empty($reshook)) $rowidcol = "rowid"; $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."=".((int) $rowid); - + if (!$user->admin) { // A non admin user can only edit its own template + $sql .= " AND fk_user = ".$user->id; + } dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); if (!$result) @@ -414,7 +469,7 @@ $formadmin = new FormAdmin($db); $help_url = ''; $title = $langs->trans("EMailsSetup"); -llxHeader('', $title); +llxHeader('', $title, $help_url); $linkback = ''; $titlepicto = 'title_setup'; @@ -423,17 +478,16 @@ print load_fiche_titre($title, $linkback, $titlepicto); $head = email_admin_prepare_head(); -dol_fiche_head($head, 'templates', '', -1); +print dol_get_fiche_head($head, 'templates', '', -1); // Confirmation de la suppression de la ligne if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } -//var_dump($elementList); -$sql = "SELECT rowid as rowid, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, enabled, active"; +$sql = "SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, joinfiles, content_lines, content, enabled, active"; $sql .= " FROM ".MAIN_DB_PREFIX."c_email_templates"; $sql .= " WHERE entity IN (".getEntity('email_template').")"; if (!$user->admin) @@ -481,7 +535,7 @@ if ($action == 'view') { if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } - if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); } + if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); $align = "center"; } if ($fieldlist[$field] == 'private') { $align = 'center'; } if ($fieldlist[$field] == 'position') { $align = 'center'; } @@ -492,7 +546,7 @@ if ($action == 'view') { if ($valuetoshow != '') { - print ''; + print ''; if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; elseif (!empty($tabhelp[$id][$value])) { @@ -570,14 +624,12 @@ if ($action == 'view') { } elseif ($tmpfieldlist == 'joinfiles') { print ''; } else { - if ($context != 'hide') { - // print ''; - $okforextended = true; - if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) - $okforextended = false; - $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%'); - print $doleditor->Create(1); - } else print ' '; + // print ''; + $okforextended = true; + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) + $okforextended = false; + $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 180, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_4, '90%'); + print $doleditor->Create(1); } print ''; if ($tmpfieldlist == 'topic') { @@ -591,11 +643,6 @@ if ($action == 'view') { print ''; } - - - $colspan = count($fieldlist) + 1; - //print ' '; // Keep   to have a line with enough height - print ''; print '
'; print ''; @@ -641,26 +688,24 @@ if ($resql) // Title line with search boxes print ''; - $filterfound = 0; foreach ($fieldlist as $field => $value) { if ($value == 'label') { print ''; } elseif ($value == 'lang') { print ''; - print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100'); + print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth150'); print ''; } elseif ($value == 'fk_user') { print ''; - $restrictid = array(); - if (!$user->admin) $restrictid = array($user->id); - //var_dump($restrictid); - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth100'); + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 1, '', 0, '', 'maxwidth150'); print ''; } elseif ($value == 'topic') { print ''; } elseif ($value == 'type_template') { - print ''.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 maxwidth100onsmartphone').''; + print ''; + print $form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth200', 1, '', 0, 1); + print ''; } elseif (!in_array($value, array('content', 'content_lines'))) { print ''; } @@ -792,6 +837,13 @@ if ($resql) print "\n"; } else { + if ($obj->module) { + $tempmodulekey = $obj->module; + if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { + $i++; + continue; + } + } $keyforobj = 'type_template'; if (!in_array($obj->$keyforobj, array_keys($elementList))) { @@ -819,22 +871,26 @@ if ($resql) { if (in_array($fieldlist[$field], array('content', 'content_lines'))) continue; $showfield = 1; - $align = "left"; + $align = ""; + $class = "tddict"; $valuetoshow = $obj->{$fieldlist[$field]}; - if ($value == 'label' || $value == 'topic') - { + if ($value == 'label' || $value == 'topic') { $valuetoshow = dol_escape_htmltag($valuetoshow); } - if ($value == 'type_template') - { - $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; + if ($value == 'label') { + $class .= ' tdoverflowmax100'; } - if ($value == 'lang' && $valuetoshow) - { + /*if ($value == 'topic') { + $class .= ' tdoverflowmax300'; + }*/ + if ($value == 'type_template') { + $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; + $align = "center"; + } + if ($value == 'lang' && $valuetoshow) { $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow); } - if ($value == 'fk_user') - { + if ($value == 'fk_user') { if ($valuetoshow > 0) { $fuser = new User($db); @@ -842,29 +898,25 @@ if ($resql) $valuetoshow = $fuser->getNomUrl(1); } } - if ($value == 'private') - { + if ($value == 'private') { $align = "center"; if ($valuetoshow) $valuetoshow = yn($valuetoshow); else $valuetoshow = ''; } - if ($value == 'position') - { + if ($value == 'position') { $align = "center"; } - if ($value == 'joinfiles') - { + if ($value == 'joinfiles') { $align = "center"; if ($valuetoshow) $valuetoshow = 1; else $valuetoshow = ''; } + if ($align) $class .= ' '.$align; - $class = 'tddict'; // Show value for field - if ($showfield) - { + if ($showfield) { print ''; - print ''.$valuetoshow.''; + print ''.$valuetoshow.''; } } } @@ -943,7 +995,7 @@ print '
'; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); @@ -963,7 +1015,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') { global $conf, $langs, $user, $db; global $form; - global $elementList, $sourceList; + global $elementList; $formadmin = new FormAdmin($db); @@ -972,9 +1024,8 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if ($fieldlist[$field] == 'fk_user') { print ''; - if ($user->admin) - { - print $form->select_dolusers($obj->{$fieldlist[$field]}, 'fk_user', 1, null, 0, '', null, 0, 0, 1, '', 0, '', 'maxwidth200'); + if ($user->admin) { + print $form->select_dolusers($obj->{$fieldlist[$field]}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 1, '', 0, '', 'maxwidth200'); } else { if ($context == 'add') // I am not admin and we show the add form { @@ -1017,14 +1068,14 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') // Le type de template elseif ($fieldlist[$field] == 'type_template') { - print ''; + print ''; if ($context == 'edit' && !empty($obj->{$fieldlist[$field]}) && !in_array($obj->{$fieldlist[$field]}, array_keys($elementList))) { // Current tempalte type is an unknown type, so we must keep it as it is. print ''; print $obj->{$fieldlist[$field]}; } else { - print $form->selectarray('type_template', $elementList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth150 maxwidth100onsmartphone'); + print $form->selectarray('type_template', $elementList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth200', 1, '', 0, 1); } print ''; } elseif ($context == 'add' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 39e159535ba..dda9d0c01a8 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -60,7 +60,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && empty($_POST["cancel"])) { - // Send mode parameters + // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_TICKET", GETPOST("MAIN_MAIL_SENDMODE_TICKET"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_TICKET", GETPOST("MAIN_MAIL_SMTP_SERVER_TICKET"), 'chaine', 0, '', $conf->entity); @@ -215,7 +215,7 @@ if ($action == 'edit') print ''; print ''; - dol_fiche_head($head, 'common_ticket', '', -1); + print dol_get_fiche_head($head, 'common_ticket', '', -1); print ''.$langs->trans("EMailsDesc")."
\n"; print "
\n"; @@ -359,22 +359,22 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - print ''; + print ''; - dol_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; } else { - dol_fiche_head($head, 'common_ticket', '', -1); + print dol_get_fiche_head($head, 'common_ticket', '', -1); - print ''.$langs->trans("EMailsDesc")."
\n"; - print "
\n"; + print ''.$langs->trans("EMailsDesc")."
\n"; + print "
\n"; print ''; print ''; @@ -441,13 +441,13 @@ if ($action == 'edit') print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - dol_fiche_end(); + print dol_get_fiche_end(); - if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) - { - print '
'; - /* + if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) + { + print '
'; + /* // Warning 1 if ($linuxlike) { @@ -457,12 +457,12 @@ if ($action == 'edit') print info_admin($langs->trans("SendmailOptionNotComplete")); } }*/ - // Warning 2 - print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); - } + // Warning 2 + print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); + } - // Buttons for actions + // Buttons for actions print '
'; @@ -493,8 +493,8 @@ if ($action == 'edit') if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) { - $text = $langs->trans("WarningPHPMail"); - print info_admin($text); + $text = $langs->trans("WarningPHPMail"); + print info_admin($text); } // Run the test to connect @@ -522,10 +522,10 @@ if ($action == 'edit') // Show email send test form if ($action == 'test' || $action == 'testhtml') { - print '
'; + print '
'; print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); - dol_fiche_head(''); + print dol_get_fiche_head(''); // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; @@ -558,14 +558,14 @@ if ($action == 'edit') $formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode") == 'init') + if (GETPOST("mode") == 'init') { $formmail->clear_attached_files(); } print $formmail->get_form('addfile', 'removefile'); - dol_fiche_end(); + print dol_get_fiche_end(); } } diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index ff15bbdcd40..9bdc497c776 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -151,7 +151,7 @@ print '
'; print ''; print ''; -dol_fiche_head($head, 'handler', '', -1); +print dol_get_fiche_head($head, 'handler', '', -1); print ''.$langs->trans("MenusDesc")."
\n"; print "
\n"; @@ -206,7 +206,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index 31e0f896633..70d2f4bcda6 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -299,7 +299,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print ''; @@ -398,7 +398,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -417,7 +417,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print ''; @@ -507,7 +507,7 @@ if ($action == 'create') print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); // Bouton print '
'; diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index f83507c37aa..f55a2a74874 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -38,8 +38,8 @@ $dirsmartphone = array(); $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); foreach ($dirmenus as $dirmenu) { - $dirstandard[] = $dirmenu.'standard'; - $dirsmartphone[] = $dirmenu.'smartphone'; + $dirstandard[] = $dirmenu.'standard'; + $dirsmartphone[] = $dirmenu.'smartphone'; } $action = GETPOST('action', 'aZ09'); @@ -229,7 +229,7 @@ $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'misc'; $h++; -dol_fiche_head($head, 'editor', '', -1); +print dol_get_fiche_head($head, 'editor', '', -1); print ''.$langs->trans("MenusEditorDesc")."
\n"; print "
\n"; @@ -244,13 +244,13 @@ if ($action == 'delete') $result = $db->query($sql); $obj = $db->fetch_object($result); - print $form->formconfirm("index.php?menu_handler=".$menu_handler."&menuId=".GETPOST('menuId', 'int'), $langs->trans("DeleteMenu"), $langs->trans("ConfirmDeleteMenu", $obj->title), "confirm_delete"); + print $form->formconfirm("index.php?menu_handler=".$menu_handler."&menuId=".GETPOST('menuId', 'int'), $langs->trans("DeleteMenu"), $langs->trans("ConfirmDeleteMenu", $obj->title), "confirm_delete"); } $newcardbutton = ''; if ($user->admin) { - $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF'])); + $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF'])); } print ''; @@ -297,7 +297,7 @@ if ($conf->use_javascript_ajax) //il faut d'abord declarer un element racine de l'arbre - $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); + $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); //puis tous les elements enfants @@ -337,16 +337,16 @@ if ($conf->use_javascript_ajax) $data[] = array( 'rowid'=>$menu['rowid'], - 'module'=>$menu['module'], + 'module'=>$menu['module'], 'fk_menu'=>$menu['fk_menu'], 'title'=>$titre, - 'mainmenu'=>$menu['mainmenu'], + 'mainmenu'=>$menu['mainmenu'], 'leftmenu'=>$menu['leftmenu'], 'fk_mainmenu'=>$menu['fk_mainmenu'], 'fk_leftmenu'=>$menu['fk_leftmenu'], - 'position'=>$menu['position'], + 'position'=>$menu['position'], 'entry'=>$entry, - 'buttons'=>$buttons + 'buttons'=>$buttons ); $i++; } @@ -369,36 +369,36 @@ if ($conf->use_javascript_ajax) // Process remaining records (records that are not linked to root by any path) - $remainingdata = array(); + $remainingdata = array(); foreach ($data as $datar) { - if (empty($datar['rowid']) || $tree_recur_alreadyadded[$datar['rowid']]) continue; - $remainingdata[] = $datar; + if (empty($datar['rowid']) || $tree_recur_alreadyadded[$datar['rowid']]) continue; + $remainingdata[] = $datar; } if (count($remainingdata)) { - print ''; + print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - print '
'.$langs->trans("NotTopTreeMenuPersonalized").'
'.$langs->trans("NotTopTreeMenuPersonalized").'
'; - foreach ($remainingdata as $datar) - { - $father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); - //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'
'."\n"; - tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1); - } + print '
'; + foreach ($remainingdata as $datar) + { + $father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); + //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'
'."\n"; + tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1); + } - print '
'; + print ''; } print '
'; diff --git a/htdocs/admin/menus/other.php b/htdocs/admin/menus/other.php index cd8c7cccfa6..2450d572abd 100644 --- a/htdocs/admin/menus/other.php +++ b/htdocs/admin/menus/other.php @@ -75,7 +75,7 @@ $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'misc'; $h++; -dol_fiche_head($head, 'misc', '', -1); +print dol_get_fiche_head($head, 'misc', '', -1); // Other Options diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index c788eca01d3..7aa36b843cd 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -91,106 +91,106 @@ foreach ($modulesdir as $dir) while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n
"; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { - $modName = substr($file, 0, dol_strlen($file) - 10); + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + { + $modName = substr($file, 0, dol_strlen($file) - 10); - if ($modName) - { - if (!empty($modNameLoaded[$modName])) - { - $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; - setEventMessages($mesg, null, 'warnings'); - dol_syslog($mesg, LOG_ERR); + if ($modName) + { + if (!empty($modNameLoaded[$modName])) + { + $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; + setEventMessages($mesg, null, 'warnings'); + dol_syslog($mesg, LOG_ERR); continue; - } + } - try { - $res = include_once $dir.$file; - if (class_exists($modName)) + try { + $res = include_once $dir.$file; + if (class_exists($modName)) { try { - $objMod = new $modName($db); + $objMod = new $modName($db); $modNameLoaded[$modName] = $dir; - if (!$objMod->numero > 0 && $modName != 'modUser') - { - dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); - } + if (!$objMod->numero > 0 && $modName != 'modUser') + { + dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); + } $j = $objMod->numero; - $modulequalified = 1; + $modulequalified = 1; - // We discard modules according to features level (PS: if module is activated we always show it) - $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; - if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; + // We discard modules according to features level (PS: if module is activated we always show it) + $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); + if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; + if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified = 0; - // We discard modules according to property disabled - //if (! empty($objMod->hidden)) $modulequalified=0; + // We discard modules according to property disabled + //if (! empty($objMod->hidden)) $modulequalified=0; - if ($modulequalified > 0) - { - $publisher = dol_escape_htmltag($objMod->getPublisher()); - $external = ($objMod->isCoreOrExternalModule() == 'external'); - if ($external) - { - if ($publisher) - { - $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; - } else { - $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); - } - } - ksort($arrayofnatures); - } + if ($modulequalified > 0) + { + $publisher = dol_escape_htmltag($objMod->getPublisher()); + $external = ($objMod->isCoreOrExternalModule() == 'external'); + if ($external) + { + if ($publisher) + { + $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; + } else { + $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); + } + } + ksort($arrayofnatures); + } - // Define array $categ with categ with at least one qualified module - if ($modulequalified > 0) - { - $modules[$i] = $objMod; - $filename[$i] = $modName; + // Define array $categ with categ with at least one qualified module + if ($modulequalified > 0) + { + $modules[$i] = $objMod; + $filename[$i] = $modName; - // Gives the possibility to the module, to provide his own family info and position of this family - if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { - if (!is_array($familyinfo)) $familyinfo = array(); - $familyinfo = array_merge($familyinfo, $objMod->familyinfo); - $familykey = key($objMod->familyinfo); - } else { - $familykey = $objMod->family; - } + // Gives the possibility to the module, to provide his own family info and position of this family + if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { + if (!is_array($familyinfo)) $familyinfo = array(); + $familyinfo = array_merge($familyinfo, $objMod->familyinfo); + $familykey = key($objMod->familyinfo); + } else { + $familykey = $objMod->family; + } - $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); - if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) - { - $moduleposition = '80'; // External modules at end by default - } + $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); + if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) + { + $moduleposition = '80'; // External modules at end by default + } - $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number - $dirmod[$i] = $dir; - //print $i.'-'.$dirmod[$i].'
'; - // Set categ[$i] - $specialstring = 'unknown'; - if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; - if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories - else $categ[$specialstring] = 1; - $j++; - $i++; - } else dol_syslog("Module ".get_class($objMod)." not qualified"); + $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number + $dirmod[$i] = $dir; + //print $i.'-'.$dirmod[$i].'
'; + // Set categ[$i] + $specialstring = 'unknown'; + if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; + if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories + else $categ[$specialstring] = 1; + $j++; + $i++; + } else dol_syslog("Module ".get_class($objMod)." not qualified"); } catch (Exception $e) - { - dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); - } + { + dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); + } } else { print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; } } catch (Exception $e) - { - dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); - } - } - } + { + dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); + } + } + } } closedir($handle); } else { @@ -208,16 +208,16 @@ unset($objMod); $i = 0; foreach ($orders as $tmpkey => $tmpvalue) { - $tmpMod = $modules[$tmpkey]; - if ($tmpMod->numero == $id) - { - $key = $i; - $modName = $filename[$tmpkey]; - $dirofmodule = $dirmod[$tmpkey]; - $objMod = $tmpMod; - break; - } - $i++; + $tmpMod = $modules[$tmpkey]; + if ($tmpMod->numero == $id) + { + $key = $i; + $modName = $filename[$tmpkey]; + $dirofmodule = $dirmod[$tmpkey]; + $objMod = $tmpMod; + break; + } + $i++; } $value = $orders[$key]; $tab = explode('_', $value); @@ -265,7 +265,7 @@ $picto = 'object_'.$objMod->picto; print load_fiche_titre(($modulename ? $modulename : $moduledesc), $moreinfo, $picto, 0, '', 'titlemodulehelp'); print '
'; -dol_fiche_head($head, $mode, '', -1); +print dol_get_fiche_head($head, $mode, '', -1); if (!$modulename) { @@ -296,7 +296,7 @@ $versiontrans .= $objMod->getVersion(1); $imginfo = "info"; if ($objMod->isCoreOrExternalModule() == 'external') { - $imginfo = "info_black"; + $imginfo = "info_black"; } // Define text of description of module @@ -304,138 +304,138 @@ $text = ''; if ($mode == 'desc') { - if ($moduledesc) $text .= '
'.$moduledesc.'


'; + if ($moduledesc) $text .= '
'.$moduledesc.'


'; - $text .= ''.$langs->trans("Version").': '.$version; + $text .= ''.$langs->trans("Version").': '.$version; - $moduledescriptorfile = get_class($objMod).'.class.php'; - $text .= '
'.$langs->trans("DescriptorFile").': '.$moduledescriptorfile; + $moduledescriptorfile = get_class($objMod).'.class.php'; + $text .= '
'.$langs->trans("DescriptorFile").': '.$moduledescriptorfile; - $textexternal = ''; - if ($objMod->isCoreOrExternalModule() == 'external') - { - $textexternal .= '
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $dirofmodule); - if ($objMod->editor_name != 'dolibarr') $textexternal .= '
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name); - $editor_url = $objMod->editor_url; - if (!preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url; - if (!empty($objMod->editor_url) && !preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' '.$objMod->editor_url.''; - $text .= $textexternal; - $text .= '
'; - } else { - $text .= '
'.$langs->trans("Origin").': '.$langs->trans("Core").'
'; - } + $textexternal = ''; + if ($objMod->isCoreOrExternalModule() == 'external') + { + $textexternal .= '
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $dirofmodule); + if ($objMod->editor_name != 'dolibarr') $textexternal .= '
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name); + $editor_url = $objMod->editor_url; + if (!preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url; + if (!empty($objMod->editor_url) && !preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' '.$objMod->editor_url.''; + $text .= $textexternal; + $text .= '
'; + } else { + $text .= '
'.$langs->trans("Origin").': '.$langs->trans("Core").'
'; + } - $moduledesclong = $objMod->getDescLong(); - if ($moduledesclong) $text .= '

'.$moduledesclong.'
'; + $moduledesclong = $objMod->getDescLong(); + if ($moduledesclong) $text .= '

'.$moduledesclong.'
'; } if ($mode == 'feature') { - $text .= '
'.$langs->trans("DependsOn").': '; - if (count($objMod->depends)) $text .= join(',', $objMod->depends); + $text .= '
'.$langs->trans("DependsOn").': '; + if (count($objMod->depends)) $text .= join(',', $objMod->depends); else $text .= $langs->trans("None"); - $text .= '
'.$langs->trans("RequiredBy").': '; + $text .= '
'.$langs->trans("RequiredBy").': '; if (count($objMod->requiredby)) $text .= join(',', $objMod->requiredby); else $text .= $langs->trans("None"); - $text .= '

'; + $text .= '

'; - $text .= '
'.$langs->trans("AddDataTables").': '; + $text .= '
'.$langs->trans("AddDataTables").': '; $sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back')); - if (count($sqlfiles) > 0) - { - $text .= $langs->trans("Yes").' ('; - $i = 0; - foreach ($sqlfiles as $val) - { - $text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); - $i++; - } - $text .= ')'; - } else $text .= $langs->trans("No"); + if (count($sqlfiles) > 0) + { + $text .= $langs->trans("Yes").' ('; + $i = 0; + foreach ($sqlfiles as $val) + { + $text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); + $i++; + } + $text .= ')'; + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddDictionaries").': '; - if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib'])) - { - $i = 0; - foreach ($objMod->dictionaries['tablib'] as $val) - { - $text .= ($i ? ', ' : '').$val; - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddDictionaries").': '; + if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib'])) + { + $i = 0; + foreach ($objMod->dictionaries['tablib'] as $val) + { + $text .= ($i ? ', ' : '').$val; + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddData").': '; - $filedata = dol_buildpath($moduledir.'/sql/data.sql'); - if (dol_is_file($filedata)) - { - $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddData").': '; + $filedata = dol_buildpath($moduledir.'/sql/data.sql'); + if (dol_is_file($filedata)) + { + $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddRemoveTabs").': '; - if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) - { - $i = 0; - foreach ($objMod->tabs as $val) - { - if (is_array($val)) $val = $val['data']; - if (is_string($val)) - { - $tmp = explode(':', $val, 3); - $text .= ($i ? ', ' : '').$tmp[0].':'.$tmp[1]; - $i++; - } - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddRemoveTabs").': '; + if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) + { + $i = 0; + foreach ($objMod->tabs as $val) + { + if (is_array($val)) $val = $val['data']; + if (is_string($val)) + { + $tmp = explode(':', $val, 3); + $text .= ($i ? ', ' : '').$tmp[0].':'.$tmp[1]; + $i++; + } + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddModels").': '; - if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) - { - $text .= $langs->trans("Yes"); - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddModels").': '; + if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) + { + $text .= $langs->trans("Yes"); + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddSubstitutions").': '; - if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) - { - $text .= $langs->trans("Yes"); - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddSubstitutions").': '; + if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) + { + $text .= $langs->trans("Yes"); + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddSheduledJobs").': '; - if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs)) - { - $i = 0; - foreach ($objMod->cronjobs as $val) - { - $text .= ($i ? ', ' : '').($val['label']); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddSheduledJobs").': '; + if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs)) + { + $i = 0; + foreach ($objMod->cronjobs as $val) + { + $text .= ($i ? ', ' : '').($val['label']); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddTriggers").': '; - $moreinfoontriggerfile = ''; - if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) - { - $yesno = 'Yes'; - } else { - $yesno = 'No'; - } - require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interfaces = new Interfaces($db); - $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external') ? '/'.$moduledir : '').'/core/triggers')); + $text .= '
'.$langs->trans("AddTriggers").': '; + $moreinfoontriggerfile = ''; + if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) + { + $yesno = 'Yes'; + } else { + $yesno = 'No'; + } + require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interfaces = new Interfaces($db); + $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external') ? '/'.$moduledir : '').'/core/triggers')); foreach ($triggers as $triggercursor) { if ($triggercursor['module'] == $moduledir) @@ -445,116 +445,116 @@ if ($mode == 'feature') } } - $text .= $langs->trans($yesno).$moreinfoontriggerfile; + $text .= $langs->trans($yesno).$moreinfoontriggerfile; - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddBoxes").': '; - if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) - { - $i = 0; - foreach ($objMod->boxes as $val) - { - $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddBoxes").': '; + if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) + { + $i = 0; + foreach ($objMod->boxes as $val) + { + $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddHooks").': '; - if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) - { - $i = 0; - foreach ($objMod->module_parts['hooks'] as $key => $val) - { - if ($key === 'entity') continue; + $text .= '
'.$langs->trans("AddHooks").': '; + if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) + { + $i = 0; + foreach ($objMod->module_parts['hooks'] as $key => $val) + { + if ($key === 'entity') continue; - // For special values - if ($key === 'data') - { - if (is_array($val)) - { - foreach ($val as $value) - { - $text .= ($i ? ', ' : '').($value); - $i++; - } + // For special values + if ($key === 'data') + { + if (is_array($val)) + { + foreach ($val as $value) + { + $text .= ($i ? ', ' : '').($value); + $i++; + } - continue; - } - } + continue; + } + } - $text .= ($i ? ', ' : '').($val); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= ($i ? ', ' : '').($val); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddPermissions").': '; - if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights)) - { - $i = 0; - foreach ($objMod->rights as $val) - { - $text .= ($i ? ', ' : '').($val[1]); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddPermissions").': '; + if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights)) + { + $i = 0; + foreach ($objMod->rights as $val) + { + $text .= ($i ? ', ' : '').($val[1]); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddMenus").': '; - if (isset($objMod->menu) && !empty($objMod->menu)) // objMod can be an array or just an int 1 - { - $text .= $langs->trans("Yes"); - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddMenus").': '; + if (isset($objMod->menu) && !empty($objMod->menu)) // objMod can be an array or just an int 1 + { + $text .= $langs->trans("Yes"); + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddExportProfiles").': '; - if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label)) - { - $i = 0; - foreach ($objMod->export_label as $val) - { - $text .= ($i ? ', ' : '').($val); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddExportProfiles").': '; + if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label)) + { + $i = 0; + foreach ($objMod->export_label as $val) + { + $text .= ($i ? ', ' : '').($val); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddImportProfiles").': '; - if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label)) - { - $i = 0; - foreach ($objMod->import_label as $val) - { - $text .= ($i ? ', ' : '').($val); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddImportProfiles").': '; + if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label)) + { + $i = 0; + foreach ($objMod->import_label as $val) + { + $text .= ($i ? ', ' : '').($val); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddOtherPagesOrServices").': '; - $text .= $langs->trans("DetectionNotPossible"); + $text .= '
'.$langs->trans("AddOtherPagesOrServices").': '; + $text .= $langs->trans("DetectionNotPossible"); } if ($mode == 'changelog') { - $changelog = $objMod->getChangeLog(); - if ($changelog) $text .= '
'.$changelog.'
'; - else $text .= '
'.$langs->trans("NotAvailable").'
'; + $changelog = $objMod->getChangeLog(); + if ($changelog) $text .= '
'.$changelog.'
'; + else $text .= '
'.$langs->trans("NotAvailable").'
'; } print $text; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 3ca08f90900..e7b7e2cd59b 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -28,6 +28,8 @@ * \brief Page to activate/disable all modules */ +if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -279,7 +281,7 @@ if ($action == 'set' && $user->admin) $form = new Form($db); -//$morejs = array("/admin/dolistore/js/dolistore.js.php"); +$morejs = array(); $morecss = array("/admin/dolistore/css/dolistore.css"); // Set dir where external modules are installed @@ -400,9 +402,9 @@ foreach ($modulesdir as $dir) $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext; } - $familyposition = $familyinfo[$familykey]['position']; + $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']); $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other'); - if ($external && ! in_array($familykey, $listOfOfficialModuleGroups)) + if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) { // If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups). if (is_numeric($familyposition)) { @@ -494,7 +496,7 @@ if ($mode == 'common' || $mode == 'commonkanban') $newmode = $mode; if ($newmode == 'common') $newmode = 'commonkanban'; - dol_fiche_head($head, $newmode, '', -1); + print dol_get_fiche_head($head, $newmode, '', -1); $moreforfilter = '
'; @@ -701,11 +703,11 @@ if ($mode == 'common' || $mode == 'commonkanban') if (!empty($conf->multicompany->enabled) && $user->entity) $disableSetup++; } else { if (!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { - $codeenabledisable .= 'warnings_unactivation[$mysoc->country_code].'&value='.$modName.'&mode='.$mode.$param.'">'; + $codeenabledisable .= 'warnings_unactivation[$mysoc->country_code].'&value='.$modName.'&mode='.$mode.$param.'">'; $codeenabledisable .= img_picto($langs->trans("Activated"), 'switch_on'); $codeenabledisable .= ''; } else { - $codeenabledisable .= ''; + $codeenabledisable .= ''; $codeenabledisable .= img_picto($langs->trans("Activated"), 'switch_on'); $codeenabledisable .= ''; } @@ -881,7 +883,7 @@ if ($mode == 'common' || $mode == 'commonkanban') } } - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -893,7 +895,7 @@ if ($mode == 'common' || $mode == 'commonkanban') if ($mode == 'marketplace') { - dol_fiche_head($head, $mode, '', -1); + print dol_get_fiche_head($head, $mode, '', -1); // Marketplace print '
'; @@ -914,7 +916,7 @@ if ($mode == 'marketplace') print "\n"; print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -978,7 +980,7 @@ if ($mode == 'marketplace') if ($mode == 'deploy') { - dol_fiche_head($head, $mode, '', -1); + print dol_get_fiche_head($head, $mode, '', -1); $dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT); $allowonlineinstall = true; @@ -1134,12 +1136,12 @@ if ($mode == 'deploy') } } - dol_fiche_end(); + print dol_get_fiche_end(); } if ($mode == 'develop') { - dol_fiche_head($head, $mode, '', -1); + print dol_get_fiche_head($head, $mode, '', -1); // Marketplace print "\n"; @@ -1151,8 +1153,6 @@ if ($mode == 'develop') print ''."\n"; print ''; print ''; @@ -1170,7 +1170,7 @@ if ($mode == 'develop') print "
'; - //span class="fa fa-bug"> - //print ''; print '
'; print '
'.$langs->trans("TryToUseTheModuleBuilder", $langs->transnoentitiesnoconv("ModuleBuilder")).'
\n"; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index 863633176bd..837a77fe2a7 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -182,7 +182,7 @@ print load_fiche_titre($langs->trans("MrpSetupPage"), $linkback, 'title_setup'); $head = mrpAdminPrepareHead(); -dol_fiche_head($head, 'settings', $langs->trans("MOs"), -1, 'mrp'); +print dol_get_fiche_head($head, 'settings', $langs->trans("MOs"), -1, 'mrp'); /* * MOs Numbering model diff --git a/htdocs/admin/mrp_extrafields.php b/htdocs/admin/mrp_extrafields.php index b0bd0e522ab..2a48713869c 100644 --- a/htdocs/admin/mrp_extrafields.php +++ b/htdocs/admin/mrp_extrafields.php @@ -70,19 +70,19 @@ print load_fiche_titre($langs->trans("MrpSetupPage"), $linkback, 'title_setup'); $head = mrpAdminPrepareHead(); -dol_fiche_head($head, 'mrp_extrafields', $langs->trans("ExtraFields"), -1, 'account'); +print dol_get_fiche_head($head, 'mrp_extrafields', $langs->trans("ExtraFields"), -1, 'account'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -92,9 +92,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -102,10 +102,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index a447551b04e..962adae93aa 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -34,7 +34,7 @@ $langs->loadLangs(array('admin', 'multicurrency')); // Access control if (!$user->admin) { - accessforbidden(); + accessforbidden(); } // Parameters @@ -52,9 +52,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) $value = GETPOST($code, 'alpha'); if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessages($langs->trans("Error"), null, 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -63,9 +63,9 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) $code = $reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessages($langs->trans("Error"), null, 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -132,17 +132,17 @@ if ($action == 'add_currency') } } elseif ($action == 'setapilayer') { - if (GETPOSTISSET('modify_apilayer')) - { - dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha')); - dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha')); - //dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha')); - } else { - $result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); - if ($result > 0) { - setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs"); - } - } + if (GETPOSTISSET('modify_apilayer')) + { + dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha')); + dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha')); + //dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha')); + } else { + $result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); + if ($result > 0) { + setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs"); + } + } } @@ -176,7 +176,7 @@ print load_fiche_titre($langs->trans($page_name), $linkback); // Configuration header $head = multicurrencyAdminPrepareHead(); -dol_fiche_head($head, 'settings', $langs->trans("ModuleSetup"), -1, "multicurrency"); +print dol_get_fiche_head($head, 'settings', $langs->trans("ModuleSetup"), -1, "multicurrency"); print ''; @@ -189,10 +189,10 @@ print ''; print ''; print ''; @@ -201,26 +201,26 @@ print ''; print ''; print ''; // Online payment with currency on document. This option should be on by default. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } /* TODO uncomment when the functionality will integrated @@ -258,9 +258,9 @@ print '
'; if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print '
'; print '
'.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE").''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE'); + print ajax_constantonoff('MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE", $arrval, $conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE", $arrval, $conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE); } print '
'.$langs->transnoentitiesnoconv("multicurrency_useOriginTx").''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MULTICURRENCY_USE_ORIGIN_TX'); + print ajax_constantonoff('MULTICURRENCY_USE_ORIGIN_TX'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MULTICURRENCY_USE_ORIGIN_TX", $arrval, $conf->global->MULTICURRENCY_USE_ORIGIN_TX); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MULTICURRENCY_USE_ORIGIN_TX", $arrval, $conf->global->MULTICURRENCY_USE_ORIGIN_TX); } print '
'.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT", $arrval, $conf->global->MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT); - } - print '
'.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT", $arrval, $conf->global->MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT); + } + print '
'; diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index b484e7acea9..13b1b4b3e55 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -61,8 +61,8 @@ if ($action == 'settemplates') $triggername = $reg[1]; $constvalue = GETPOST($key, 'alpha'); $consttype = 'emailtemplate:xxx'; - $tmparray=explode(':', $constvalue); - if (! empty($tmparray[0]) && ! empty($tmparray[1])) { + $tmparray = explode(':', $constvalue); + if (!empty($tmparray[0]) && !empty($tmparray[1])) { $constvalue = $tmparray[0]; $consttype = 'emailtemplate:'.$tmparray[1]; //var_dump($constvalue); @@ -96,19 +96,19 @@ if ($action == 'setvalue' && $user->admin) $db->begin(); $result = dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", GETPOST("email_from", "restricthtml"), 'chaine', 0, '', $conf->entity); - if ($result < 0) $error++; + if ($result < 0) $error++; - if (!$error) - { - $db->commit(); + if (!$error) + { + $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -116,50 +116,50 @@ if ($action == 'setfixednotif' && $user->admin) { $db->begin(); - if (!$error && is_array($_POST)) - { - $reg = array(); - foreach ($_POST as $key => $val) - { - if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; + if (!$error && is_array($_POST)) + { + $reg = array(); + foreach ($_POST as $key => $val) + { + if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; - $newval = ''; - $newkey = ''; + $newval = ''; + $newkey = ''; - $shortkey = preg_replace('/_key$/', '', $key); - //print $shortkey.'
'; + $shortkey = preg_replace('/_key$/', '', $key); + //print $shortkey.'
'; - if (preg_match('/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) - { + if (preg_match('/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) + { dolibarr_del_const($db, 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.$reg[2], $conf->entity); $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); $newval = GETPOST($shortkey.'_key'); //print $newkey.' - '.$newval.'
'; - } elseif (preg_match('/^NOTIF_(.*)_new_key/', $key, $reg)) - { - // Add a new entry - $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); - $newval = GETPOST($shortkey.'_key'); - } + } elseif (preg_match('/^NOTIF_(.*)_new_key/', $key, $reg)) + { + // Add a new entry + $newkey = 'NOTIFICATION_FIXEDEMAIL_'.$reg[1].'_THRESHOLD_HIGHER_'.((int) GETPOST($shortkey.'_amount')); + $newval = GETPOST($shortkey.'_key'); + } - if ($newkey && $newval) - { + if ($newkey && $newval) + { $result = dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity); - } - } - } + } + } + } if (!$error) - { - $db->commit(); + { + $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -318,66 +318,66 @@ print "\n"; foreach ($listofnotifiedevents as $notifiedevent) { - $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; + $label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; - $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); + $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); // Special cases - if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); - elseif ($notifiedevent['elementtype'] == 'propal') $elementLabel = $langs->trans('Proposal'); - elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill'); - elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order'); + if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); + elseif ($notifiedevent['elementtype'] == 'propal') $elementLabel = $langs->trans('Proposal'); + elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill'); + elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order'); elseif ($notifiedevent['elementtype'] == 'ficheinter') $elementLabel = $langs->trans('Intervention'); elseif ($notifiedevent['elementtype'] == 'shipping') $elementLabel = $langs->trans('Shipping'); elseif ($notifiedevent['elementtype'] == 'expensereport') $elementLabel = $langs->trans('ExpenseReport'); - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + } + // New entry input fields + $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. + print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; } print '
'.$elementLabel.''.$notifiedevent['code'].''.$label.''; - // Notification with threshold - foreach ($conf->global as $key => $val) - { + print '
'.$elementLabel.''.$notifiedevent['code'].''.$label.''; + // Notification with threshold + foreach ($conf->global as $key => $val) + { if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; - $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; - $value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param; + $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; + $value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param; - $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. - $arrayemail = explode(',', $value); + $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. + $arrayemail = explode(',', $value); $showwarning = 0; foreach ($arrayemail as $keydet => $valuedet) { $valuedet = trim($valuedet); if (!empty($valuedet) && !isValidEmail($valuedet, 1)) $showwarning++; } - if ((!empty($conf->global->$param)) && $showwarning) $s .= ' '.img_warning($langs->trans("ErrorBadEMail")); - print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); + if ((!empty($conf->global->$param)) && $showwarning) $s .= ' '.img_warning($langs->trans("ErrorBadEMail")); + print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); print '
'; - } - // New entry input fields - $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. - print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); - print '
'; - // Notification with threshold - foreach ($conf->global as $key => $val) - { + print ''; + // Notification with threshold + foreach ($conf->global as $key => $val) + { if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; - print $langs->trans("AmountHT").' >= '; + print $langs->trans("AmountHT").' >= '; print '
'; - } - // New entry input fields + } + // New entry input fields print $langs->trans("AmountHT").' >= '; print '
'; + print ''; // TODO Add link to show message content - print '
'; diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 8b0e9516abd..a71e09fad56 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -38,7 +38,7 @@ $langs->loadLangs(array('admin', 'oauth')); // Security check if (!$user->admin) - accessforbidden(); + accessforbidden(); $action = GETPOST('action', 'aZ09'); @@ -49,23 +49,23 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'update') { - $error = 0; + $error = 0; - foreach ($list as $constname) { - $constvalue = GETPOST($constname[1], 'alpha'); - if (!dolibarr_set_const($db, $constname[1], $constvalue, 'chaine', 0, '', $conf->entity)) - $error++; - $constvalue = GETPOST($constname[2], 'alpha'); - if (!dolibarr_set_const($db, $constname[2], $constvalue, 'chaine', 0, '', $conf->entity)) - $error++; - } + foreach ($list as $constname) { + $constvalue = GETPOST($constname[1], 'alpha'); + if (!dolibarr_set_const($db, $constname[1], $constvalue, 'chaine', 0, '', $conf->entity)) + $error++; + $constvalue = GETPOST($constname[2], 'alpha'); + if (!dolibarr_set_const($db, $constname[2], $constvalue, 'chaine', 0, '', $conf->entity)) + $error++; + } - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* @@ -85,7 +85,7 @@ print ''; $head = oauthadmin_prepare_head(); -dol_fiche_head($head, 'services', '', -1, 'technic'); +print dol_get_fiche_head($head, 'services', '', -1, 'technic'); print ''.$langs->trans("ListOfSupportedOauthProviders").'

'; @@ -97,51 +97,51 @@ $i = 0; // $list is defined into oauth.lib.php foreach ($list as $key) { - $supported = 0; - if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; - if (!$supported) continue; // show only supported + $supported = 0; + if (in_array($key[0], array_keys($supportedoauth2array))) $supported = 1; + if (!$supported) continue; // show only supported - $i++; + $i++; - print ''; - // Api Name - $label = $langs->trans($key[0]); - print ''.$label.''; - print ''; - if (!empty($key[3])) print $langs->trans($key[3]); - print ''; - print ''; + print ''; + // Api Name + $label = $langs->trans($key[0]); + print ''.$label.''; + print ''; + if (!empty($key[3])) print $langs->trans($key[3]); + print ''; + print ''; - if ($supported) - { - $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; - print ''; - print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; - print ''; - print ''; - } else { - print ''; - print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; - print ''.$langs->trans("FeatureNotYetSupported").''; - print ''; - } + if ($supported) + { + $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; + print ''; + print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print ''; + print ''; + } else { + print ''; + print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print ''.$langs->trans("FeatureNotYetSupported").''; + print ''; + } - // Api Id - print ''; - print ''; - print ''; - print ''; + // Api Id + print ''; + print ''; + print ''; + print ''; - // Api Secret - print ''; - print ''; - print ''; - print ''; + // Api Secret + print ''; + print ''; + print ''; + print ''; } print ''."\n"; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 2c8f2070724..4fb0bbb7452 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -123,7 +123,7 @@ print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); $head = oauthadmin_prepare_head(); -dol_fiche_head($head, 'tokengeneration', '', -1, 'technic'); +print dol_get_fiche_head($head, 'tokengeneration', '', -1, 'technic'); if (GETPOST('error')) { setEventMessages(GETPOST('error'), null, 'errors'); @@ -156,7 +156,7 @@ if ($mode == 'setup' && $user->admin) // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service). // We pass this param list in to 'state' because we need it before and after the redirect. $shortscope = 'userinfo_email,userinfo_profile,cloud_print'; - if (!empty($conf->global->OAUTH_GSUITE)){ + if (!empty($conf->global->OAUTH_GSUITE)) { $shortscope .= ',admin_directory_user'; } //$scope.=',gmail_full'; @@ -402,7 +402,7 @@ if ($mode == 'userconf' && $user->admin) print ''; } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/openinghours.php b/htdocs/admin/openinghours.php index d4886bb2a57..7cd803d5e69 100644 --- a/htdocs/admin/openinghours.php +++ b/htdocs/admin/openinghours.php @@ -75,7 +75,7 @@ print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup'); $head = company_admin_prepare_head(); -dol_fiche_head($head, 'openinghours', $langs->trans("Company"), -1, 'company'); +print dol_get_fiche_head($head, 'openinghours', $langs->trans("Company"), -1, 'company'); print ''.$langs->trans("OpeningHoursDesc")."
\n"; print "
\n"; @@ -97,37 +97,37 @@ if (empty($action) || $action == 'edit' || $action == 'updateedit') print ''; print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'>'."\n"; - print ''; - print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Wednesday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Wednesday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Thursday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Thursday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Friday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Friday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Saturday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Saturday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Sunday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Sunday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; + print ''; print '
'; print ''; diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index 1b2bb0c0cd0..5d5573d4579 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -73,19 +73,19 @@ print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); $head = order_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Orders"), -1, 'order'); +print dol_get_fiche_head($head, 'attributes', $langs->trans("Orders"), -1, 'order'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -98,9 +98,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -110,10 +110,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index 1f645241646..2f7462a3cf0 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -74,19 +74,19 @@ print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); $head = order_admin_prepare_head(); -dol_fiche_head($head, 'attributeslines', $langs->trans("Orders"), -1, 'order'); +print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Orders"), -1, 'order'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -111,10 +111,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 92b5c9511d5..d92704c211b 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -47,23 +47,23 @@ if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_pay if ($action == 'updateMask') { - $maskconstpayment = GETPOST('maskconstpayment', 'alpha'); - $maskpayment = GETPOST('maskpayment', 'alpha'); - if ($maskconstpayment) $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); + $maskconstpayment = GETPOST('maskconstpayment', 'alpha'); + $maskpayment = GETPOST('maskpayment', 'alpha'); + if ($maskconstpayment) $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } if ($action == 'setmod') { - dolibarr_set_const($db, "PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); } if ($action == 'setparams') @@ -72,8 +72,8 @@ if ($action == 'setparams') $res = dolibarr_set_const($db, "FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS", $freetext, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; - $res = dolibarr_set_const($db, "PAYMENTS_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + $res = dolibarr_set_const($db, "PAYMENTS_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; if ($error) { @@ -81,7 +81,7 @@ if ($action == 'setparams') } if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } } @@ -101,7 +101,7 @@ $linkback = 'trans("Invoices"), -1, 'invoice'); +print dol_get_fiche_head($head, 'payment', $langs->trans("Invoices"), -1, 'invoice'); /* * Numbering module @@ -123,105 +123,105 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/payment/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) - { - $filebis = $file; - $classname = preg_replace('/\.php$/', '', $file); - // For compatibility - if (!is_file($dir.$filebis)) - { - $filebis = $file."/".$file.".modules.php"; - $classname = "mod_payment_".$file; - } - // Check if there is a filter on country - preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + $dir = dol_buildpath($reldir."core/modules/payment/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_payment_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; - $classname = preg_replace('/\-.*$/', '', $classname); - if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') - { - // Charging the numbering class - require_once $dir.$filebis; + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; - $module = new $classname($db); + $module = new $classname($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; + // 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()) - { - $var = !$var; - print ''; - echo preg_replace('/\-.*$/', '', preg_replace('/mod_payment_/', '', preg_replace('/\.php$/', '', $file))); - print "\n"; + if ($module->isEnabled()) + { + $var = !$var; + print ''; + echo preg_replace('/\-.*$/', '', preg_replace('/mod_payment_/', '', preg_replace('/\.php$/', '', $file))); + print "\n"; - print $module->info(); + print $module->info(); - print ''; + print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - //print "> ".$conf->global->PAYMENT_ADDON." - ".$file; - if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file) - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print '
'.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + print ''; + //print "> ".$conf->global->PAYMENT_ADDON." - ".$file; + if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file) + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - $payment = new Paiement($db); - $payment->initAsSpecimen(); + $payment = new Paiement($db); + $payment->initAsSpecimen(); - // Example - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $payment); - 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).'
'; - } - } + // Example + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $payment); + 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 $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors - { - if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); - } + if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors + { + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + } - print ''; + print ''; - print "\n"; - } - } - } - } - closedir($handle); - } - } + print "\n"; + } + } + } + } + closedir($handle); + } + } } print ''; @@ -262,7 +262,7 @@ print "\n"; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print '
'; diff --git a/htdocs/admin/paymentbybanktransfer.php b/htdocs/admin/paymentbybanktransfer.php index 718e64e6446..6a419d39e53 100644 --- a/htdocs/admin/paymentbybanktransfer.php +++ b/htdocs/admin/paymentbybanktransfer.php @@ -361,7 +361,7 @@ foreach ($dirmodels as $reldir) */ -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 363edca6c80..4008fad141d 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -46,42 +46,40 @@ $cancel = GETPOST('cancel', 'alpha'); */ if ($cancel) { - $action = ''; + $action = ''; } if ($action == 'update') { - dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_FORMAT", GETPOST("MAIN_PDF_FORMAT"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", $_POST["MAIN_PDF_MARGIN_LEFT"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", $_POST["MAIN_PDF_MARGIN_RIGHT"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", $_POST["MAIN_PDF_MARGIN_TOP"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", $_POST["MAIN_PDF_MARGIN_BOTTOM"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", GETPOST("MAIN_PDF_MARGIN_TOP"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", GETPOST("MAIN_PDF_MARGIN_BOTTOM"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", GETPOST("MAIN_PROFID1_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", GETPOST("MAIN_PROFID2_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", GETPOST("MAIN_PROFID3_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", GETPOST("MAIN_PROFID4_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", GETPOST("MAIN_PROFID5_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", GETPOST("MAIN_PROFID6_IN_ADDRESS", "nohtml"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", GETPOST("MAIN_PROFID1_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", GETPOST("MAIN_PROFID2_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", GETPOST("MAIN_PROFID3_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", GETPOST("MAIN_PROFID4_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", GETPOST("MAIN_PROFID5_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", GETPOST("MAIN_PROFID6_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", $_POST["MAIN_TVAINTRA_NOT_IN_ADDRESS"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DESC"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_REF"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_DOCUMENTS_LOGO_HEIGHT", GETPOST("MAIN_DOCUMENTS_LOGO_HEIGHT", 'int'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", $_POST["MAIN_INVERT_SENDER_RECIPIENT"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", GETPOST("MAIN_INVERT_SENDER_RECIPIENT"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", GETPOST("MAIN_PDF_USE_ISO_LOCATION"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_SECOND_TAX"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_THIRD_TAX"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["MAIN_PDF_MAIN_HIDE_THIRD_TAX"], 'chaine', 0, '', $conf->entity); - - dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index cd9d290b828..4905f4f2497 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -44,18 +44,18 @@ $entity = $conf->entity; if ($action == 'add') { - $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1"; - $sql .= " WHERE id = ".GETPOST("pid", 'int'); - $sql .= " AND entity = ".$conf->entity; - $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1"; + $sql .= " WHERE id = ".GETPOST("pid", 'int'); + $sql .= " AND entity = ".$conf->entity; + $db->query($sql); } if ($action == 'remove') { - $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0"; - $sql .= " WHERE id = ".GETPOST('pid', 'int'); - $sql .= " AND entity = ".$conf->entity; - $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0"; + $sql .= " WHERE id = ".GETPOST('pid', 'int'); + $sql .= " AND entity = ".$conf->entity; + $db->query($sql); } @@ -116,7 +116,7 @@ $db->commit(); $head = security_prepare_head(); -dol_fiche_head($head, 'default', '', -1); +print dol_get_fiche_head($head, 'default', '', -1); // Show warning about external users @@ -145,81 +145,81 @@ $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - $oldmod = ''; + $num = $db->num_rows($result); + $i = 0; + $oldmod = ''; - while ($i < $num) - { - $obj = $db->fetch_object($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); - // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it - if (empty($modules[$obj->module])) - { - $i++; - continue; - } + // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it + if (empty($modules[$obj->module])) + { + $i++; + continue; + } - // Save field module_position in database if value is still zero - if (empty($obj->module_position)) - { - if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) - { - // TODO Define familyposition - $family = $modules[$obj->module]->family_position; - $familyposition = 0; - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.","; - $sqlupdate .= " family_position = ".$familyposition; - $sqlupdate .= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; - $db->query($sqlupdate); - } - } + // Save field module_position in database if value is still zero + if (empty($obj->module_position)) + { + if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) + { + // TODO Define familyposition + $family = $modules[$obj->module]->family_position; + $familyposition = 0; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.","; + $sqlupdate .= " family_position = ".$familyposition; + $sqlupdate .= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; + $db->query($sqlupdate); + } + } - // Check if permission we found is inside a module definition. If not, we discard it. - $found = false; - foreach ($modules[$obj->module]->rights as $key => $val) - { - if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) - { - $found = true; - break; - } - } + // Check if permission we found is inside a module definition. If not, we discard it. + $found = false; + foreach ($modules[$obj->module]->rights as $key => $val) + { + if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) + { + $found = true; + break; + } + } if (!$found) { $i++; continue; } - // Break found, it's a new module to catch + // Break found, it's a new module to catch if (isset($obj->module) && ($oldmod <> $obj->module)) - { - $oldmod = $obj->module; + { + $oldmod = $obj->module; - // Break detected, we get objMod - $objMod = $modules[$obj->module]; - $picto = ($objMod->picto ? $objMod->picto : 'generic'); + // Break detected, we get objMod + $objMod = $modules[$obj->module]; + $picto = ($objMod->picto ? $objMod->picto : 'generic'); - // Show break line - print ''; - print ''; - print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); - print ''; - print ''; - print ' '; - print ' '; - print ' '; - // Permission id - if ($user->admin) print ''; - print ''."\n"; - } + // Show break line + print ''; + print ''; + print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); + print ''; + print ''; + print ' '; + print ' '; + print ' '; + // Permission id + if ($user->admin) print ''; + print ''."\n"; + } - $perm_libelle = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $obj->label)); + $perm_libelle = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $obj->label)); - print ''; + print ''; - // Picto and label of module - print ''; + // Picto and label of module + print ''; print ''; // Tick @@ -247,20 +247,20 @@ if ($result) } // Permission and tick - print ''.$perm_libelle.''; + print ''.$perm_libelle.''; - // Permission id - if ($user->admin) print ''.$obj->id.''; + // Permission id + if ($user->admin) print ''.$obj->id.''; - print ''."\n"; + print ''."\n"; - $i++; - } + $i++; + } } else dol_print_error($db); print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 50d01924364..c16b5c30c47 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -368,7 +368,7 @@ foreach ($dirmodels as $reldir) */ -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 3b574956cd0..e75a06a78ad 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -76,7 +76,7 @@ if ($action == 'updateMask') { $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php"); + $file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php"); if (file_exists($file)) { $filefound = 1; @@ -154,25 +154,25 @@ if ($action == 'updateMask') { setEventMessages($langs->trans("Error"), null, 'errors'); } } elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set') { // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->PROPALE_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity); + if ($conf->global->PROPALE_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity); } } elseif ($action == 'setdoc') { - if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { + if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { $conf->global->PROPALE_ADDON_PDF = $value; } @@ -206,7 +206,7 @@ print load_fiche_titre($langs->trans("PropalSetup"), $linkback, 'title_setup'); $head = propal_admin_prepare_head(); -dol_fiche_head($head, 'general', $langs->trans("Proposals"), -1, 'propal'); +print dol_get_fiche_head($head, 'general', $langs->trans("Proposals"), -1, 'propal'); /* * Module numerotation @@ -253,13 +253,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->PROPALE_ADDON == "$file") @@ -280,16 +280,16 @@ foreach ($dirmodels as $reldir) $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $propal->type = 0; $nextval = $module->getNextValue($mysoc, $propal); - 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).'
'; - } - } + 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 $form->textwithpicto('', $htmltooltip, 1, 0); @@ -348,83 +348,83 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/propale".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/propale".$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); + 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); + 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); + 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; + $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) - { - $var = !$var; - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + $var = !$var; + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ""; - if ($conf->global->PROPALE_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ""; + if ($conf->global->PROPALE_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // 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; + // 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("FeaturesSupported").':'; $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); @@ -434,28 +434,28 @@ foreach ($dirmodels as $reldir) $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -623,11 +623,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->tra $variablename = 'PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index 795cbec5ede..71bd50ef5ce 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -94,7 +94,7 @@ print ''; $head = security_prepare_head(); -dol_fiche_head($head, 'proxy', '', -1); +print dol_get_fiche_head($head, 'proxy', '', -1); if ($conf->use_javascript_ajax) @@ -197,7 +197,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print ''; diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 350d4a3dc15..3f66d04ca01 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -43,7 +43,7 @@ $printername = GETPOST('printername', 'alpha'); $printerid = GETPOST('printerid', 'int'); $parameter = GETPOST('parameter', 'alpha'); -$template = GETPOST('template', 'alpha'); +$template = GETPOST('template', 'nohtml'); $templatename = GETPOST('templatename', 'alpha'); $templateid = GETPOST('templateid', 'int'); @@ -282,7 +282,7 @@ if ($mode == 'config' && $user->admin) { } - dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); + print dol_get_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); print ''.$langs->trans("ReceiptPrinterDesc")."

\n"; @@ -354,7 +354,7 @@ if ($mode == 'config' && $user->admin) { print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print ''; @@ -387,7 +387,7 @@ if ($mode == 'config' && $user->admin) { // mode = template if ($mode == 'template' && $user->admin) { - dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); + print dol_get_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic'); print '
'; print ''; @@ -460,7 +460,7 @@ if ($mode == 'template' && $user->admin) { } print '
'; - dol_fiche_end(); + print dol_get_fiche_end(); print '
'; @@ -473,7 +473,7 @@ if ($mode == 'template' && $user->admin) { $langs->loadLangs(array("bills", "companies")); foreach ($printer->tags as $key => $val) { print ''; - print '<'.$key.'>'.$langs->trans($val).''; + print '{'.$key.'}'.$langs->trans($val).''; print ''; } print ''; diff --git a/htdocs/admin/reception_extrafields.php b/htdocs/admin/reception_extrafields.php index d9babd5d95b..605b8cf465e 100644 --- a/htdocs/admin/reception_extrafields.php +++ b/htdocs/admin/reception_extrafields.php @@ -79,11 +79,11 @@ print "
\n"; $head = reception_admin_prepare_head(); -dol_fiche_head($head, 'attributes_reception', $langs->trans("Receptions"), -1, 'sending'); +print dol_get_fiche_head($head, 'attributes_reception', $langs->trans("Receptions"), -1, 'sending'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index f84d9a3a7f9..6c5d9916225 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -189,7 +189,7 @@ print load_fiche_titre($langs->trans("ReceptionsSetup"), $linkback, 'title_setup print '
'; $head = reception_admin_prepare_head(); -dol_fiche_head($head, 'reception', $langs->trans("Receptions"), -1, 'sending'); +print dol_get_fiche_head($head, 'reception', $langs->trans("Receptions"), -1, 'sending'); // Reception numbering model diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index b57e41ddfd4..ecf72df9b37 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -70,7 +70,7 @@ print load_fiche_titre($langs->trans('ResourceSetup'), $linkback, 'title_setup') $head = resource_admin_prepare_head(); -dol_fiche_head($head, 'general', $langs->trans("ResourceSingular"), -1, 'action'); +print dol_get_fiche_head($head, 'general', $langs->trans("ResourceSingular"), -1, 'action'); print '
'; print ''; @@ -142,7 +142,7 @@ print '
'; //RESOURCE_HIDE_ADD_CONTACT_USER //RESOURCE_HIDE_ADD_CONTACT_THIPARTY -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index 61b0bf900df..219643e8303 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -73,19 +73,19 @@ print "
\n"; $head = resource_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("ResourceSingular"), -1, 'action'); +print dol_get_fiche_head($head, 'attributes', $langs->trans("ResourceSingular"), -1, 'action'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -98,9 +98,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -110,10 +110,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index f25cdf25958..d9eae8f064e 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -53,51 +53,51 @@ if ($action == 'setgeneraterule') if ($action == 'activate_encrypt') { - $error = 0; + $error = 0; $db->begin(); - dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); - $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; - $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value + $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value - $resql = $db->query($sql); - if ($resql) - { - $numrows = $db->num_rows($resql); - $i = 0; - while ($i < $numrows) - { - $obj = $db->fetch_object($resql); - if (dol_hash($obj->pass)) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL"; - $sql .= " WHERE rowid=".$obj->rowid; - //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + $i = 0; + while ($i < $numrows) + { + $obj = $db->fetch_object($resql); + if (dol_hash($obj->pass)) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL"; + $sql .= " WHERE rowid=".$obj->rowid; + //print $sql; - $resql2 = $db->query($sql); - if (!$resql2) - { - dol_print_error($db); - $error++; - break; - } + $resql2 = $db->query($sql); + if (!$resql2) + { + dol_print_error($db); + $error++; + break; + } - $i++; - } - } - } else dol_print_error($db); + $i++; + } + } + } else dol_print_error($db); //print $error." ".$sql; - //exit; - if (!$error) + //exit; + if (!$error) { $db->commit(); header("Location: security.php"); - exit; + exit; } else { $db->rollback(); dol_print_error($db, ''); @@ -109,9 +109,9 @@ if ($action == 'activate_encrypt') if ($allow_disable_encryption) { dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity); - } + } header("Location: security.php"); - exit; + exit; } if ($action == 'activate_encryptdbpassconf') @@ -119,9 +119,9 @@ if ($action == 'activate_encryptdbpassconf') $result = encodedecode_dbpassconf(1); if ($result > 0) { - sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. + sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. - // database value not required + // database value not required //dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1"); header("Location: security.php"); exit; @@ -133,7 +133,7 @@ if ($action == 'activate_encryptdbpassconf') $result = encodedecode_dbpassconf(0); if ($result > 0) { - sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. + sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. // database value not required //dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity); @@ -158,24 +158,24 @@ if ($action == 'activate_MAIN_SECURITY_DISABLEFORGETPASSLINK') if ($action == 'updatepattern') { - $pattern = GETPOST("pattern", "alpha"); - $explodePattern = explode(';', $pattern); + $pattern = GETPOST("pattern", "alpha"); + $explodePattern = explode(';', $pattern); - $patternInError = false; - if ($explodePattern[0] < 1 || $explodePattern[4] < 0) { - $patternInError = true; - } + $patternInError = false; + if ($explodePattern[0] < 1 || $explodePattern[4] < 0) { + $patternInError = true; + } - if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) { - $patternInError = true; - } + if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) { + $patternInError = true; + } - if (!$patternInError) { - dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - header("Location: security.php"); - exit; - } + if (!$patternInError) { + dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + header("Location: security.php"); + exit; + } } @@ -197,7 +197,7 @@ print "
\n"; $head = security_prepare_head(); -dol_fiche_head($head, 'passwords', '', -1); +print dol_get_fiche_head($head, 'passwords', '', -1); // Choix du gestionnaire du generateur de mot de passe @@ -214,20 +214,20 @@ $handle = opendir($dir); $i = 1; if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) - { - // Charging the numbering class - $classname = $reg[1]; - require_once $dir.'/'.$file; + while (($file = readdir($handle)) !== false) + { + if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) + { + // Charging the numbering class + $classname = $reg[1]; + require_once $dir.'/'.$file; - $obj = new $classname($db, $conf, $langs, $user); - $arrayhandler[$obj->id] = $obj; - $i++; - } - } - closedir($handle); + $obj = new $classname($db, $conf, $langs, $user); + $arrayhandler[$obj->id] = $obj; + $i++; + } + } + closedir($handle); } asort($arrayhandler); @@ -241,33 +241,33 @@ print ''; foreach ($arrayhandler as $key => $module) { // 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->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) { - print ''; - print ucfirst($key); - print "\n"; - print $module->getDescription().'
'; - print $langs->trans("MinLength").': '.$module->length; - print ''; + print ''; + print ucfirst($key); + print "\n"; + print $module->getDescription().'
'; + print $langs->trans("MinLength").': '.$module->length; + print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - if ($conf->global->USER_PASSWORD_GENERATED == $key) - { - print img_picto('', 'tick'); - } else { - print ''.$langs->trans("Activate").''; - } - print "\n"; + print ''; + if ($conf->global->USER_PASSWORD_GENERATED == $key) + { + print img_picto('', 'tick'); + } else { + print ''.$langs->trans("Activate").''; + } + print "\n"; } } print ''; @@ -493,14 +493,14 @@ print '
'; if (GETPOST('info', 'int') > 0) { - if (function_exists('password_hash')) - { - print $langs->trans("Note: The function password_hash exists on your PHP")."
\n"; - } else { - print $langs->trans("Note: The function password_hash does not exists on your PHP")."
\n"; - } - print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."
\n"; - print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT."
\n"; + if (function_exists('password_hash')) + { + print $langs->trans("Note: The function password_hash exists on your PHP")."
\n"; + } else { + print $langs->trans("Note: The function password_hash does not exists on your PHP")."
\n"; + } + print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."
\n"; + print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT."
\n"; } print '
'; diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index a2e97b45869..2669e741c6e 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -100,7 +100,7 @@ print ''; $head = security_prepare_head(); -dol_fiche_head($head, 'file', '', -1); +print dol_get_fiche_head($head, 'file', '', -1); // Upload options @@ -153,7 +153,7 @@ if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); } } -print ''; +print ''; if (defined('MAIN_ANTIVIRUS_COMMAND')) { print '
'.$langs->trans("ValueIsForcedBySystem").''; } @@ -177,7 +177,7 @@ print ''; print ''; print '
'; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index 4eb6af14843..5f063dbe2a2 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -93,7 +93,7 @@ print ''; $head = security_prepare_head(); -dol_fiche_head($head, 'misc', '', -1); +print dol_get_fiche_head($head, 'misc', '', -1); // Other Options @@ -121,8 +121,8 @@ if (function_exists("imagecreatefrompng")) } } } else { - $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); - print $desc; + $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); + print $desc; } print ''; @@ -184,7 +184,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index e09304a4921..e34d2ab9b7a 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -86,32 +86,32 @@ if ($action == 'send' && !$_POST['cancel']) if (!empty($formsms->error)) { setEventMessages($formsms->error, $formsms->errors, 'errors'); - $action = 'test'; - $error++; + $action = 'test'; + $error++; + } + if (empty($body)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); + $action = 'test'; + $error++; } - if (empty($body)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); - $action = 'test'; - $error++; - } if (empty($smsfrom) || !str_replace('+', '', $smsfrom)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsFrom")), null, 'errors'); - $action = 'test'; + $action = 'test'; $error++; } if (empty($sendto) || !str_replace('+', '', $sendto)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsTo")), null, 'errors'); - $action = 'test'; + $action = 'test'; $error++; } if (!$error) { // Make substitutions into message - complete_substitutions_array($substitutionarrayfortest, $langs); - $body = make_substitutions($body, $substitutionarrayfortest); + complete_substitutions_array($substitutionarrayfortest, $langs); + $body = make_substitutions($body, $substitutionarrayfortest); require_once DOL_DOCUMENT_ROOT.'/core/class/CSMSFile.class.php'; @@ -180,7 +180,7 @@ if ($action == 'edit') print ''.$langs->trans("MAIN_SMS_SENDMODE").''; if (count($listofmethods)) print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1); else print ''.$langs->trans("None").''; - print ''; + print ''; // From print ''.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).''; @@ -259,9 +259,9 @@ if ($action == 'edit') if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) { - print ''.$langs->trans("DoTestSend").''; + print ''.$langs->trans("DoTestSend").''; } else { - print ''.$langs->trans("DoTestSend").''; + print ''.$langs->trans("DoTestSend").''; } print '
'; @@ -298,9 +298,9 @@ if ($action == 'edit') // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php'; $formsms = new FormSms($db); - $formsms->fromtype = 'user'; - $formsms->fromid = $user->id; - $formsms->fromsms = (GETPOSTISSET('fromsms') ? $_POST['fromsms'] : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile)); + $formsms->fromtype = 'user'; + $formsms->fromid = $user->id; + $formsms->fromsms = (GETPOSTISSET('fromsms') ? $_POST['fromsms'] : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile)); $formsms->withfromreadonly = 0; $formsms->withsubstit = 0; $formsms->withfrom = 1; diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php index b848dccd998..0ab3a91432b 100644 --- a/htdocs/admin/socialnetworks.php +++ b/htdocs/admin/socialnetworks.php @@ -43,26 +43,26 @@ $action = GETPOST('action', 'aZ09'); */ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } @@ -89,26 +89,26 @@ $h++; print '
'; -dol_fiche_head($head, 'setup', '', 0, 'user'); +print dol_get_fiche_head($head, 'setup', '', 0, 'user'); print '
'; $arrayofsocialnetworks = array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook', 'linkedin'=>'LinkedIn'); foreach ($arrayofsocialnetworks as $snkey => $snlabel) { - $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); - if ($conf->use_javascript_ajax) { - $link = ajax_constantonoff($consttocheck); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck); - } + $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); + if ($conf->use_javascript_ajax) { + $link = ajax_constantonoff($consttocheck); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck); + } - print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; + print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; } -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php index ca44caac258..2fa111578a9 100644 --- a/htdocs/admin/spip.php +++ b/htdocs/admin/spip.php @@ -55,48 +55,48 @@ if ($action == 'update' || $action == 'add') $consttypearray = GETPOST("consttype", 'array'); $constnotearray = GETPOST("constnote", 'array'); - // Action mise a jour ou ajout d'une constante - if ($action == 'update' || $action == 'add') - { - foreach ($constnamearray as $key => $val) - { - $constname = dol_escape_htmltag($constnamearray[$key]); - $constvalue = dol_escape_htmltag($constvaluearray[$key]); - $consttype = dol_escape_htmltag($consttypearray[$key]); - $constnote = dol_escape_htmltag($constnotearray[$key]); + // Action mise a jour ou ajout d'une constante + if ($action == 'update' || $action == 'add') + { + foreach ($constnamearray as $key => $val) + { + $constname = dol_escape_htmltag($constnamearray[$key]); + $constvalue = dol_escape_htmltag($constvaluearray[$key]); + $consttype = dol_escape_htmltag($consttypearray[$key]); + $constnote = dol_escape_htmltag($constnotearray[$key]); - $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); + $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); - if (!$res > 0) $error++; - } + if (!$res > 0) $error++; + } - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } + } } // Action activation d'un sous module du module adherent if ($action == 'set') { - $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); - if ($result < 0) - { - dol_print_error($db); - } + $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); + if ($result < 0) + { + dol_print_error($db); + } } // Action desactivation d'un sous module du module adherent if ($action == 'unset') { - $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); - if ($result < 0) - { - dol_print_error($db); - } + $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); + if ($result < 0) + { + dol_print_error($db); + } } @@ -126,41 +126,41 @@ if (!empty($conf->global->ADHERENT_USE_SPIP)) print ''; print ''; - dol_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user'); + print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user'); - //$link=img_picto($langs->trans("Active"),'tick').' '; - $link = ''; - //$link.=$langs->trans("Disable"); - $link .= img_picto($langs->trans("Activated"), 'switch_on'); - $link .= ''; - // Edition des varibales globales - $constantes = array( - 'ADHERENT_SPIP_SERVEUR', - 'ADHERENT_SPIP_DB', - 'ADHERENT_SPIP_USER', - 'ADHERENT_SPIP_PASS' + //$link=img_picto($langs->trans("Active"),'tick').' '; + $link = ''; + //$link.=$langs->trans("Disable"); + $link .= img_picto($langs->trans("Activated"), 'switch_on'); + $link .= ''; + // Edition des varibales globales + $constantes = array( + 'ADHERENT_SPIP_SERVEUR', + 'ADHERENT_SPIP_DB', + 'ADHERENT_SPIP_USER', + 'ADHERENT_SPIP_PASS' ); - print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); + print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); print '
'; form_constantes($constantes, 2); - dol_fiche_end(); + print dol_get_fiche_end(); - print '
'; + print '
'; - print ''; + print ''; } else { - dol_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user'); + print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user'); - $link = ''; - //$link.=$langs->trans("Activate"); - $link .= img_picto($langs->trans("Disabled"), 'switch_off'); - $link .= ''; - print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); + $link = ''; + //$link.=$langs->trans("Activate"); + $link .= img_picto($langs->trans("Disabled"), 'switch_off'); + $link .= ''; + print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 20b1252456e..134aeb663b4 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -93,7 +93,7 @@ if ($action == 'warehouse') { $value = GETPOST('default_warehouse', 'alpha'); $res = dolibarr_set_const($db, "MAIN_DEFAULT_WAREHOUSE", $value, 'chaine', 0, '', $conf->entity); - if ($value == -1 || empty($value) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)){ + if ($value == -1 || empty($value) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) { $res = dolibarr_del_const($db, "MAIN_DEFAULT_WAREHOUSE", $conf->entity); } if (!$res > 0) $error++; @@ -184,7 +184,7 @@ print load_fiche_titre($langs->trans("StockSetup"), $linkback, 'title_setup'); $head = stock_admin_prepare_head(); -dol_fiche_head($head, 'general', $langs->trans("StockSetup"), -1, 'stock'); +print dol_get_fiche_head($head, 'general', $langs->trans("StockSetup"), -1, 'stock'); $form = new Form($db); $formproduct = new FormProduct($db); @@ -483,13 +483,15 @@ if ($virtualdiffersfromphysical) print ''."\n"; print ''; - print ''.$langs->trans("UseVirtualStockByDefault").''; + print ''; + print $form->textwithpicto($langs->trans("UseRealStockByDefault"), $langs->trans("ReplenishmentCalculation")); + print ''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK'); + print ajax_constantonoff('STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK); + print $form->selectarray("STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT", $arrval, $conf->global->STOCK_USE_REAL_STOCK_BY_DEFAULT_FOR_REPLENISHMENT); } print "\n"; print "\n"; @@ -668,8 +670,8 @@ print load_fiche_titre($langs->trans("Other"), '', ''); print ''; print ''; -print "\n"; -print ''."\n"; +print "\n"; +print ''."\n"; print ''."\n"; print ''; @@ -684,7 +686,7 @@ print ''; print ''; print '\n"; print "\n"; -if (! empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { +if (!empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { print ''; print ''; print ''; + print ''; - // Show example of numbering model - print ''."\n"; + // Show example of numbering model + print ''."\n"; - print ''; + print ''; - $invoice = new FactureFournisseur($db); - $invoice->initAsSpecimen(); + $invoice = new FactureFournisseur($db); + $invoice->initAsSpecimen(); - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $invoice); - 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).'
'; - } - } + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $invoice); + 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 ''; - print ''; - } - } - } - closedir($handle); - } - } + print ''; + } + } + } + closedir($handle); + } + } } print '
".$langs->trans("Other")."'.$langs->trans("Status").'".$langs->trans("Parameter")."'.$langs->trans("Value").'
'.$langs->trans("UserDefaultWarehouse").''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MAIN_DEFAULT_WAREHOUSE_USER', array(), null, 0, 0, 1); + print ajax_constantonoff('MAIN_DEFAULT_WAREHOUSE_USER', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("MAIN_DEFAULT_WAREHOUSE_USER", $arrval, $conf->global->MAIN_DEFAULT_WAREHOUSE_USER); @@ -692,7 +694,7 @@ if ($conf->use_javascript_ajax) { print "
'.$langs->trans("UserWarehouseAutoCreate").''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index c4f2e48ff4a..779f7ab472a 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -57,15 +57,15 @@ $specimenthirdparty->initAsSpecimen(); if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); - $maskinvoice = GETPOST('maskinvoice', 'alpha'); + $maskinvoice = GETPOST('maskinvoice', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha'); - if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); + if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { @@ -77,44 +77,44 @@ if ($action == 'updateMask') if ($action == 'specimen') // For invoices { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $facture = new FactureFournisseur($db); - $facture->initAsSpecimen(); - $facture->thirdparty = $specimenthirdparty; // Define who should has build the invoice (so the supplier) + $facture = new FactureFournisseur($db); + $facture->initAsSpecimen(); + $facture->thirdparty = $specimenthirdparty; // Define who should has build the invoice (so the supplier) - // 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/supplier_invoice/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // 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/supplier_invoice/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $facture); + $module = new $classname($db, $facture); - if ($module->write_file($facture, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($facture, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -126,52 +126,52 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'INVOICE_SUPPLIER_ADDON_PDF', $conf->entity); + if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'INVOICE_SUPPLIER_ADDON_PDF', $conf->entity); } } // Set default model elseif ($action == 'setdoc') { - if (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent - $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value; - } + if (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value; + } - // On active le modele - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - $ret = addDocumentModel($value, $type, $label, $scandir); - } + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } } elseif ($action == 'unsetdoc') { - dolibarr_del_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $conf->entity); + dolibarr_del_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $conf->entity); } if ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated - dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); } if ($action == 'addcat') { - $fourn = new Fournisseur($db); - $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); + $fourn = new Fournisseur($db); + $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); } if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT') { - $freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string + $freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string - $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { @@ -199,7 +199,7 @@ print "
"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'invoice', $langs->trans("Suppliers"), -1, 'company'); +print dol_get_fiche_head($head, 'invoice', $langs->trans("Suppliers"), -1, 'company'); // Supplier invoice numbering module @@ -221,79 +221,79 @@ foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/supplier_invoice"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 24) == 'mod_facture_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') - { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (substr($file, 0, 24) == 'mod_facture_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file) - 4); - require_once $dir.'/'.$file.'.php'; + require_once $dir.'/'.$file.'.php'; - $module = new $file; + $module = new $file; - if ($module->isEnabled()) - { - // 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()) + { + // 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; - print '
'.$module->nom."\n"; - print $module->info(); - print '
'.$module->nom."\n"; + print $module->info(); + print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print '
'; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; - if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER == "$file") - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER == "$file") + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print '

'; @@ -318,16 +318,16 @@ $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++; - } + $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); + dol_print_error($db); } print ''."\n"; @@ -347,94 +347,94 @@ foreach ($dirmodels as $reldir) $realpath = $reldir."core/modules/supplier_invoice/doc"; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); + if (is_dir($dir)) + { + $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $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, new FactureFournisseur($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new FactureFournisseur($db)); - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print '"; - } else { - print '"; - } + print ""; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $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("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - print ''; - print ''; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + print ''; + print ''; - print "\n"; - } - } + print "\n"; + } + } - closedir($handle); - } - } + closedir($handle); + } + } } print '
"; - print (empty($module->name) ? $name : $module->name); - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + print "
"; + print (empty($module->name) ? $name : $module->name); + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; - print "'."\n"; - //if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") - //{ - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - /*} + // Active + if (in_array($name, $def)) + { + print ''."\n"; + //if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") + //{ + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + /*} else { print img_picto($langs->trans("Enabled"),'switch_on'); }*/ - print "'."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; - if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") - { - //print img_picto($langs->trans("Default"),'on'); - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") + { + //print img_picto($langs->trans("Default"),'on'); + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print '

'; @@ -466,11 +466,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->tra $variablename = 'SUPPLIER_INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 9afa2bb2d1f..60c2c4da56e 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -58,12 +58,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); - $maskvalue = GETPOST('maskorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskvalue = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskvalue, 'chaine', 0, '', $conf->entity); + if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskvalue, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { @@ -73,44 +73,44 @@ if ($action == 'updateMask') } } elseif ($action == 'specimen') // For orders { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); - $commande->thirdparty = $specimenthirdparty; + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + $commande->thirdparty = $specimenthirdparty; - // 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/supplier_order/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // 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/supplier_order/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $commande); + $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($commande, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -122,7 +122,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_SUPPLIER_ADDON_PDF', $conf->entity); + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_SUPPLIER_ADDON_PDF', $conf->entity); } } @@ -144,64 +144,64 @@ elseif ($action == 'setdoc') } } elseif ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated - dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); } elseif ($action == 'addcat') { - $fourn = new Fournisseur($db); - $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); + $fourn = new Fournisseur($db); + $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); } elseif ($action == 'set_SUPPLIER_ORDER_OTHER') { - $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string + $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $doubleapproval = GETPOST('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED', 'alpha'); $doubleapproval = price2num($doubleapproval); - $res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - $res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval, 'chaine', 0, '', $conf->entity); + $res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); + $res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval, 'chaine', 0, '', $conf->entity); - // TODO We add/delete permission here until permission can have a condition on a global var - include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; - $newmodule = new modFournisseur($db); + // TODO We add/delete permission here until permission can have a condition on a global var + include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; + $newmodule = new modFournisseur($db); - if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) - { - // clear default rights array - $newmodule->rights = array(); - // add new right - $r = 0; - $newmodule->rights[$r][0] = 1190; - $newmodule->rights[$r][1] = $langs->trans("Permission1190"); - $newmodule->rights[$r][2] = 'w'; - $newmodule->rights[$r][3] = 0; - $newmodule->rights[$r][4] = 'commande'; - $newmodule->rights[$r][5] = 'approve2'; + if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) + { + // clear default rights array + $newmodule->rights = array(); + // add new right + $r = 0; + $newmodule->rights[$r][0] = 1190; + $newmodule->rights[$r][1] = $langs->trans("Permission1190"); + $newmodule->rights[$r][2] = 'w'; + $newmodule->rights[$r][3] = 0; + $newmodule->rights[$r][4] = 'commande'; + $newmodule->rights[$r][5] = 'approve2'; - // Insert - $newmodule->insert_permissions(1); - } else { - // Remove all rights with Permission1190 - $newmodule->delete_permissions(); + // Insert + $newmodule->insert_permissions(1); + } else { + // Remove all rights with Permission1190 + $newmodule->delete_permissions(); - // Add all right without Permission1190 - $newmodule->insert_permissions(1); - } + // Add all right without Permission1190 + $newmodule->insert_permissions(1); + } } // Activate ask for payment bank elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -222,7 +222,7 @@ print "
"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'order', $langs->trans("Suppliers"), -1, 'company'); +print dol_get_fiche_head($head, 'order', $langs->trans("Suppliers"), -1, 'company'); // Supplier order numbering module @@ -244,79 +244,79 @@ foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/supplier_order/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') - { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file) - 4); - require_once $dir.$file.'.php'; + require_once $dir.$file.'.php'; - $module = new $file; + $module = new $file; - if ($module->isEnabled()) - { - // 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()) + { + // 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; - print ''.$module->nom."\n"; - print $module->info(); - print ''; + print ''.$module->nom."\n"; + print $module->info(); + print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "$file") - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + print ''; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "$file") + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $commande); - 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).'
'; - } - } + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $commande); + 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 $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - print ''; - } - } - } - closedir($handle); - } - } + print ''; + } + } + } + closedir($handle); + } + } } print '
'; @@ -339,16 +339,16 @@ $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++; - } + $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); + dol_print_error($db); } print ''."\n"; @@ -368,86 +368,86 @@ foreach ($dirmodels as $reldir) $realpath = $reldir."core/modules/supplier_order/doc"; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $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, new CommandeFournisseur($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new CommandeFournisseur($db)); - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print '"; - } else { - print '"; - } + // Active + if (in_array($name, $def)) + { + print '"; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $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("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - print ''; - print ''; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + print ''; + print ''; - print "\n"; - } - } + print "\n"; + } + } - closedir($handle); - } - } + closedir($handle); + } + } } print '
"; - print (empty($module->name) ? $name : $module->name); - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print "
"; + print (empty($module->name) ? $name : $module->name); + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print "'."\n"; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") - { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - } else { - print img_picto($langs->trans("Enabled"), 'switch_on'); - } - print "'."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") + { + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + } else { + print img_picto($langs->trans("Enabled"), 'switch_on'); + } + print "'."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print '

'; @@ -521,11 +521,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans $variablename = 'SUPPLIER_ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 003c0247f20..217b7d7c44a 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -48,21 +48,21 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'alpha'); - $masksupplierpayment = GETPOST('masksupplierpayment', 'alpha'); - if ($maskconstsupplierpayment) $res = dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment, 'chaine', 0, '', $conf->entity); + $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'alpha'); + $masksupplierpayment = GETPOST('masksupplierpayment', 'alpha'); + if ($maskconstsupplierpayment) $res = dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'setmod') { - dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); } // Activate a model @@ -74,7 +74,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PAYMENT_ADDON_PDF', $conf->entity); + if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PAYMENT_ADDON_PDF', $conf->entity); } } @@ -96,54 +96,54 @@ elseif ($action == 'setdoc') } } elseif ($action == 'specimen') { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $paiementFourn = new PaiementFourn($db); - $paiementFourn->initAsSpecimen(); + $paiementFourn = new PaiementFourn($db); + $paiementFourn->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/supplier_payment/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + $file = dol_buildpath($reldir."core/modules/supplier_payment/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db); + $module = new $classname($db); - if ($module->write_file($paiementFourn, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($paiementFourn, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } elseif ($action == 'setparams') { - $res = dolibarr_set_const($db, "PAYMENTS_FOURN_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + $res = dolibarr_set_const($db, "PAYMENTS_FOURN_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; if ($error) - { + { setEventMessages($langs->trans("Error"), null, 'errors'); } if (!$error) - { + { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } } @@ -165,7 +165,7 @@ print load_fiche_titre($langs->trans("SupplierPaymentSetup"), $linkback, 'title_ print "
"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'supplierpayment', $langs->trans("Suppliers"), -1, 'company'); +print dol_get_fiche_head($head, 'supplierpayment', $langs->trans("Suppliers"), -1, 'company'); /* * Numbering module @@ -184,16 +184,16 @@ $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++; - } + $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); + dol_print_error($db); } print ''; @@ -209,104 +209,104 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) - { - $filebis = $file; - $classname = preg_replace('/\.php$/', '', $file); - // For compatibility - if (!is_file($dir.$filebis)) - { - $filebis = $file."/".$file.".modules.php"; - $classname = "mod_supplier_payment_".$file; - } - // Check if there is a filter on country - preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_supplier_payment_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; - $classname = preg_replace('/\-.*$/', '', $classname); - if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') - { - // Charging the numbering class - require_once $dir.$filebis; + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; - $module = new $classname($db); + $module = new $classname($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; + // 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()) - { - print ''; + print ''; - // Show example of numbering module - print ''."\n"; + // Show example of numbering module + print ''."\n"; - print ''; + print ''; - $payment = new PaiementFourn($db); - $payment->initAsSpecimen(); + $payment = new PaiementFourn($db); + $payment->initAsSpecimen(); - // Example - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $payment); - 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).'
'; - } - } + // Example + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $payment); + 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 ''; - print "\n"; - } - } - } - } - closedir($handle); - } - } + print "\n"; + } + } + } + } + closedir($handle); + } + } } print '
'; - echo preg_replace('/\-.*$/', '', preg_replace('/mod_supplier_payment_/', '', preg_replace('/\.php$/', '', $file))); - print "\n"; + if ($module->isEnabled()) + { + print '
'; + echo preg_replace('/\-.*$/', '', preg_replace('/mod_supplier_payment_/', '', preg_replace('/\.php$/', '', $file))); + print "\n"; - print $module->info(); + 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 '
'; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; - //print "> ".$conf->global->SUPPLIER_PAYMENT_ADDON." - ".$file; - if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.'.php' == $file) - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + //print "> ".$conf->global->SUPPLIER_PAYMENT_ADDON." - ".$file; + if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.'.php' == $file) + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors - { - if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); - } + if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors + { + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + } - print '
'; @@ -335,91 +335,91 @@ foreach ($dirmodels as $reldir) $realpath = $reldir."core/modules/supplier_payment/doc"; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); + if (is_dir($dir)) + { + $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $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, new PaiementFourn($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new PaiementFourn($db)); - print "\n"; - print ""; - print (empty($module->name) ? $name : $module->name); - print "\n"; - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + print "\n"; + print ""; + print (empty($module->name) ? $name : $module->name); + print "\n"; + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; - print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - //if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF != "$name") - //{ - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - /*} + // Active + if (in_array($name, $def)) + { + print ''."\n"; + //if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF != "$name") + //{ + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + /*} else { print img_picto($langs->trans("Enabled"),'switch_on'); }*/ - print ""; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + print ""; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF == "$name") - { - //print img_picto($langs->trans("Default"),'on'); - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Default + print ''; + if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF == "$name") + { + //print img_picto($langs->trans("Default"),'on'); + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $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); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print ''; - print "\n"; - } - } + print "\n"; + } + } - closedir($handle); - } - } + closedir($handle); + } + } } print ''; @@ -454,7 +454,7 @@ print "\n"; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); print '
'; print '
'; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 7bf34fa669a..38a6d9e3ff5 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -77,7 +77,7 @@ if ($action == 'specimen') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/supplier_proposal/doc/pdf_".$modele.".modules.php"); + $file = dol_buildpath($reldir."core/modules/supplier_proposal/doc/pdf_".$modele.".modules.php"); if (file_exists($file)) { $filefound = 1; @@ -139,16 +139,16 @@ if ($action == 'set_SUPPLIER_PROPOSAL_FREE_TEXT') if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } // Activate a model @@ -160,11 +160,11 @@ if ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PROPOSAL_ADDON_PDF', $conf->entity); + if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PROPOSAL_ADDON_PDF', $conf->entity); } } elseif ($action == 'setdoc') { - if (dolibarr_set_const($db, "SUPPLIER_PROPOSAL_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + if (dolibarr_set_const($db, "SUPPLIER_PROPOSAL_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF = $value; } @@ -202,7 +202,7 @@ print load_fiche_titre($langs->trans("SupplierProposalSetup"), $linkback, 'title $head = supplier_proposal_admin_prepare_head(); -dol_fiche_head($head, 'general', $langs->trans("CommRequests"), -1, 'supplier_proposal'); +print dol_get_fiche_head($head, 'general', $langs->trans("CommRequests"), -1, 'supplier_proposal'); /* * Module numerotation @@ -248,13 +248,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->SUPPLIER_PROPOSAL_ADDON == "$file") @@ -274,16 +274,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $supplier_proposal); - 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).'
'; - } - } + 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 $form->textwithpicto('', $htmltooltip, 1, 0); @@ -342,82 +342,82 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/supplier_proposal".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/supplier_proposal".$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); + 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); + 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); + 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; + $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 ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ""; - if ($conf->global->SUPPLIER_PROPOSAL_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 ''; + // Defaut + print ""; + if ($conf->global->SUPPLIER_PROPOSAL_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 ''; - // 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; + // 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("FeaturesSupported").':'; $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); @@ -427,28 +427,28 @@ foreach ($dirmodels as $reldir) $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -482,11 +482,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnSupplierProposal"), $la $variablename = 'SUPPLIER_PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; @@ -508,23 +508,23 @@ print ''; if ($conf->banque->enabled) { - print ''; - print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '; - if (!empty($conf->use_javascript_ajax)) - { - print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL'); - } else { - if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL)) - { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } else { - print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; - } - } - print ''; + print ''; + print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '; + if (!empty($conf->use_javascript_ajax)) + { + print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL'); + } else { + if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL)) + { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } else { + print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; + } + } + print ''; } else { - print ''; - print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '.$langs->trans('NotAvailable').''; + print ''; + print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '.$langs->trans('NotAvailable').''; } print ''; diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 50e2fbbbb91..ca12e4dfaa4 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -74,19 +74,19 @@ print "
\n"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'supplierinvoice', $langs->trans("Suppliers"), -1, 'company'); +print dol_get_fiche_head($head, 'supplierinvoice', $langs->trans("Suppliers"), -1, 'company'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -111,10 +111,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index 15a96009392..ac40ef66e09 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -76,11 +76,11 @@ print "
\n"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'supplierinvoicedet', $langs->trans("Suppliers"), -1, 'company'); +print dol_get_fiche_head($head, 'supplierinvoicedet', $langs->trans("Suppliers"), -1, 'company'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index 17d866d8f94..c46eebfb037 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -74,11 +74,11 @@ print "
\n"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'supplierorder', $langs->trans("Suppliers"), -1, 'company'); +print dol_get_fiche_head($head, 'supplierorder', $langs->trans("Suppliers"), -1, 'company'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 1bcfcec05c4..97cf92883f9 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -75,19 +75,19 @@ print "
\n"; $head = supplierorder_admin_prepare_head(); -dol_fiche_head($head, 'supplierorderdet', $langs->trans("Suppliers"), -1, 'company'); +print dol_get_fiche_head($head, 'supplierorderdet', $langs->trans("Suppliers"), -1, 'company'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -100,9 +100,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -112,10 +112,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 60de87d2d2e..6d84b4a0e2d 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -109,8 +109,8 @@ if ($action == 'set') $activeModules = $newActiveModules; - dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity - dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine', 0, '', 0); + dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity + dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine', 0, '', 0); // Check configuration foreach ($activeModules as $modulename) { @@ -213,7 +213,7 @@ foreach ($syslogModules as $moduleName) print ' '; print $module->getName(); if ($moduleName == 'mod_syslog_syslog') { - if (! $module->isActive()) { + if (!$module->isActive()) { $langs->load("errors"); print $form->textwithpicto('', $langs->trans("ErrorPHPNeedModule", 'SysLog')); } @@ -226,22 +226,22 @@ foreach ($syslogModules as $moduleName) { foreach ($setuparray as $option) { - $tmpoption = $option['constant']; - if (!empty($tmpoption)) - { - if (isset($_POST[$tmpoption])) $value = $_POST[$tmpoption]; - elseif (!empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption; - } else $value = (isset($option['default']) ? $option['default'] : ''); + $tmpoption = $option['constant']; + if (!empty($tmpoption)) + { + if (isset($_POST[$tmpoption])) $value = $_POST[$tmpoption]; + elseif (!empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption; + } else $value = (isset($option['default']) ? $option['default'] : ''); print $option['name'].': '; if (!empty($option['example'])) print '
'.$langs->trans("Example").': '.$option['example']; if ($option['constant'] == 'SYSLOG_FILE' && preg_match('/^DOL_DATA_ROOT\/[^\/]*$/', $value)) { - $filelogparam = ' ('; - $filelogparam .= $langs->trans('Download'); - $filelogparam .= $filelog.')'; - print $filelogparam; + $filelogparam = ' ('; + $filelogparam .= $langs->trans('Download'); + $filelogparam .= $filelog.')'; + print $filelogparam; } } } diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index bbac6bdfe0c..0668e4612ae 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -83,6 +83,7 @@ print '
  • '; print ''.$langs->trans("OfficialWebSite").''; print '
  • '; // Show local site +/* if (preg_match('/^fr_/i', $langs->getDefaultLang())) { print '
  • '; @@ -112,7 +113,7 @@ if (preg_match('/^de_/i', $langs->getDefaultLang())) print '
  • '; print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Germany")).''; print '
  • '; -} +}*/ print '
  • '; print ''.$langs->trans("OfficialWiki").''; print '
  • '; @@ -168,7 +169,7 @@ print $langs->trans("OtherResources").':'; print '
      '; $url = 'https://saas.dolibarr.org'; $title = $langs->trans("OfficialWebHostingService"); -if (preg_match('/^fr_/i', $langs->getDefaultLang())) $url = 'https://wiki.dolibarr.org/index.php/Solutions_de_Cloud'; +if (preg_match('/^fr_/i', $langs->getDefaultLang())) $url = 'https://wiki.dolibarr.org/index.php/Solutions_Cloud_pour_Dolibarr_ERP_CRM'; if (preg_match('/^es_/i', $langs->getDefaultLang())) $url = 'https://wiki.dolibarr.org/index.php/Soluciones_en_la_Nube'; print '
    • '; print ''.$title.''; @@ -188,25 +189,25 @@ print '
      '; $showpromotemessage = 1; if ($showpromotemessage) { - $tmp = versiondolibarrarray(); - if (is_numeric($tmp[2])) // Not alpha, beta or rc - { - print '
      '; - print '
      '; + $tmp = versiondolibarrarray(); + if (is_numeric($tmp[2])) // Not alpha, beta or rc + { + print '
      '; + print '
      '; - if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0)) - { - print $langs->trans("TitleExampleForMajorRelease").':
      '; - print ''; - } else { - print $langs->trans("TitleExampleForMaintenanceRelease").':
      '; - print ''; - } - } + if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0)) + { + print $langs->trans("TitleExampleForMajorRelease").':
      '; + print ''; + } else { + print $langs->trans("TitleExampleForMaintenanceRelease").':
      '; + print ''; + } + } } // End of page diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index 683fc3c4f3a..00020845bde 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -119,7 +119,7 @@ if (!$base) print ''.$obj->Name.''; print ''.$obj->Engine.''; if (isset($obj->Engine) && $obj->Engine == "MyISAM") { - print ''.$langs->trans("Convert").' InnoDb'; + print ''.$langs->trans("Convert").' InnoDb'; } else { print ' '; } diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index 6b08fc4fe8f..8681efa08ef 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -77,7 +77,7 @@ if (!count($listofvars) && !count($listofstatus)) foreach ($arraylist as $listname) { print '
      '; - print '
      '; + print '
      '; print ''; print ''; print ''; diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 41c8dcbd198..6bae9666ee9 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -48,9 +48,13 @@ $version = '0.0'; if ($action == 'getlastversion') { - $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); - //var_dump($result['content']); - $sfurl = simplexml_load_string($result['content']); + $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); + //var_dump($result['content']); + if (function_exists('simplexml_load_string')) { + $sfurl = simplexml_load_string($result['content']); + } else { + setEventMessages($langs->trans("ErrorPHPDoesNotSupport", "xml"), null, 'errors'); + } } @@ -74,43 +78,43 @@ print ''; + } + $out .= '
      '.$langs->trans("Parameters").'
      '.$langs->trans("CurrentVersion").' ('.$langs->tr // If current version differs from last upgrade if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) { - // Compare version with last install database version (upgrades never occured) - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); + // Compare version with last install database version (upgrades never occured) + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); } else { - // Compare version with last upgrade database version - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); + // Compare version with last upgrade database version + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); } if (function_exists('curl_init')) { - $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; - print '     -     '; - if ($action == 'getlastversion') - { - if ($sfurl) - { - while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) - { - $title = $sfurl->channel[0]->item[$i]->title; - if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) - { - $newversion = $reg[1]; - $newversionarray = explode('.', $newversion); - $versionarray = explode('.', $version); - //var_dump($newversionarray);var_dump($versionarray); - if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; - } - $i++; - } + $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; + print '     -     '; + if ($action == 'getlastversion') + { + if ($sfurl) + { + while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) + { + $title = $sfurl->channel[0]->item[$i]->title; + if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) + { + $newversion = $reg[1]; + $newversionarray = explode('.', $newversion); + $versionarray = explode('.', $version); + //var_dump($newversionarray);var_dump($versionarray); + if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; + } + $i++; + } - // Show version - print $langs->trans("LastStableVersion").' : '.(($version != '0.0') ? $version : $langs->trans("Unknown")).''; - } else { - print $langs->trans("LastStableVersion").' : '.$langs->trans("UpdateServerOffline").''; - } - } else { - print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").''; - } + // Show version + print $langs->trans("LastStableVersion").' : '.(($version != '0.0') ? $version : $langs->trans("Unknown")).''; + } else { + print $langs->trans("LastStableVersion").' : '.$langs->trans("UpdateServerOffline").''; + } + } else { + print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").''; + } } // Now show link to the changelog @@ -168,7 +172,7 @@ if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_S { $shmoparray = dol_listshmop(); - print '
      '; + print '
      '; print ''; print ''; print ''; @@ -280,8 +284,8 @@ $configfileparameters = array( 'dolibarr_main_document_root'=> $langs->trans("DocumentRootServer"), '?dolibarr_main_document_root_alt' => $langs->trans("DocumentRootServer").' (alt)', 'dolibarr_main_data_root' => $langs->trans("DataRootServer"), - 'dolibarr_main_instance_unique_id' => $langs->trans("InstanceUniqueID"), - 'separator1' => '', + 'dolibarr_main_instance_unique_id' => $langs->trans("InstanceUniqueID"), + 'separator1' => '', 'dolibarr_main_db_host' => $langs->trans("DatabaseServer"), 'dolibarr_main_db_port' => $langs->trans("DatabasePort"), 'dolibarr_main_db_name' => $langs->trans("DatabaseName"), @@ -293,7 +297,7 @@ $configfileparameters = array( '?dolibarr_main_db_prefix' => $langs->trans("Prefix"), 'separator2' => '', 'dolibarr_main_authentication' => $langs->trans("AuthenticationMode"), - '?multicompany_transverse_mode'=> $langs->trans("MultiCompanyMode"), + '?multicompany_transverse_mode'=> $langs->trans("MultiCompanyMode"), 'separator'=> '', '?dolibarr_main_auth_ldap_login_attribute' => 'dolibarr_main_auth_ldap_login_attribute', '?dolibarr_main_auth_ldap_host' => 'dolibarr_main_auth_ldap_host', @@ -349,8 +353,8 @@ foreach ($configfileparameters as $key => $value) if (preg_match('/^\?/', $key) && empty(${$newkey})) { - if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled)) - continue; // We discard parameters starting with ? + if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled)) + continue; // We discard parameters starting with ? } if (strpos($newkey, 'separator') !== false && $lastkeyshown == 'separator') continue; @@ -387,14 +391,14 @@ foreach ($configfileparameters as $key => $value) ++$i; } } elseif ($newkey == 'dolibarr_main_instance_unique_id') { - //print $conf->file->instance_unique_id; - global $dolibarr_main_cookie_cryptkey; - $valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey - print $valuetoshow; - if (empty($valuetoshow)) { - print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); - } - print '   ('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')'; + //print $conf->file->instance_unique_id; + global $dolibarr_main_cookie_cryptkey; + $valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey + print $valuetoshow; + if (empty($valuetoshow)) { + print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); + } + print '   ('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')'; } elseif ($newkey == 'dolibarr_main_prod') { print ${$newkey}; @@ -410,7 +414,7 @@ foreach ($configfileparameters as $key => $value) print img_warning($langs->trans('SwitchThisForABetterSecurity', 0)); } } else { - print ${$newkey}; + print ${$newkey}; } if ($newkey == 'dolibarr_main_url_root' && ${$newkey} != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')'; print ""; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index a3d54104a02..a94a78a9794 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; $langs->load("admin"); if (!$user->admin) - accessforbidden(); + accessforbidden(); $error = 0; @@ -57,13 +57,13 @@ print ''."\n"; print '
      '.$langs->trans("LanguageFilesCachedIntoShmopSharedMemory").'
      '.$langs->trans("VersionLastUpgrade") print '
      '.$langs->trans("VersionProgram").''.DOL_VERSION; // If current version differs from last upgrade if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) { - // Compare version with last install database version (upgrades never occured) - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) - print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); + // Compare version with last install database version (upgrades never occured) + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) + print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); } else { - // Compare version with last upgrade database version - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) - print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); + // Compare version with last upgrade database version + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) + print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); } print '
      '; @@ -96,24 +96,24 @@ print $langs->trans("MakeIntegrityAnalysisFrom").':
      '; print ''."\n"; if (dol_is_file($xmlfile)) { - print ' '.$langs->trans("LocalSignature").' = '; - print ''; - print '
      '; + print ' '.$langs->trans("LocalSignature").' = '; + print ''; + print '
      '; } else { - print ' '.$langs->trans("LocalSignature").' = '; - print ''; - print ' ('.$langs->trans("AvailableOnlyOnPackagedVersions").')'; - print '
      '; + print ' '.$langs->trans("LocalSignature").' = '; + print ''; + print ' ('.$langs->trans("AvailableOnlyOnPackagedVersions").')'; + print '
      '; } print ''."\n"; if ($enableremotecheck) { - print ' '.$langs->trans("RemoteSignature").' = '; - print '
      '; + print ' '.$langs->trans("RemoteSignature").' = '; + print '
      '; } else { - print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote; - if (!GETPOST('xmlremote')) print ' ('.$langs->trans("FeatureAvailableOnlyOnStable").')'; - print '
      '; + print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote; + if (!GETPOST('xmlremote')) print ' ('.$langs->trans("FeatureAvailableOnlyOnStable").')'; + print '
      '; } print '
      '; print ''; @@ -122,275 +122,275 @@ print '
      '; if (GETPOST('target') == 'local') { - if (dol_is_file($xmlfile)) - { - // If file is a zip file (.../filelist-x.y.z.xml.zip), we uncompress it before - if (preg_match('/\.zip$/i', $xmlfile)) { - dol_mkdir($conf->admin->dir_temp); - $xmlfilenew = preg_replace('/\.zip$/i', '', $xmlfile); - $result = dol_uncompress($xmlfile, $conf->admin->dir_temp); - if (empty($result['error'])) { - $xmlfile = $conf->admin->dir_temp.'/'.basename($xmlfilenew); - } else { - print $langs->trans('FailedToUncompressFile').': '.$xmlfile; - $error++; - } - } - $xml = simplexml_load_file($xmlfile); - } else { - print $langs->trans('XmlNotFound').': '.$xmlfile; - $error++; - } + if (dol_is_file($xmlfile)) + { + // If file is a zip file (.../filelist-x.y.z.xml.zip), we uncompress it before + if (preg_match('/\.zip$/i', $xmlfile)) { + dol_mkdir($conf->admin->dir_temp); + $xmlfilenew = preg_replace('/\.zip$/i', '', $xmlfile); + $result = dol_uncompress($xmlfile, $conf->admin->dir_temp); + if (empty($result['error'])) { + $xmlfile = $conf->admin->dir_temp.'/'.basename($xmlfilenew); + } else { + print $langs->trans('FailedToUncompressFile').': '.$xmlfile; + $error++; + } + } + $xml = simplexml_load_file($xmlfile); + } else { + print $langs->trans('XmlNotFound').': '.$xmlfile; + $error++; + } } if (GETPOST('target') == 'remote') { - $xmlarray = getURLContent($xmlremote); + $xmlarray = getURLContent($xmlremote); - // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) - if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') - { - $xmlfile = $xmlarray['content']; - //print "xmlfilestart".$xmlfile."xmlfileend"; - $xml = simplexml_load_string($xmlfile); - } else { - $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; - setEventMessages($errormsg, null, 'errors'); - $error++; - } + // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) + if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') + { + $xmlfile = $xmlarray['content']; + //print "xmlfilestart".$xmlfile."xmlfileend"; + $xml = simplexml_load_string($xmlfile); + } else { + $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; + setEventMessages($errormsg, null, 'errors'); + $error++; + } } if (!$error && $xml) { - $checksumconcat = array(); - $file_list = array(); - $out = ''; + $checksumconcat = array(); + $file_list = array(); + $out = ''; - // Forced constants - if (is_object($xml->dolibarr_constants[0])) - { - $out .= load_fiche_titre($langs->trans("ForcedConstants")); + // Forced constants + if (is_object($xml->dolibarr_constants[0])) + { + $out .= load_fiche_titre($langs->trans("ForcedConstants")); $out .= '
      '; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; + $out .= '
      #'.$langs->trans("Constant").''.$langs->trans("ExpectedValue").''.$langs->trans("Value").'
      '; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; - $i = 0; - foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement - { - $constname = $constant['name']; - $constvalue = (string) $constant; - $constvalue = (empty($constvalue) ? '0' : $constvalue); - // Value found - $value = ''; - if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; - $valueforchecksum = (empty($value) ? '0' : $value); + $i = 0; + foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement + { + $constname = $constant['name']; + $constvalue = (string) $constant; + $constvalue = (empty($constvalue) ? '0' : $constvalue); + // Value found + $value = ''; + if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; + $valueforchecksum = (empty($value) ? '0' : $value); - $checksumconcat[] = $valueforchecksum; + $checksumconcat[] = $valueforchecksum; - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } - if ($i == 0) - { - $out .= ''; - } - $out .= '
      #'.$langs->trans("Constant").''.$langs->trans("ExpectedValue").''.$langs->trans("Value").'
      '.$i.''.dol_escape_htmltag($constname).''.dol_escape_htmltag($constvalue).''.dol_escape_htmltag($valueforchecksum).'
      '.$i.''.dol_escape_htmltag($constname).''.dol_escape_htmltag($constvalue).''.dol_escape_htmltag($valueforchecksum).'
      '.$langs->trans("None").'
      '; - $out .= '
      '; + if ($i == 0) + { + $out .= '
      '.$langs->trans("None").'
      '; + $out .= '
      '; - $out .= '
      '; - } + $out .= '
      '; + } - // Scan htdocs - if (is_object($xml->dolibarr_htdocs_dir[0])) - { - //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit; - $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); + // Scan htdocs + if (is_object($xml->dolibarr_htdocs_dir[0])) + { + //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit; + $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); - // Defined qualified files (must be same than into generate_filelist_xml.php) - $regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; - $regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs - $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); + // Defined qualified files (must be same than into generate_filelist_xml.php) + $regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; + $regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs + $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); - // Fill file_list with files in signature, new files, modified files - $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list - // Complete with list of new files - foreach ($scanfiles as $keyfile => $valfile) - { - $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); - if (!in_array($tmprelativefilename, $file_list['insignature'])) - { - $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file - $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); - } - } + // Fill file_list with files in signature, new files, modified files + $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list + // Complete with list of new files + foreach ($scanfiles as $keyfile => $valfile) + { + $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); + if (!in_array($tmprelativefilename, $file_list['insignature'])) + { + $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file + $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); + } + } - // Files missings - $out .= load_fiche_titre($langs->trans("FilesMissing")); + // Files missings + $out .= load_fiche_titre($langs->trans("FilesMissing")); $out .= '
      '; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; - $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); - if (is_array($tmpfilelist) && count($tmpfilelist)) - { - $i = 0; - foreach ($tmpfilelist as $file) - { - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } - } else { - $out .= ''; - } - $out .= '
      #'.$langs->trans("Filename").''.$langs->trans("ExpectedSize").''.$langs->trans("ExpectedChecksum").'
      '.$i.''.dol_escape_htmltag($file['filename']).''; - if (!empty($file['expectedsize'])) $out .= dol_print_size($file['expectedsize']); - $out .= ''.dol_escape_htmltag($file['expectedmd5']).'
      '.$langs->trans("None").'
      '; - $out .= '
      '; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; + $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); + if (is_array($tmpfilelist) && count($tmpfilelist)) + { + $i = 0; + foreach ($tmpfilelist as $file) + { + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } + } else { + $out .= ''; + } + $out .= '
      #'.$langs->trans("Filename").''.$langs->trans("ExpectedSize").''.$langs->trans("ExpectedChecksum").'
      '.$i.''.dol_escape_htmltag($file['filename']).''; + if (!empty($file['expectedsize'])) $out .= dol_print_size($file['expectedsize']); + $out .= ''.dol_escape_htmltag($file['expectedmd5']).'
      '.$langs->trans("None").'
      '; + $out .= '
      '; - $out .= '
      '; + $out .= '
      '; - // Files modified - $out .= load_fiche_titre($langs->trans("FilesModified")); + // Files modified + $out .= load_fiche_titre($langs->trans("FilesModified")); - $totalsize = 0; + $totalsize = 0; $out .= '
      '; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; - $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); - if (is_array($tmpfilelist2) && count($tmpfilelist2)) - { - $i = 0; - foreach ($tmpfilelist2 as $file) - { - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); - $totalsize += $size; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } else { - $out .= ''; - } - $out .= '
      #'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("ExpectedSize").''.$langs->trans("CurrentSize").''.$langs->trans("DateModification").'
      '.$i.''.dol_escape_htmltag($file['filename']).''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''; - if ($file['expectedsize']) $out .= dol_print_size($file['expectedsize']); - $out .= ''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
      '.$langs->trans("Total").''.dol_print_size($totalsize).'
      '.$langs->trans("None").'
      '; - $out .= '
      '; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; + $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); + if (is_array($tmpfilelist2) && count($tmpfilelist2)) + { + $i = 0; + foreach ($tmpfilelist2 as $file) + { + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); + $totalsize += $size; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } else { + $out .= ''; + } + $out .= '
      #'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("ExpectedSize").''.$langs->trans("CurrentSize").''.$langs->trans("DateModification").'
      '.$i.''.dol_escape_htmltag($file['filename']).''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''; + if ($file['expectedsize']) $out .= dol_print_size($file['expectedsize']); + $out .= ''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
      '.$langs->trans("Total").''.dol_print_size($totalsize).'
      '.$langs->trans("None").'
      '; + $out .= '
    '; - $out .= '
    '; + $out .= '
    '; - // Files added - $out .= load_fiche_titre($langs->trans("FilesAdded")); + // Files added + $out .= load_fiche_titre($langs->trans("FilesAdded")); - $totalsize = 0; + $totalsize = 0; $out .= '
    '; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; - $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); - if (is_array($tmpfilelist3) && count($tmpfilelist3)) - { - $i = 0; - foreach ($tmpfilelist3 as $file) - { - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); - $totalsize += $size; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } else { - $out .= ''; - } - $out .= '
    #'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("Size").''.$langs->trans("DateModification").'
    '.$i.''.dol_escape_htmltag($file['filename']); - if (!preg_match('/^win/i', PHP_OS)) { - $htmltext = $langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] - $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); - } - $out .= ''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
    '.$langs->trans("Total").''.dol_print_size($totalsize).'
    '.$langs->trans("None").'
    '; - $out .= '
    '; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; + $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); + if (is_array($tmpfilelist3) && count($tmpfilelist3)) + { + $i = 0; + foreach ($tmpfilelist3 as $file) + { + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); + $totalsize += $size; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } else { + $out .= ''; + } + $out .= '
    #'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("Size").''.$langs->trans("DateModification").'
    '.$i.''.dol_escape_htmltag($file['filename']); + if (!preg_match('/^win/i', PHP_OS)) { + $htmltext = $langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] + $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); + } + $out .= ''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
    '.$langs->trans("Total").''.dol_print_size($totalsize).'
    '.$langs->trans("None").'
    '; + $out .= '
    '; - // Show warning - if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) - { - setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); - } - } else { - print 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile; - $error++; - } + // Show warning + if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) + { + setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); + } + } else { + print 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile; + $error++; + } - // Scan scripts - /* + // Scan scripts + /* if (is_object($xml->dolibarr_script_dir[0])) { $file_list = array(); @@ -398,44 +398,44 @@ if (!$error && $xml) }*/ - asort($checksumconcat); // Sort list of checksum - //var_dump($checksumconcat); - $checksumget = md5(join(',', $checksumconcat)); - $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); + asort($checksumconcat); // Sort list of checksum + //var_dump($checksumconcat); + $checksumget = md5(join(',', $checksumconcat)); + $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); - /*var_dump(count($file_list['added'])); + /*var_dump(count($file_list['added'])); var_dump($checksumget); var_dump($checksumtoget); var_dump($checksumget == $checksumtoget);*/ - $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")); - if ($checksumget == $checksumtoget) - { - if (count($file_list['added'])) - { - $resultcode = 'warning'; - $resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; - $outcurrentchecksum = $checksumget.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; - } else { - $resultcode = 'ok'; - $resultcomment = 'Success'; - $outcurrentchecksum = ''.$checksumget.''; - } - } else { - $resultcode = 'error'; - $resultcomment = 'Error'; - $outcurrentchecksum = ''.$checksumget.''; - } + $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")); + if ($checksumget == $checksumtoget) + { + if (count($file_list['added'])) + { + $resultcode = 'warning'; + $resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; + $outcurrentchecksum = $checksumget.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; + } else { + $resultcode = 'ok'; + $resultcomment = 'Success'; + $outcurrentchecksum = ''.$checksumget.''; + } + } else { + $resultcode = 'error'; + $resultcomment = 'Error'; + $outcurrentchecksum = ''.$checksumget.''; + } - print load_fiche_titre($langs->trans("GlobalChecksum")).'
    '; - print $langs->trans("ExpectedChecksum").' = '.$outexpectedchecksum.'
    '; - print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum; + print load_fiche_titre($langs->trans("GlobalChecksum")).'
    '; + print $langs->trans("ExpectedChecksum").' = '.$outexpectedchecksum.'
    '; + print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum; - print '
    '; - print '
    '; + print '
    '; + print '
    '; - // Output detail - print $out; + // Output detail + print $out; } // End of page diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 06003068bb2..2bbe919c72e 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -94,10 +94,10 @@ if ($db->type == 'pgsql') { // Check option standard_conforming_strings is on $paramarray = $db->getServerParametersValues('standard_conforming_strings'); - // if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1) - // { - // $langs->load("errors"); - // } + // if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1) + // { + // $langs->load("errors"); + // } } print '
    '; diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 7857773924f..6d9e3574789 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -62,7 +62,7 @@ print "
    Web server - ".$langs->trans("Version").": ".$_SERVE print '
    '; print ''.$langs->trans("XDebug").': '; $test = !function_exists('xdebug_is_enabled'); -if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); +if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotSlowedDownByThis"); else { print img_picto('', 'warning').' '.$langs->trans("ModuleActivated", $langs->transnoentities("XDebug")); print ' - '.$langs->trans("MoreInformation").' XDebug admin page'; @@ -73,7 +73,7 @@ print '
    '; print '
    '; print ''.$langs->trans("Syslog").': '; $test = empty($conf->syslog->enabled); -if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); +if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotSlowedDownByThis"); else { print img_picto('', 'warning').' '.$langs->trans("ModuleActivated", $langs->transnoentities("Syslog")); //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; @@ -84,10 +84,10 @@ print '
    '; print '
    '; print ''.$langs->trans("DebugBar").': '; $test = empty($conf->debugbar->enabled); -if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); +if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotSlowedDownByThis"); else { print img_picto('', 'warning').' '.$langs->trans("ModuleActivated", $langs->transnoentities("DebugBar")); - //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; + //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } print '
    '; @@ -431,7 +431,6 @@ print '
    '; print ''; print $form->textwithpicto($langs->trans("CompressionOfResources"), $langs->trans("CompressionOfResourcesDesc")); print ': '; -//$tmp=getURLContent(DOL_URL_ROOT.'/index.php','GET');var_dump($tmp); print '
    '; // on PHP print '
    '.img_picto('', 'tick.png').' '.$langs->trans("FilesOfTypeCompressed", 'php (.php)').'
    '; diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index 9f1766a5d22..78146b85a76 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -105,36 +105,21 @@ if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["main print ''; print 'Sessions support'; - if (!function_exists("session_id")) { print 'Error '.$langs->trans("ErrorPHPDoesNotSupportSessions"); } else { print 'Ok '.$langs->trans("PHPSupportSessions"); } - print ''; print 'UTF-8 support'; - if (!function_exists("utf8_encode")) { print 'Warning '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8"); } else { print 'Ok '.$langs->trans("PHPSupport", "UTF8"); } - -print ''; - -print 'MBString support'; - -if (!function_exists("mb_check_encoding")) -{ - print 'Warning '.$langs->trans("ErrorPHPDoesNotSupport", "mbstring"); -} else { - print 'Ok '.$langs->trans("PHPSupport", "mbstring"); -} - print ''; print ''; @@ -153,6 +138,28 @@ print ''.$langs->trans("FunctionTest").''; print ''.$langs->trans("Result").''; print ''; +$functions = ["mb_check_encoding"]; +$name = "MBString"; + +print ""; +print "".$name.""; +//print getTableColumn($name, $activatedExtensions); +print getTableColumn($name, $loadedExtensions); +print getTableColumnFunction($functions); +print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); +print ""; + +$functions = ["json_decode"]; +$name = "JSON"; + +print ""; +print "".$name.""; +//print getTableColumn($name, $activatedExtensions); +print getTableColumn($name, $loadedExtensions); +print getTableColumnFunction($functions); +print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); +print ""; + $functions = ["imagecreate"]; $name = "GD"; @@ -186,7 +193,6 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc print getTableColumn($name, $loadedExtensions); print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); - print ""; } @@ -225,7 +231,7 @@ foreach ($phparray as $key => $value) print ''.$keyparam.''; $valtoshow = $keyvalue; if ($keyparam == 'X-ChromePhp-Data') $valtoshow = dol_trunc($keyvalue, 80); - print ''; + print ''; if ($keyparam == 'Path') $valtoshow = implode('; ', explode(';', trim($valtoshow))); if ($keyparam == 'PATH') $valtoshow = implode('; ', explode(';', trim($valtoshow))); if ($keyparam == '_SERVER["PATH"]') $valtoshow = implode('; ', explode(';', trim($valtoshow))); @@ -275,7 +281,7 @@ function getActivatedExtensions() // For compatibility with LF (Line Feed) if (empty($configLines) || count($configLines) < 2) { - $configLines = explode("\n", $content); + $configLines = explode("\n", $content); } $extensions = array(); @@ -425,8 +431,8 @@ function getResultColumn($name, array $activated, array $loaded, array $function } $html = ""; - $html .= $result ? $langs->trans("PHPSupport".$name) : $langs->trans("ErrorPHPDoesNotSupport".$name); + $html .= $result ? $langs->trans("PHPSupport", $name) : $langs->trans("ErrorPHPDoesNotSupport".$name); $html .= ""; - return $html; + return $html; } diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 0cf70f2bbaa..f978c0dcd81 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -25,6 +25,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; // Load translation files required by the page $langs->loadLangs(array("install", "other", "admin")); @@ -50,52 +51,71 @@ llxHeader(); print load_fiche_titre($langs->trans("Security"), '', 'title_setup'); print ''.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').' ('.$langs->trans("Reload").')
    '; +print '
    '; -// Recupere la version de PHP +print load_fiche_titre($langs->trans("PHPSetup"), '', 'folder'); + +// Get version of PHP $phpversion = version_php(); -print "
    PHP - ".$langs->trans("Version").": ".$phpversion."
    \n"; +print "PHP - ".$langs->trans("Version").": ".$phpversion."
    \n"; -// Recupere la version du serveur web +// Get versionof web server print "
    Web server - ".$langs->trans("Version").": ".$_SERVER["SERVER_SOFTWARE"]."
    \n"; print '
    '; - -print load_fiche_titre($langs->trans("ConfigFile"), '', ''); - -print ''.$langs->trans("dolibarr_main_prod").': '.$dolibarr_main_prod; -// dolibarr_main_prod - - +print "PHP safe_mode = ".(ini_get('safe_mode') ? ini_get('safe_mode') : yn(0))."
    \n"; +print "PHP open_basedir = ".(ini_get('open_basedir') ? ini_get('open_basedir') : yn(0))."
    \n"; print '
    '; -print '
    '; - -print load_fiche_titre($langs->trans("PermissionsOnFiles"), '', ''); - -print ''.$langs->trans("PermissionOnFileInWebRoot").': '; -// TODO - - -print '
    '; -print '
    '; - - -print load_fiche_titre($langs->trans("Modules"), '', ''); // XDebug print ''.$langs->trans("XDebug").': '; $test = !function_exists('xdebug_is_enabled'); -if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); +if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis"); else { print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("XDebug")); print ' - '.$langs->trans("MoreInformation").' XDebug admin page'; } print '
    '; -// Module log print '
    '; +print load_fiche_titre($langs->trans("ConfigFile"), '', 'folder'); + +print ''.$langs->trans("dolibarr_main_prod").': '.$dolibarr_main_prod; +if (empty($dolibarr_main_prod)) { + print '   '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 1); +} +print '
    '; + +print ''.$langs->trans("dolibarr_nocsrfcheck").': '.$dolibarr_nocsrfcheck; +if (!empty($dolibarr_nocsrfcheck)) { + print img_picto('', 'warning').'   '.$langs->trans("IfYouAreOnAProductionSetThis", 0); +} + +print '
    '; + +print '
    '; +print '
    '; +print load_fiche_titre($langs->trans("Permissions"), '', 'folder'); + +print ''.$langs->trans("PermissionsOnFilesInWebRoot").': '; +// TODO Check permission are read only except for custom dir +print 'TODO'; +print '
    '; + +print ''.$langs->trans("PermissionsOnFile", 'conf.php').': '; +// TODO Check permission on file conf.php (read only for the web user) +print 'TODO'; +print '
    '; + +print '
    '; + +print '
    '; +print load_fiche_titre($langs->trans("Modules"), '', 'folder'); + +// Module log print ''.$langs->trans("Syslog").': '; $test = empty($conf->syslog->enabled); -if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); +if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis"); else { print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("Syslog")); //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; @@ -103,33 +123,53 @@ else { print '
    '; // Module debugbar -print '
    '; print ''.$langs->trans("DebugBar").': '; $test = empty($conf->debugbar->enabled); -if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); +if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis"); else { print img_picto('', 'error').' '.$langs->trans("ModuleActivatedDoNotUseInProduction", $langs->transnoentities("DebugBar")); - //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; + //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } print '
    '; -print '
    '; -print load_fiche_titre($langs->trans("SecuritySetup"), '', ''); +print '
    '; +print '
    '; +print load_fiche_titre($langs->trans("Menu").' '.$langs->trans("SecuritySetup"), '', 'folder'); //print ''.$langs->trans("PasswordEncryption").': '; -print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."   (Recommanded value: 'password_hash')
    "; +print 'MAIN_SECURITY_HASH_ALGO = '.(empty($conf->global->MAIN_SECURITY_HASH_ALGO) ? 'unset' : '')."   "; +print '   If unset: \'md5\' '; +print ' - Recommanded value: \'password_hash\'
    '; print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT.'
    '; print '
    '; // TODO print ''.$langs->trans("AntivirusEnabledOnUpload").': '; -// TODO +print yn($conf->global->MAIN_ANTIVIRUS_COMMAND ? 1 : 0); +if (!empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { + print '   - '.$conf->global->MAIN_ANTIVIRUS_COMMAND; + if (defined('MAIN_ANTIVIRUS_COMMAND')) { + print ' - '.$langs->trans("ValueIsForcedBySystem").''; + } +} print '
    '; -print ''.$langs->trans("SecurityAudit").': '; -// TODO Disabled or enabled ? print '
    '; +$securityevent = new Events($db); +$eventstolog = $securityevent->eventstolog; + +print ''.$langs->trans("LogEvents").': '; +// Loop on each event type +foreach ($eventstolog as $key => $arr) +{ + if ($arr['id']) + { + $key = 'MAIN_LOGEVENTS_'.$arr['id']; + $value = empty($conf->global->$key) ? '' : $conf->global->$key; + if ($value) print $key.', '; + } +} diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index 51a089336c6..0963a264c52 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -125,7 +125,7 @@ if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('TaxSetup'), $linkback, 'title_setup'); -//dol_fiche_head(null, '', '', -1); +//print dol_get_fiche_head(null, '', '', -1); if (empty($mysoc->tva_assuj)) { diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index b30dd9c5f13..e8da4a8d736 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -182,11 +182,11 @@ print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); // Configuration header $head = ticketAdminPrepareHead(); -dol_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticket"); +print dol_get_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticket"); print ''.$langs->trans("TicketSetupDictionaries").' : '.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'
    '; -dol_fiche_end(); +print dol_get_fiche_end(); /* diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php index 91e5df44180..4a50beaa32e 100644 --- a/htdocs/admin/ticket_extrafields.php +++ b/htdocs/admin/ticket_extrafields.php @@ -71,11 +71,11 @@ print load_fiche_titre($langs->trans("TicketSetup"), $linkback, 'title_setup'); $head = ticketAdminPrepareHead(); -dol_fiche_head($head, 'attributes', $langs->trans("Module56000Name"), -1, "ticket"); +print dol_get_fiche_head($head, 'attributes', $langs->trans("Module56000Name"), -1, "ticket"); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 011de9422bf..121ded4f578 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -32,7 +32,7 @@ $langs->loadLangs(array("admin", "ticket")); // Access control if (!$user->admin) { - accessforbidden(); + accessforbidden(); } // Parameters @@ -50,62 +50,62 @@ $error = 0; if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { - if (GETPOST('value')) 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); + if (GETPOST('value')) 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); } if ($action == 'setvar') { - include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; + include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; - $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml'); - if (!empty($topic_interface)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml'); + if (!empty($topic_interface)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml'); - if (!empty($text_home)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml'); + if (!empty($text_home)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml'); - if (!empty($text_help)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml'); + if (!empty($text_help)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml'); - if (!empty($mail_new_ticket)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml'); + if (!empty($mail_new_ticket)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); - if (!empty($url_interface)) { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); + if (!empty($url_interface)) { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } $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); @@ -115,38 +115,38 @@ if ($action == 'setvar') { } if ($action == 'setvarother') { - $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } + $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } - $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_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_CUSTOMER_MAILS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } + $param_disable_email = GETPOST('TICKET_DISABLE_CUSTOMER_MAILS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } $param_show_module_logo = GETPOST('TICKET_SHOW_COMPANY_LOGO', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_SHOW_COMPANY_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); if (!$res > 0) { - $error++; + $error++; } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, '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'); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + } } @@ -171,25 +171,25 @@ print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); // Configuration header $head = ticketAdminPrepareHead(); -dol_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket"); +print dol_get_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket"); print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php', 2).''; -dol_fiche_end(); +print dol_get_fiche_end(); $enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { - // Button off, click to enable - $enabledisablehtml .= ''; - $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); - $enabledisablehtml .= ''; + // Button off, click to enable + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); + $enabledisablehtml .= ''; } else { - // Button on, click to disable - $enabledisablehtml .= ''; - $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); - $enabledisablehtml .= ''; + // Button on, click to disable + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml .= ''; } print $enabledisablehtml; print ''; @@ -198,37 +198,37 @@ print '

    '; if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { - if (empty($conf->use_javascript_ajax)) { - print '
    '; - print ''; - print ''; - } + if (empty($conf->use_javascript_ajax)) { + print ''; + print ''; + print ''; + } - print '
    '; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
    '; + print '
    '.$langs->trans("Parameters").''; - print ''; - print '
    '; + print ''; + print ''; + print ''; + print ''; - // Check if email exists - print ''; - print ''; - print ''; - print ''; + // Check if email exists + print ''; + print ''; + print ''; + print ''; - /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // Show logo for module print ''; @@ -246,145 +246,145 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print ''; }*/ - // Show logo for company - print ''; - print ''; - print ''; - print ''; + // Show logo for company + print ''; + print ''; + print ''; + print ''; - // Also send to main email address - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - print ''; - print ''; - print ''; - print ''; - } + // Also send to main email address + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + print ''; + print ''; + print ''; + print ''; + } - if (!$conf->use_javascript_ajax) { - print ''; - print ''; - } + if (!$conf->use_javascript_ajax) { + print ''; + print ''; + } - print '
    '.$langs->trans("Parameters").''; + print ''; + print '
    '.$langs->trans("TicketsEmailMustExist").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); - } 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 ''; - print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); - print '
    '.$langs->trans("TicketsEmailMustExist").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); + } 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 ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); + print '
    ' . $langs->trans("TicketsShowModuleLogo") . '
    '.$langs->trans("TicketsShowCompanyLogo").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); - print '
    '.$langs->trans("TicketsShowCompanyLogo").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); + print '
    '.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); - print '
    '.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); + print '
    '; - print '
    '; - print '
    '; + print ''; + print '
    '; + print '
    '; - if (!$conf->use_javascript_ajax) { - print ''; - } + if (!$conf->use_javascript_ajax) { + print ''; + } - // Admin var of module - print load_fiche_titre($langs->trans("TicketParamMail")); + // Admin var of module + print load_fiche_titre($langs->trans("TicketParamMail")); - print '
    '; - print ''; + print '
    '; + print '
    '; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print "\n"; - if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { - print ''; - print ''; - print "\n"; - } + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { + print ''; + print ''; + print "\n"; + } - // Interface topic - $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; - print ''; - print ''; - print ''; + // Interface topic + $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; + print ''; + print ''; + print ''; - // Texte d'accueil homepage - $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); - print ''; - print ''; + // Texte d'accueil homepage + $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); + print ''; + print ''; - // Texte d'aide à la saisie du message - $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); - print ''; - print ''; + // Texte d'aide à la saisie du message + $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); + print ''; + print ''; - // Activate email creation to user - print ''; - print ''; - print ''; - print ''; + // Activate email creation to user + print ''; + print ''; + print ''; + print ''; - // Texte de création d'un ticket - $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); - print ''; - print ''; + // Texte de création d'un ticket + $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); + print ''; + print ''; - // Url public interface - $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; - print ''; - print ''; - print ''; + // Url public interface + $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; + print ''; + print ''; + print ''; // Activate email notification when a new message is added - print ''; + print ''; print ''; // Send notification when a new message is added to a email if a user is not assigned to the ticket - print ''; + print ''; print ''; print '
    '.$langs->trans("Parameter").'
    '.$langs->trans("Parameter").'
    '.$langs->trans("TicketCkEditorEmailNotActivated").'
    '.$langs->trans("TicketCkEditorEmailNotActivated").'
    '.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").''; - print ''; - print ''; - print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); - print '
    '.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); + print '
    '.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").''; - print ''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); - $doleditor->Create(); - print ''; - print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); - print '
    '.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").''; + print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); + print '
    '.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").''; - print ''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); - $doleditor->Create(); - print ''; - print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); - print '
    '.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").''; + print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); + print '
    '.$langs->trans("TicketsDisableCustomerEmail").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help'); - print '
    '.$langs->trans("TicketsDisableCustomerEmail").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help'); + print '
    '.$langs->trans("TicketNewEmailBodyLabel").''; - print ''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); - $doleditor->Create(); - print ''; - print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); - print '
    '.$langs->trans("TicketNewEmailBodyLabel").''; + print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); + print '
    '.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").''; - print ''; - print ''; - print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); - print '
    '.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); + print '
    ' . $langs->trans("TicketsPublicNotificationNewMessage") . '
    '.$langs->trans("TicketsPublicNotificationNewMessage").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED'); @@ -399,9 +399,9 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
    ' . $langs->trans("TicketPublicNotificationNewMessageDefaultEmail") . ''; + print '
    '.$langs->trans("TicketPublicNotificationNewMessageDefaultEmail").''; print ''; - print ''; print $form->textwithpicto('', $langs->trans("TicketPublicNotificationNewMessageDefaultEmailHelp"), 1, 'help'); @@ -410,9 +410,9 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
    '; print '
    '; - print '
    '; + print '
    '; - print ''; + print ''; } // End of page diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 5e990709d19..4128c0d7075 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -243,7 +243,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { print ''; print ''; - print ''; + print ''; print ''; print '
    '; print ''; @@ -304,7 +304,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { print '
    '; print '
    '.$langs->trans('ExportStructure').''; - print ''; + print ''; print ''; print '
    '; print '
    '; diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index 224bbc14b56..91fbb81b90e 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -58,8 +58,8 @@ jQuery(document).ready(function() { jQuery("#postgresql_options").show(); }); }); @@ -97,26 +97,26 @@ print $langs->trans("RestoreDesc3", $dolibarr_main_db_name).'

    ';
    trans("ImportMethod"); ?> + if (in_array($type, array('mysql', 'mysqli'))) + { + ?>
    />
    + } elseif (in_array($type, array('pgsql'))) + { + ?>
    />
    + } else { + print 'No method available with database '.$label; + } + ?>
    @@ -128,8 +128,8 @@ print $langs->trans("RestoreDesc3", $dolibarr_main_db_name).'

    '; '; - print ''.$langs->trans('RestoreMySQL').''; + print '
    '; + print ''.$langs->trans('RestoreMySQL').''; print '
    '; // Parameteres execution $command = $db->getPathOfRestore(); @@ -152,46 +152,46 @@ if (in_array($type, array('mysql', 'mysqli'))) print '
    '; print ajax_autoselect('restorecommand'); - if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) { - print '
    '.$langs->trans("UnHidePassword").''; - } - //else print '
    '.$langs->trans("HidePassword").''; - print '
    '; - print '
    '; + if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) { + print '
    '.$langs->trans("UnHidePassword").''; + } + //else print '
    '.$langs->trans("HidePassword").''; + print '
    '; + print ''; } elseif (in_array($type, array('pgsql'))) { - print '
    '; - print 'Restore PostgreSQL'; - print '
    '; - // Parameteres execution - $command = $db->getPathOfRestore(); - if (preg_match("/\s/", $command)) $command = $command = escapeshellarg($command); // Use quotes on command + print '
    '; + print 'Restore PostgreSQL'; + print '
    '; + // Parameteres execution + $command = $db->getPathOfRestore(); + if (preg_match("/\s/", $command)) $command = $command = escapeshellarg($command); // Use quotes on command - $param = " -d ".$dolibarr_main_db_name; - $param .= " -h ".$dolibarr_main_db_host; - if (!empty($dolibarr_main_db_port)) $param .= " -p ".$dolibarr_main_db_port; - $param .= " -U ".$dolibarr_main_db_user; - $paramcrypted = $param; - $paramclear = $param; - /*if (! empty($dolibarr_main_db_pass)) + $param = " -d ".$dolibarr_main_db_name; + $param .= " -h ".$dolibarr_main_db_host; + if (!empty($dolibarr_main_db_port)) $param .= " -p ".$dolibarr_main_db_port; + $param .= " -U ".$dolibarr_main_db_user; + $paramcrypted = $param; + $paramclear = $param; + /*if (! empty($dolibarr_main_db_pass)) { $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass); $paramclear.=" -p".$dolibarr_main_db_pass; }*/ - $paramcrypted .= " -W"; - $paramclear .= " -W"; - // With psql: - $paramcrypted .= " -f"; - $paramclear .= " -f"; + $paramcrypted .= " -W"; + $paramclear .= " -W"; + // With psql: + $paramcrypted .= " -f"; + $paramclear .= " -f"; - echo $langs->trans("ImportPostgreSqlDesc"); - print '
    '; - print '
    '; - print ajax_autoselect('restorecommand'); - //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
    '.$langs->trans("UnHidePassword").''; - //else print '
    '.$langs->trans("HidePassword").''; - print '
    '; - print '
    '; + echo $langs->trans("ImportPostgreSqlDesc"); + print '
    '; + print '
    '; + print ajax_autoselect('restorecommand'); + //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
    '.$langs->trans("UnHidePassword").''; + //else print '
    '.$langs->trans("HidePassword").''; + print '
    '; + print '
    '; } print '
    '; diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 7ab26f6f6e0..0c3679c62fa 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -49,9 +49,9 @@ if (!$user->admin) accessforbidden(); if ($file && !$what) { - //print DOL_URL_ROOT.'/dolibarr_export.php'; + //print DOL_URL_ROOT.'/dolibarr_export.php'; header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int') ? '&page_y='.GETPOST('page_y', 'int') : '')); - exit; + exit; } $errormsg = ''; @@ -83,16 +83,16 @@ $_SESSION["commandbackupresult"] = ''; $ExecTimeLimit = 600; if (!empty($ExecTimeLimit)) { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); } $MemoryLimit = 0; if (!empty($MemoryLimit)) { - @ini_set('memory_limit', $MemoryLimit); + @ini_set('memory_limit', $MemoryLimit); } $form = new Form($db); @@ -122,51 +122,51 @@ $utils = new Utils($db); // MYSQL if ($what == 'mysql') { - $cmddump = GETPOST("mysqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg - $cmddump = dol_sanitizePathName($cmddump); + $cmddump = GETPOST("mysqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg + $cmddump = dol_sanitizePathName($cmddump); - if (!empty($dolibarr_main_restrict_os_commands)) - { - $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); - dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); - $basenamecmddump = basename($cmddump); - if (!in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command - { - $errormsg = $langs->trans('CommandIsNotInsideAllowedCommands'); - } - } + if (!empty($dolibarr_main_restrict_os_commands)) + { + $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); + dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); + $basenamecmddump = basename($cmddump); + if (!in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command + { + $errormsg = $langs->trans('CommandIsNotInsideAllowedCommands'); + } + } - if (!$errormsg && $cmddump) - { - dolibarr_set_const($db, 'SYSTEMTOOLS_MYSQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); - } + if (!$errormsg && $cmddump) + { + dolibarr_set_const($db, 'SYSTEMTOOLS_MYSQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); + } - if (!$errormsg) - { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; - } + if (!$errormsg) + { + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + } } // MYSQL NO BIN if ($what == 'mysqlnobin') { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; } // POSTGRESQL if ($what == 'postgresql') { - $cmddump = GETPOST("postgresqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg - $cmddump = dol_sanitizePathName($cmddump); + $cmddump = GETPOST("postgresqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg + $cmddump = dol_sanitizePathName($cmddump); - /* Not required, the command is output on screen but not ran for pgsql + /* Not required, the command is output on screen but not ran for pgsql if (! empty($dolibarr_main_restrict_os_commands)) { $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); @@ -178,20 +178,20 @@ if ($what == 'postgresql') } } */ - if (!$errormsg && $cmddump) - { - dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); - } + if (!$errormsg && $cmddump) + { + dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); + } - if (!$errormsg) - { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; - } + if (!$errormsg) + { + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + } - $what = ''; // Clear to show message to run command + $what = ''; // Clear to show message to run command } @@ -200,20 +200,20 @@ if ($errormsg) setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); $resultstring = ''; - $resultstring .= '
    '.$langs->trans("Error")." : ".$errormsg.'
    '; + $resultstring .= '
    '.$langs->trans("Error")." : ".$errormsg.'
    '; - $_SESSION["commandbackupresult"] = $resultstring; + $_SESSION["commandbackupresult"] = $resultstring; } else { if ($what) { - setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
    '.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); + setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
    '.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); - $resultstring = '
    '; - $resultstring .= $langs->trans("BackupFileSuccessfullyCreated").'.
    '; - $resultstring .= $langs->trans("YouCanDownloadBackupFile"); - $resultstring .= '
    '; + $resultstring = '
    '; + $resultstring .= $langs->trans("BackupFileSuccessfullyCreated").'.
    '; + $resultstring .= $langs->trans("YouCanDownloadBackupFile"); + $resultstring .= '
    '; - $_SESSION["commandbackupresult"] = $resultstring; + $_SESSION["commandbackupresult"] = $resultstring; } /*else { diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index 28eaa2d9d54..590ff276831 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -59,8 +59,8 @@ $errormsg = ''; if ($action == 'delete') { - $filerelative = dol_sanitizeFileName(GETPOST('urlfile', 'alpha')); - $filepath = $conf->admin->dir_output.'/'.$filerelative; + $filerelative = dol_sanitizeFileName(GETPOST('urlfile', 'alpha')); + $filepath = $conf->admin->dir_output.'/'.$filerelative; $ret = dol_delete_file($filepath, 1); if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filerelative), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filerelative), null, 'errors'); @@ -76,16 +76,16 @@ if ($action == 'delete') $ExecTimeLimit = 1800; // 30mn if (!empty($ExecTimeLimit)) { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); } $MemoryLimit = 0; if (!empty($MemoryLimit)) { - @ini_set('memory_limit', $MemoryLimit); + @ini_set('memory_limit', $MemoryLimit); } $form = new Form($db); @@ -113,54 +113,54 @@ $utils = new Utils($db); if ($compression == 'zip') { $file .= '.zip'; - $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.back|\.old|\.log|[\\\/]temp[\\\/]|documents[\\\/]admin[\\\/]documents[\\\/])/i'); - if ($ret < 0) - { - if ($ret == -2) { - $langs->load("errors"); - $errormsg = $langs->trans("ErrNoZipEngine"); - } else { - $langs->load("errors"); - $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir); - } - } + $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.back|\.old|\.log|[\\\/]temp[\\\/]|documents[\\\/]admin[\\\/]documents[\\\/])/i'); + if ($ret < 0) + { + if ($ret == -2) { + $langs->load("errors"); + $errormsg = $langs->trans("ErrNoZipEngine"); + } else { + $langs->load("errors"); + $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir); + } + } } elseif (in_array($compression, array('gz', 'bz'))) { $userlogin = ($user->login ? $user->login : 'unknown'); $outputfile = $conf->admin->dir_temp.'/export_files.'.$userlogin.'.out'; // File used with popen method - $file .= '.tar'; - // We also exclude '/temp/' dir and 'documents/admin/documents' - $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dirname(DOL_DATA_ROOT)." ".basename(DOL_DATA_ROOT); + $file .= '.tar'; + // We also exclude '/temp/' dir and 'documents/admin/documents' + $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dirname(DOL_DATA_ROOT)." ".basename(DOL_DATA_ROOT); - $result = $utils->executeCLI($cmd, $outputfile); + $result = $utils->executeCLI($cmd, $outputfile); - $retval = $result['error']; - if ($result['result'] || !empty($retval)) - { - $langs->load("errors"); - dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); - $errormsg = 'Error tar generation return '.$retval; - } else { - if ($compression == 'gz') - { - $cmd = "gzip -f ".$outputdir."/".$file; - } - if ($compression == 'bz') - { - $cmd = "bzip2 -f ".$outputdir."/".$file; - } + $retval = $result['error']; + if ($result['result'] || !empty($retval)) + { + $langs->load("errors"); + dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); + $errormsg = 'Error tar generation return '.$retval; + } else { + if ($compression == 'gz') + { + $cmd = "gzip -f ".$outputdir."/".$file; + } + if ($compression == 'bz') + { + $cmd = "bzip2 -f ".$outputdir."/".$file; + } - $result = $utils->executeCLI($cmd, $outputfile); + $result = $utils->executeCLI($cmd, $outputfile); - $retval = $result['error']; - if ($result['result'] || !empty($retval)) - { - $errormsg = 'Error '.$compression.' generation return '.$retval; - unlink($outputdir."/".$file); - } - } + $retval = $result['error']; + if ($result['result'] || !empty($retval)) + { + $errormsg = 'Error '.$compression.' generation return '.$retval; + unlink($outputdir."/".$file); + } + } } if ($errormsg) diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 82111e0716d..00c4bdc36dd 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -76,11 +76,11 @@ $nowarray = dol_getdate($now); if (empty($date_start)) // We define date_start and date_end { - $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false); + $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false); } if (empty($date_end)) { - $date_end = dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']); + $date_end = dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']); } // Set $date_startmonth... $tmp = dol_getdate($date_start); @@ -104,14 +104,14 @@ $now = dol_now(); // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $date_start = -1; - $date_end = -1; - $search_code = ''; - $search_ip = ''; - $search_user = ''; - $search_desc = ''; - $search_ua = ''; - $search_prefix_session = ''; + $date_start = -1; + $date_end = -1; + $search_code = ''; + $search_ip = ''; + $search_user = ''; + $search_desc = ''; + $search_ua = ''; + $search_prefix_session = ''; } // Purge audit events @@ -144,7 +144,7 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) $result = $securityevent->create($user); if ($result > 0) { - $db->commit(); + $db->commit(); dol_syslog($text, LOG_WARNING); } else { $error++; @@ -219,16 +219,16 @@ if ($result) if ($date_endday) $param .= "&date_endday=".urlencode($date_endday); if ($date_endyear) $param .= "&date_endyear=".urlencode($date_endyear); - $langs->load('withdrawals'); - if ($num) - { - $center = ''.$langs->trans("Purge").''; - } + $langs->load('withdrawals'); + if ($num) + { + $center = ''.$langs->trans("Purge").''; + } print '
    '; print ''; - print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup', 0, '', '', $limit); + print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup', 0, '', '', $limit); if ($action == 'purge') { diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index aedc41e0b23..d8e0a0383a2 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -37,8 +37,8 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -192,7 +192,7 @@ if ($savehandler == 'files') { if (count($listofsessions)) { - print ''.$langs->trans("PurgeSessions").''; + print ''.$langs->trans("PurgeSessions").''; } } diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index c41b43b3b48..d450b5aa888 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -48,16 +48,16 @@ if (!empty($conf->syslog->enabled)) */ if ($action == 'purge' && !preg_match('/^confirm/i', $choice) && ($choice != 'allfiles' || $confirm == 'yes')) { - // Increase limit of time. Works only if we are not in safe mode - $ExecTimeLimit = 600; - if (!empty($ExecTimeLimit)) - { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); - } + // Increase limit of time. Works only if we are not in safe mode + $ExecTimeLimit = 600; + if (!empty($ExecTimeLimit)) + { + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); + } require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; $utils = new Utils($db); @@ -97,9 +97,9 @@ if (!empty($conf->syslog->enabled)) $filelogparam = $filelog; if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) { - $filelogparam = ''.$filelog.''; + $filelogparam = ''.$filelog.''; } print '> '.$langs->trans("PurgeDeleteLogFile", $filelogparam); print '

    '; diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index 27b53e8266e..f39766818f3 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -54,7 +54,7 @@ $version = '0.0'; if ($action == 'getlastversion') { - $result = getURLContent('http://sourceforge.net/projects/dolibarr/rss'); + $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); //var_dump($result['content']); $sfurl = simplexml_load_string($result['content']); } diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index c962a9fb776..edd5ca95026 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -235,7 +235,7 @@ print ''; $head = translation_prepare_head(); -dol_fiche_head($head, $mode, '', -1, ''); +print dol_get_fiche_head($head, $mode, '', -1, ''); if ($mode == 'overwrite') { @@ -547,7 +547,7 @@ if ($mode == 'searchkey') print '
    '; } -dol_fiche_end(); +print dol_get_fiche_end(); print "\n"; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 620efb0540e..ea39cc1dce9 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,6 +43,8 @@ $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); $value = GETPOST('value', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scandir', 'alpha'); $type = 'user'; @@ -60,7 +63,7 @@ if ($action == 'set_default') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->USER_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USER_ADDON_PDF_ODT', $conf->entity); + if ($conf->global->USER_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USER_ADDON_PDF_ODT', $conf->entity); } $res = true; } @@ -84,24 +87,24 @@ elseif ($action == 'setdoc') $res = true; } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } //Set hide closed customer into combox or select elseif ($action == 'sethideinactiveuser') @@ -132,7 +135,7 @@ print load_fiche_titre($langs->trans("UsersSetup"), $linkback, 'title_setup'); $head = user_admin_prepare_head(); -dol_fiche_head($head, 'card', $langs->trans("MenuUsersAndGroups"), -1, 'user'); +print dol_get_fiche_head($head, 'card', $langs->trans("MenuUsersAndGroups"), -1, 'user'); print ''; print ''; @@ -225,110 +228,110 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $dir = dol_buildpath($reldir."core/modules/user".$valdir); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + foreach (array('', '/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/user".$valdir); + 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); + 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); + 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; + $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 ''; + if ($modulequalified) + { + print ''; - // Active - if (in_array($name, $def)) - { - print ''; - } else { - print '"; - } + // Active + if (in_array($name, $def)) + { + print ''; + } else { + print '"; + } - // Defaut - print ''; + // Defaut + 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("FeaturesSupported").':'; - $htmltooltip .= '
    '.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
    '.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + // 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("FeaturesSupported").':'; + $htmltooltip .= '
    '.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
    '.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - print ''; + print ''; - // Preview - print ''; + // Preview + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print '
    '; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print '
    '; + 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 "'."\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 "'; - if ($conf->global->USER_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 ''; + if ($conf->global->USER_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 ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'contract').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'contract').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
    '; print "
    "; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index 9ae01790bb2..dd12584b276 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -57,7 +57,7 @@ if ($action == 'set_default') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity); + if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity); } $res = true; } @@ -81,24 +81,24 @@ elseif ($action == 'setdoc') $res = true; } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } /* * View @@ -113,7 +113,7 @@ print load_fiche_titre($langs->trans("UsersSetup"), $linkback, 'title_setup'); $head = user_admin_prepare_head(); -dol_fiche_head($head, 'usergroupcard', $langs->trans("MenuUsersAndGroups"), -1, 'user'); +print dol_get_fiche_head($head, 'usergroupcard', $langs->trans("MenuUsersAndGroups"), -1, 'user'); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -157,110 +157,110 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + foreach (array('', '/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir); + 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); + 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); + 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; + $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 ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->USERGROUP_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 ''; + // Defaut + print ''; + if ($conf->global->USERGROUP_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 ''; - // 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("FeaturesSupported").':'; - $htmltooltip .= '
    '.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
    '.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + // 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("FeaturesSupported").':'; + $htmltooltip .= '
    '.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
    '.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'contract').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'contract').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; print "
    "; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 19d71ebb1d9..208caf85666 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -401,7 +401,7 @@ $head[$h][1] = $langs->trans("Options"); $head[$h][2] = 'options'; $h++; -dol_fiche_head($head, 'website', '', -1); +print dol_get_fiche_head($head, 'website', '', -1); print ''.$langs->trans("WebsiteSetupDesc").'
    '; @@ -621,7 +621,7 @@ if ($id) } } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php index 1df7642b646..738fd5bc998 100644 --- a/htdocs/admin/website_options.php +++ b/htdocs/admin/website_options.php @@ -94,7 +94,7 @@ $head[$h][1] = $langs->trans("Options"); $head[$h][2] = 'options'; $h++; -dol_fiche_head($head, 'options', '', -1); +print dol_get_fiche_head($head, 'options', '', -1); if ($action == 'edit') @@ -140,7 +140,7 @@ if ($action == 'edit') } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index a8bcbcf8172..6bd3edca2b8 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -139,7 +139,7 @@ if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['w } // remove not available workflows (based on activated modules and global defined keys) -$workflowcodes = array_filter($workflowcodes, function ($var) { +$workflowcodes = array_filter($workflowcodes, function ($var) { return $var['enabled']; }); /* diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php index 22263b8b9ba..835a5485544 100644 --- a/htdocs/api/admin/explorer.php +++ b/htdocs/api/admin/explorer.php @@ -43,10 +43,10 @@ $langs->load("admin"); // Enable and test if module Api is enabled if (empty($conf->global->MAIN_MODULE_API)) { - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); - print $langs->trans("WarningModuleNotActive", 'Api').'.

    '; - print $langs->trans("ToActivateModule"); - exit; + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningModuleNotActive", 'Api').'.

    '; + print $langs->trans("ToActivateModule"); + exit; } @@ -61,45 +61,45 @@ $listofapis = array(); $modulesdir = dolGetModulesDirs(); foreach ($modulesdir as $dir) { - /* + /* * Search available module */ - //dol_syslog("Scan directory ".$dir." for API modules"); + //dol_syslog("Scan directory ".$dir." for API modules"); - $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) - { - $modulename = $reg[1]; + $handle = @opendir(dol_osencode($dir)); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) + { + $modulename = $reg[1]; - // Defined if module is enabled - $enabled = true; - $module = $part = $obj = strtolower(preg_replace('/^mod/i', '', $modulename)); - //if ($part == 'propale') $part='propal'; - if ($module == 'societe') { + // Defined if module is enabled + $enabled = true; + $module = $part = $obj = strtolower(preg_replace('/^mod/i', '', $modulename)); + //if ($part == 'propale') $part='propal'; + if ($module == 'societe') { $obj = 'thirdparty'; } - if ($module == 'categorie') { - $part = 'categories'; + if ($module == 'categorie') { + $part = 'categories'; $obj = 'category'; } - if ($module == 'facture') { - $part = 'compta/facture'; + if ($module == 'facture') { + $part = 'compta/facture'; $obj = 'facture'; } - if ($module == 'ficheinter') { - $obj = 'fichinter'; - $part = 'fichinter'; - $module = 'fichinter'; - } + if ($module == 'ficheinter') { + $obj = 'fichinter'; + $part = 'fichinter'; + $module = 'fichinter'; + } - if (empty($conf->$module->enabled)) $enabled = false; + if (empty($conf->$module->enabled)) $enabled = false; - if ($enabled) { - /* + if ($enabled) { + /* * If exists, load the API class for enable module * * Search files named api_.class.php into /htdocs//class directory @@ -107,25 +107,25 @@ foreach ($modulesdir as $dir) * @todo : take care of externals module! * @todo : use getElementProperties() function ? */ - $dir_part = DOL_DOCUMENT_ROOT.'/'.$part.'/class/'; + $dir_part = DOL_DOCUMENT_ROOT.'/'.$part.'/class/'; - $handle_part = @opendir(dol_osencode($dir_part)); - if (is_resource($handle_part)) - { - while (($file_searched = readdir($handle_part)) !== false) - { - if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $reg)) - { - $classname = ucwords($reg[1]); - require_once $dir_part.$file_searched; - if (class_exists($classname)) - { - dol_syslog("Found API classname=".$classname." into ".$dir); - $listofapis[] = $classname; - } - } + $handle_part = @opendir(dol_osencode($dir_part)); + if (is_resource($handle_part)) + { + while (($file_searched = readdir($handle_part)) !== false) + { + if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $reg)) + { + $classname = ucwords($reg[1]); + require_once $dir_part.$file_searched; + if (class_exists($classname)) + { + dol_syslog("Found API classname=".$classname." into ".$dir); + $listofapis[] = $classname; + } + } - /* + /* if (is_readable($dir_part.$file_searched) && preg_match("/^(api_.*)\.class\.php$/i",$file_searched,$reg)) { $classname=$reg[1]; @@ -150,12 +150,12 @@ foreach ($modulesdir as $dir) // //$listofapis[]=array('classname'=>$classname, 'fullpath'=>$file_searched); // } }*/ - } - } - } - } - } - } + } + } + } + } + } + } } //var_dump($listofapis); @@ -188,28 +188,28 @@ $oldclass = ''; print $langs->trans("ListOfAvailableAPIs").':
    '; foreach ($listofapis['v1'] as $key => $val) { - if ($key == 'login') continue; - if ($key == 'index') continue; + if ($key == 'login') continue; + if ($key == 'index') continue; - if ($key) - { - foreach ($val as $method => $val2) - { - $newclass = $val2['className']; + if ($key) + { + foreach ($val as $method => $val2) + { + $newclass = $val2['className']; - if (preg_match('/restler/i', $newclass)) continue; + if (preg_match('/restler/i', $newclass)) continue; - if ($oldclass != $newclass) - { - print "\n
    \n".$langs->trans("Class").': '.$newclass.'
    '."\n"; - $oldclass = $newclass; - } - //print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx
    \n"; - $url = $urlwithroot.'/api/index.php/'.$key; - $url .= '?api_key=token'; - print img_picto('', 'globe').' '.$method.' '.$url."
    \n"; - } - } + if ($oldclass != $newclass) + { + print "\n
    \n".$langs->trans("Class").': '.$newclass.'
    '."\n"; + $oldclass = $newclass; + } + //print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx
    \n"; + $url = $urlwithroot.'/api/index.php/'.$key; + $url .= '?api_key=token'; + print img_picto('', 'globe').' '.$method.' '.$url."
    \n"; + } + } } print '
    '; diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index a7eab61211d..18cbff2ca61 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -64,11 +64,11 @@ if ($action == 'setproductionmode') } } - if (!$error) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } + if (!$error) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } } else { dol_print_error($db); } @@ -112,13 +112,13 @@ print ''.$langs->trans("ApiProductionMode").''; $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ?false:true); if ($production_mode) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; } print ' '; print ''; @@ -157,10 +157,10 @@ print '
    '; print ''.$langs->trans("ApiExporerIs").':
    '; if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer')) { - $url = DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; - print img_picto('', 'globe').' '.$url."
    \n"; + $url = DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; + print img_picto('', 'globe').' '.$url."
    \n"; } else { - print $langs->trans("NotAvailableWithThisDistribution"); + print $langs->trans("NotAvailableWithThisDistribution"); } llxFooter(); diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 554edbb892e..80a608a0581 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,206 +30,204 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; class DolibarrApi { - /** - * @var DoliDb $db Database object - */ - protected $db; + /** + * @var DoliDb $db Database object + */ + protected $db; - /** - * @var Restler $r Restler object - */ - public $r; + /** + * @var Restler $r Restler object + */ + public $r; - /** - * Constructor - * - * @param DoliDb $db Database handler - * @param string $cachedir Cache dir - * @param boolean $refreshCache Update cache - */ - public function __construct($db, $cachedir = '', $refreshCache = false) - { - global $conf, $dolibarr_main_url_root; + /** + * Constructor + * + * @param DoliDb $db Database handler + * @param string $cachedir Cache dir + * @param boolean $refreshCache Update cache + */ + public function __construct($db, $cachedir = '', $refreshCache = false) + { + global $conf, $dolibarr_main_url_root; - if (empty($cachedir)) $cachedir = $conf->api->dir_temp; - Defaults::$cacheDirectory = $cachedir; + if (empty($cachedir)) $cachedir = $conf->api->dir_temp; + Defaults::$cacheDirectory = $cachedir; - $this->db = $db; - $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ? false : true); - $this->r = new Restler($production_mode, $refreshCache); + $this->db = $db; + $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ? false : true); + $this->r = new Restler($production_mode, $refreshCache); - $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - $urlwithouturlrootautodetect = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim(DOL_MAIN_URL_ROOT)); - $urlwithrootautodetect = $urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url + $urlwithouturlrootautodetect = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim(DOL_MAIN_URL_ROOT)); + $urlwithrootautodetect = $urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url - $this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect); - $this->r->setAPIVersion(1); - //$this->r->setSupportedFormats('json'); - //$this->r->setSupportedFormats('jsonFormat'); - } + $this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect); + $this->r->setAPIVersion(1); + //$this->r->setSupportedFormats('json'); + //$this->r->setSupportedFormats('jsonFormat'); + } - /** - * Executed method when API is called without parameter - * - * Display a short message an return a http code 200 - * - * @return array - */ - /* Disabled, most APIs does not share same signature for method index - function index() - { - return array( - 'success' => array( - 'code' => 200, - 'message' => __class__.' is up and running!' - ) - ); - }*/ + /** + * Executed method when API is called without parameter + * + * Display a short message an return a http code 200 + * + * @return array + */ + /* Disabled, most APIs does not share same signature for method index + function index() + { + return array( + 'success' => array( + 'code' => 200, + 'message' => __class__.' is up and running!' + ) + ); + }*/ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param object $object Object to clean - * @return array Array of cleaned object properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - // Remove $db object property for object - unset($object->db); - unset($object->isextrafieldmanaged); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + // Remove $db object property for object + unset($object->db); + unset($object->isextrafieldmanaged); unset($object->ismultientitymanaged); unset($object->restrictiononfksoc); unset($object->table_rowid); - // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses - unset($object->linkedObjects); + // Remove linkedObjects. We should already have linkedObjectsIds that avoid huge responses + unset($object->linkedObjects); - unset($object->fields); - unset($object->oldline); + unset($object->fields); + unset($object->oldline); - unset($object->error); - unset($object->errors); + unset($object->error); + unset($object->errors); - unset($object->ref_previous); - unset($object->ref_next); - unset($object->ref_int); + unset($object->ref_previous); + unset($object->ref_next); + unset($object->ref_int); - unset($object->projet); // Should be fk_project - unset($object->project); // Should be fk_project - unset($object->author); // Should be fk_user_author - unset($object->timespent_old_duration); - unset($object->timespent_id); - unset($object->timespent_duration); - unset($object->timespent_date); - unset($object->timespent_datehour); - unset($object->timespent_withhour); - unset($object->timespent_fk_user); - unset($object->timespent_note); - unset($object->fk_delivery_address); + unset($object->projet); // Should be fk_project + unset($object->project); // Should be fk_project + unset($object->author); // Should be fk_user_author + unset($object->timespent_old_duration); + unset($object->timespent_id); + unset($object->timespent_duration); + unset($object->timespent_date); + unset($object->timespent_datehour); + unset($object->timespent_withhour); + unset($object->timespent_fk_user); + unset($object->timespent_note); + unset($object->fk_delivery_address); - unset($object->statuts); - unset($object->statuts_short); - unset($object->statuts_logo); - unset($object->statuts_long); - unset($object->labelStatus); - unset($object->labelStatusShort); + unset($object->statuts); + unset($object->statuts_short); + unset($object->statuts_logo); + unset($object->statuts_long); + unset($object->labelStatus); + unset($object->labelStatusShort); - unset($object->stats_propale); - unset($object->stats_commande); - unset($object->stats_contrat); - unset($object->stats_facture); - unset($object->stats_commande_fournisseur); - unset($object->stats_reception); - unset($object->stats_mrptoconsume); - unset($object->stats_mrptoproduce); + unset($object->stats_propale); + unset($object->stats_commande); + unset($object->stats_contrat); + unset($object->stats_facture); + unset($object->stats_commande_fournisseur); + unset($object->stats_reception); + unset($object->stats_mrptoconsume); + unset($object->stats_mrptoproduce); - unset($object->element); - unset($object->fk_element); - unset($object->table_element); - unset($object->table_element_line); - unset($object->class_element_line); - unset($object->picto); + unset($object->element); + unset($object->fk_element); + unset($object->table_element); + unset($object->table_element_line); + unset($object->class_element_line); + unset($object->picto); - unset($object->fieldsforcombobox); + unset($object->fieldsforcombobox); - unset($object->skip_update_total); - unset($object->context); - unset($object->next_prev_filter); + unset($object->skip_update_total); + unset($object->context); + unset($object->next_prev_filter); - unset($object->region); - unset($object->region_code); + unset($object->region); + unset($object->region_code); - unset($object->libelle_statut); - unset($object->libelle_paiement); + unset($object->libelle_statut); + unset($object->libelle_paiement); - if ($object->table_element != 'ticket') { - unset($object->comments); - } + if ($object->table_element != 'ticket') { + unset($object->comments); + } - // Remove the $oldcopy property because it is not supported by the JSON - // encoder. The following error is generated when trying to serialize - // it: "Error encoding/decoding JSON: Type is not supported" - // Note: Event if this property was correctly handled by the JSON - // encoder, it should be ignored because keeping it would let the API - // have a very strange behavior: calling PUT and then GET on the same - // resource would give different results: - // PUT /objects/{id} -> returns object with oldcopy = previous version of the object - // GET /objects/{id} -> returns object with oldcopy empty - unset($object->oldcopy); + // Remove the $oldcopy property because it is not supported by the JSON + // encoder. The following error is generated when trying to serialize + // it: "Error encoding/decoding JSON: Type is not supported" + // Note: Event if this property was correctly handled by the JSON + // encoder, it should be ignored because keeping it would let the API + // have a very strange behavior: calling PUT and then GET on the same + // resource would give different results: + // PUT /objects/{id} -> returns object with oldcopy = previous version of the object + // GET /objects/{id} -> returns object with oldcopy empty + unset($object->oldcopy); - // If object has lines, remove $db property - if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { - $nboflines = count($object->lines); - for ($i = 0; $i < $nboflines; $i++) - { - $this->_cleanObjectDatas($object->lines[$i]); + // If object has lines, remove $db property + if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { + $nboflines = count($object->lines); + for ($i = 0; $i < $nboflines; $i++) + { + $this->_cleanObjectDatas($object->lines[$i]); - unset($object->lines[$i]->contact); - unset($object->lines[$i]->contact_id); - unset($object->lines[$i]->country); - unset($object->lines[$i]->country_id); - unset($object->lines[$i]->country_code); - unset($object->lines[$i]->mode_reglement_id); - unset($object->lines[$i]->mode_reglement_code); - unset($object->lines[$i]->mode_reglement); - unset($object->lines[$i]->cond_reglement_id); - unset($object->lines[$i]->cond_reglement_code); - unset($object->lines[$i]->cond_reglement); - unset($object->lines[$i]->fk_delivery_address); - unset($object->lines[$i]->fk_projet); - unset($object->lines[$i]->fk_project); - unset($object->lines[$i]->thirdparty); - unset($object->lines[$i]->user); - unset($object->lines[$i]->model_pdf); - unset($object->lines[$i]->modelpdf); - unset($object->lines[$i]->note_public); - unset($object->lines[$i]->note_private); - unset($object->lines[$i]->fk_incoterms); - unset($object->lines[$i]->label_incoterms); - unset($object->lines[$i]->location_incoterms); - unset($object->lines[$i]->name); - unset($object->lines[$i]->lastname); - unset($object->lines[$i]->firstname); - unset($object->lines[$i]->civility_id); - unset($object->lines[$i]->fk_multicurrency); - unset($object->lines[$i]->multicurrency_code); - unset($object->lines[$i]->shipping_method_id); - } - } - - if (!empty($object->thirdparty) && is_object($object->thirdparty)) - { - $this->_cleanObjectDatas($object->thirdparty); - } + unset($object->lines[$i]->contact); + unset($object->lines[$i]->contact_id); + unset($object->lines[$i]->country); + unset($object->lines[$i]->country_id); + unset($object->lines[$i]->country_code); + unset($object->lines[$i]->mode_reglement_id); + unset($object->lines[$i]->mode_reglement_code); + unset($object->lines[$i]->mode_reglement); + unset($object->lines[$i]->cond_reglement_id); + unset($object->lines[$i]->cond_reglement_code); + unset($object->lines[$i]->cond_reglement); + unset($object->lines[$i]->fk_delivery_address); + unset($object->lines[$i]->fk_projet); + unset($object->lines[$i]->fk_project); + unset($object->lines[$i]->thirdparty); + unset($object->lines[$i]->user); + unset($object->lines[$i]->model_pdf); + unset($object->lines[$i]->modelpdf); + unset($object->lines[$i]->note_public); + unset($object->lines[$i]->note_private); + unset($object->lines[$i]->fk_incoterms); + unset($object->lines[$i]->label_incoterms); + unset($object->lines[$i]->location_incoterms); + unset($object->lines[$i]->name); + unset($object->lines[$i]->lastname); + unset($object->lines[$i]->firstname); + unset($object->lines[$i]->civility_id); + unset($object->lines[$i]->fk_multicurrency); + unset($object->lines[$i]->multicurrency_code); + unset($object->lines[$i]->shipping_method_id); + } + } + if (!empty($object->thirdparty) && is_object($object->thirdparty)) { + $this->_cleanObjectDatas($object->thirdparty); + } return $object; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Check user access to a resource * @@ -240,12 +239,12 @@ class DolibarrApi * @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'. * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) - * @return bool + * @return bool * @throws RestException */ - protected static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') - { - // phpcs:enable + protected static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') + { + // phpcs:enable // Features/modules to check $featuresarray = array($resource); if (preg_match('/&/', $resource)) { @@ -260,9 +259,9 @@ class DolibarrApi } return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select); - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Return if a $sqlfilters parameter is valid * @@ -271,30 +270,30 @@ class DolibarrApi */ protected function _checkFilters($sqlfilters) { - // phpcs:enable - //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); - $tmp = $sqlfilters; - $ok = 0; - $i = 0; $nb = strlen($tmp); - $counter = 0; - while ($i < $nb) - { - if ($tmp[$i] == '(') $counter++; - if ($tmp[$i] == ')') $counter--; - if ($counter < 0) - { - $error = "Bad sqlfilters=".$sqlfilters; - dol_syslog($error, LOG_WARNING); - return false; - } - $i++; - } - return true; + // phpcs:enable + //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); + $tmp = $sqlfilters; + $ok = 0; + $i = 0; $nb = strlen($tmp); + $counter = 0; + while ($i < $nb) + { + if ($tmp[$i] == '(') $counter++; + if ($tmp[$i] == ')') $counter--; + if ($counter < 0) + { + $error = "Bad sqlfilters=".$sqlfilters; + dol_syslog($error, LOG_WARNING); + return false; + } + $i++; + } + return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Function to forge a SQL criteria * @@ -303,22 +302,22 @@ class DolibarrApi */ protected static function _forge_criteria_callback($matches) { - // phpcs:enable - global $db; + // phpcs:enable + global $db; - //dol_syslog("Convert matches ".$matches[1]); - if (empty($matches[1])) return ''; - $tmp = explode(':', $matches[1]); - if (count($tmp) < 3) return ''; + //dol_syslog("Convert matches ".$matches[1]); + if (empty($matches[1])) return ''; + $tmp = explode(':', $matches[1]); + if (count($tmp) < 3) return ''; - $tmpescaped = $tmp[2]; - $regbis = array(); - if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) - { - $tmpescaped = "'".$db->escape($regbis[1])."'"; - } else { - $tmpescaped = $db->escape($tmpescaped); - } - return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; + $tmpescaped = $tmp[2]; + $regbis = array(); + if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) + { + $tmpescaped = "'".$db->escape($regbis[1])."'"; + } else { + $tmpescaped = $db->escape($tmpescaped); + } + return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; } } diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 84f7bf303e7..e7b8ac8536b 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -52,7 +52,7 @@ class DolibarrApiAccess implements iAuthenticate /** * @var string $role user role */ - public static $role = 'user'; + public static $role = 'user'; /** * @var User $user Loggued user @@ -69,7 +69,7 @@ class DolibarrApiAccess implements iAuthenticate $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Check access * @@ -80,7 +80,7 @@ class DolibarrApiAccess implements iAuthenticate */ public function __isAllowed() { - // phpcs:enable + // phpcs:enable global $conf, $db; $login = ''; @@ -97,17 +97,17 @@ class DolibarrApiAccess implements iAuthenticate $api_key = ''; if (isset($_GET['api_key'])) // For backward compatibility { - // TODO Add option to disable use of api key on url. Return errors if used. - $api_key = $_GET['api_key']; + // TODO Add option to disable use of api key on url. Return errors if used. + $api_key = $_GET['api_key']; } if (isset($_GET['DOLAPIKEY'])) { - // TODO Add option to disable use of api key on url. Return errors if used. - $api_key = $_GET['DOLAPIKEY']; // With GET method + // TODO Add option to disable use of api key on url. Return errors if used. + $api_key = $_GET['DOLAPIKEY']; // With GET method } if (isset($_SERVER['HTTP_DOLAPIKEY'])) // Param DOLAPIKEY in header can be read with HTTP_DOLAPIKEY { - $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded) + $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded) } if ($api_key) @@ -149,7 +149,7 @@ class DolibarrApiAccess implements iAuthenticate if (!$login) { - throw new RestException(503, 'Error when searching login user from api key'); + throw new RestException(503, 'Error when searching login user from api key'); } $fuser = new User($this->db); $result = $fuser->fetch('', $login, '', 0, (empty($userentity) ? -1 : $conf->entity)); // If user is not entity 0, we search in working entity $conf->entity (that may have been forced to a different value than user entity) @@ -161,49 +161,49 @@ class DolibarrApiAccess implements iAuthenticate if ($fuser->socid) { static::$role = 'external'; - } + } if ($fuser->admin) { static::$role = 'admin'; - } - } else { - throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL)."); + } + } else { + throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL)."); } - $userClass::setCacheIdentifier(static::$role); - Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess'; - $requirefortest = static::$requires; - if (!is_array($requirefortest)) $requirefortest = explode(',', $requirefortest); - return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin'; + $userClass::setCacheIdentifier(static::$role); + Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess'; + $requirefortest = static::$requires; + if (!is_array($requirefortest)) $requirefortest = explode(',', $requirefortest); + return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * @return string string to be used with WWW-Authenticate header */ - public function __getWWWAuthenticateString() - { - // phpcs:enable - return ''; - } + public function __getWWWAuthenticateString() + { + // phpcs:enable + return ''; + } - /** - * Verify access - * - * @param array $m Properties of method - * - * @access private - * @return bool - */ - public static function verifyAccess(array $m) - { - $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) - ? $m['class']['DolibarrApiAccess']['properties']['requires'] - : false; + /** + * Verify access + * + * @param array $m Properties of method + * + * @access private + * @return bool + */ + public static function verifyAccess(array $m) + { + $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) + ? $m['class']['DolibarrApiAccess']['properties']['requires'] + : false; - return $requires - ? static::$role == 'admin' || in_array(static::$role, (array) $requires) - : true; - } + return $requires + ? static::$role == 'admin' || in_array(static::$role, (array) $requires) + : true; + } } diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 9605f46f219..9408898a984 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -229,9 +229,7 @@ class Documents extends DolibarrApi if ($result <= 0) { throw new RestException(500, 'Error generating document'); } - } - else - { + } else { throw new RestException(403, 'Generation not available for this modulepart'); } @@ -277,6 +275,8 @@ class Documents extends DolibarrApi } $id = (empty($id) ? 0 : $id); + $recursive = 0; + $type = 'files'; if ($modulepart == 'societe' || $modulepart == 'thirdparty') { @@ -409,7 +409,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->fournisseur->dir_output."/facture/".get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').dol_sanitizeFileName($object->ref); } - elseif ($modulepart == 'produit' || $modulepart == 'product') + elseif ($modulepart == 'produit' || $modulepart == 'product') { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -419,9 +419,9 @@ class Documents extends DolibarrApi $object = new Product($this->db); $result = $object->fetch($id, $ref); - if ($result==0) { + if ($result == 0) { throw new RestException(404, 'Product not found'); - } elseif ($result<0) { + } elseif ($result < 0) { throw new RestException(500, 'Error while fetching object: '.$object->error); } @@ -474,15 +474,29 @@ class Documents extends DolibarrApi } $upload_dir = $conf->categorie->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/".dol_sanitizeFileName($object->ref); - } - else - { + } elseif ($modulepart == 'ecm') { + throw new RestException(500, 'Modulepart Ecm not implemented yet.'); + // // require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; + + // if (!DolibarrApiAccess::$user->rights->ecm->read) { + // throw new RestException(401); + // } + + // // $object = new EcmDirectory($this->db); + // // $result = $object->fetch($ref); + // // if (!$result) { + // // throw new RestException(404, 'EcmDirectory not found'); + // // } + // $upload_dir = $conf->ecm->dir_output; + // $type = 'all'; + // $recursive = 0; + } else { throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, $type, $recursive, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); if (empty($filearray)) { - throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->Ref) ? ' or Ref '.$object->ref : '').' does not return any document.'); + throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->ref) ? ' or Ref '.$object->ref : '').' does not return any document.'); } return $filearray; @@ -517,7 +531,7 @@ class Documents extends DolibarrApi * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) * @param int $overwriteifexists Overwrite file if exists (1 by default) - * @return string + * @return string * * @throws RestException 400 * @throws RestException 401 @@ -594,9 +608,7 @@ class Documents extends DolibarrApi { $tmpreldir = dol_sanitizeFileName($object->project->ref).'/'; } - } - else - { + } else { throw new RestException(500, 'Error while fetching Task '.$ref); } } @@ -616,9 +628,13 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $object = new Adherent($this->db); } - // TODO Implement additional moduleparts - else + elseif ($modulepart == 'proposal' || $modulepart == 'propal' || $modulepart == 'propale') { + $modulepart = 'propale'; + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $object = new Propal($this->db); + } else { + // TODO Implement additional moduleparts throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } @@ -629,7 +645,7 @@ class Documents extends DolibarrApi if ($result == 0) { throw new RestException(404, "Object with ref '".$ref."' was not found."); - } + } elseif ($result < 0) { throw new RestException(500, 'Error while fetching object: '.$object->error); @@ -656,9 +672,7 @@ class Documents extends DolibarrApi { throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); } - } - else - { + } else { if ($modulepart == 'invoice') $modulepart = 'facture'; if ($modulepart == 'member') $modulepart = 'adherent'; @@ -678,7 +692,7 @@ class Documents extends DolibarrApi if (dol_mkdir($upload_dir) < 0) // needed by products { - throw new RestException(500, 'Error while trying to create directory.'); + throw new RestException(500, 'Error while trying to create directory.'); } $destfile = $upload_dir.'/'.$original_file; @@ -696,20 +710,16 @@ class Documents extends DolibarrApi } $fhandle = @fopen($destfiletmp, 'w'); - if ($fhandle) - { + if ($fhandle) { $nbofbyteswrote = fwrite($fhandle, $newfilecontent); fclose($fhandle); @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); - } - else - { + } else { throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); } $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); - if (!$result) - { + if (!$result) { throw new RestException(500, "Failed to move file into '".$destfile."'"); } @@ -731,63 +741,63 @@ class Documents extends DolibarrApi */ public function delete($modulepart, $original_file) { - global $conf, $langs; + global $conf, $langs; - if (empty($modulepart)) { - throw new RestException(400, 'bad value for parameter modulepart'); - } - if (empty($original_file)) { - throw new RestException(400, 'bad value for parameter original_file'); - } + if (empty($modulepart)) { + throw new RestException(400, 'bad value for parameter modulepart'); + } + if (empty($original_file)) { + throw new RestException(400, 'bad value for parameter original_file'); + } - //--- Finds and returns the document - $entity = $conf->entity; + //--- Finds and returns the document + $entity = $conf->entity; - // Special cases that need to use get_exdir to get real dir of object - // If future, all object should use this to define path of documents. - /* + // Special cases that need to use get_exdir to get real dir of object + // If future, all object should use this to define path of documents. + /* $tmpreldir = ''; if ($modulepart == 'supplier_invoice') { $tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier'); } $relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); */ - $relativefile = $original_file; + $relativefile = $original_file; - $check_access = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'read'); - $accessallowed = $check_access['accessallowed']; - $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; - $original_file = $check_access['original_file']; + $check_access = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'read'); + $accessallowed = $check_access['accessallowed']; + $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; + $original_file = $check_access['original_file']; - if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { - throw new RestException(401); - } - if (!$accessallowed) { - throw new RestException(401); - } + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { + throw new RestException(401); + } + if (!$accessallowed) { + throw new RestException(401); + } - $filename = basename($original_file); - $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset + $filename = basename($original_file); + $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset - if (!file_exists($original_file_osencoded)) - { - dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); - throw new RestException(404, 'File not found'); - } + if (!file_exists($original_file_osencoded)) + { + dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); + throw new RestException(404, 'File not found'); + } - if (@unlink($original_file_osencoded)) { - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Document deleted' - ) - ); - } + if (@unlink($original_file_osencoded)) { + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Document deleted' + ) + ); + } - throw new RestException(401); + throw new RestException(401); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Validate fields before create or update object * @@ -795,9 +805,9 @@ class Documents extends DolibarrApi * @return array * @throws RestException */ - private function _validate_file($data) - { - // phpcs:enable + private function _validate_file($data) + { + // phpcs:enable $result = array(); foreach (Documents::$DOCUMENT_FIELDS as $field) { if (!isset($data[$field])) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 8627808a679..cb2fdd54d66 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -26,14 +26,14 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; class Login { - /** - * Constructor of the class - */ - public function __construct() - { - global $db; - $this->db = $db; - } + /** + * Constructor of the class + */ + public function __construct() + { + global $db; + $this->db = $db; + } /** * Login @@ -46,21 +46,21 @@ class Login * @param string $password User password * @param string $entity Entity (when multicompany module is used). '' means 1=first company. * @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access) - * @return array Response status and user token - * + * @return array Response status and user token + * * @throws RestException 403 * @throws RestException 500 * * @url GET / * @url POST / */ - public function index($login, $password, $entity = '', $reset = 0) - { - global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; + public function index($login, $password, $entity = '', $reset = 0) + { + global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; - // TODO Remove the API login. The token must be generated from backoffice only. + // TODO Remove the API login. The token must be generated from backoffice only. - // Authentication mode + // Authentication mode if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'dolibarr'; // Authentication mode: forceuser @@ -108,22 +108,22 @@ class Login throw new RestException(403, 'User need write permission on itself to reset its API token'); } - // Generate token for user - $token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY, 1); + // Generate token for user + $token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY, 1); - // We store API token into database - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET api_key = '".$this->db->escape($token)."'"; - $sql .= " WHERE login = '".$this->db->escape($login)."'"; + // We store API token into database + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET api_key = '".$this->db->escape($token)."'"; + $sql .= " WHERE login = '".$this->db->escape($login)."'"; - dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log - $result = $this->db->query($sql); - if (!$result) - { - throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror()); - } + dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log + $result = $this->db->query($sql); + if (!$result) + { + throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror()); + } } else { - $token = $tmpuser->api_key; + $token = $tmpuser->api_key; } //return token @@ -131,9 +131,9 @@ class Login 'success' => array( 'code' => 200, 'token' => $token, - 'entity' => $tmpuser->entity, - 'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') + 'entity' => $tmpuser->entity, + 'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') ) ); - } + } } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 8177fbf7e1e..4516d2e1d45 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2017 Regis Houssin * Copyright (C) 2017 Neil Orley - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2018-2020 Thibault FOUCART * * @@ -525,8 +525,8 @@ class Setup extends DolibarrApi /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { @@ -1634,7 +1634,7 @@ class Setup extends DolibarrApi $xmlarray = getURLContent($xmlremote); // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) - if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') + if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; //print "xmlfilestart".$xmlfile."endxmlfile"; diff --git a/htdocs/api/class/api_status.class.php b/htdocs/api/class/api_status.class.php index 45c69e318e0..6c80e838f0a 100644 --- a/htdocs/api/class/api_status.class.php +++ b/htdocs/api/class/api_status.class.php @@ -26,21 +26,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; */ class Status { - /** - * Get status (Dolibarr version) - * - * @return array - */ - public function index() - { - global $conf; + /** + * Get status (Dolibarr version) + * + * @return array + */ + public function index() + { + global $conf; - return array( - 'success' => array( - 'code' => 200, - 'dolibarr_version' => DOL_VERSION, - 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED) ? '0' : $conf->global->MAIN_ONLY_LOGIN_ALLOWED), - ), - ); - } + return array( + 'success' => array( + 'code' => 200, + 'dolibarr_version' => DOL_VERSION, + 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED) ? '0' : $conf->global->MAIN_ONLY_LOGIN_ALLOWED), + ), + ); + } } diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 1ae504f523a..2fba9fbb554 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -69,22 +69,22 @@ if (!empty($conf->global->MAIN_NGINX_FIX)) // Enable and test if module Api is enabled if (empty($conf->global->MAIN_MODULE_API)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); - print $langs->trans("WarningModuleNotActive", 'Api').'.

    '; - print $langs->trans("ToActivateModule"); - //session_destroy(); - exit(0); + $langs->load("admin"); + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningModuleNotActive", 'Api').'.

    '; + print $langs->trans("ToActivateModule"); + //session_destroy(); + exit(0); } // Test if explorer is not disabled if (preg_match('/api\/index\.php\/explorer/', $url) && !empty($conf->global->API_EXPLORER_DISABLED)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); - print $langs->trans("WarningAPIExplorerDisabled").'.

    '; - //session_destroy(); - exit(0); + $langs->load("admin"); + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningAPIExplorerDisabled").'.

    '; + //session_destroy(); + exit(0); } @@ -114,7 +114,7 @@ preg_match('/index\.php\/([^\/]+)(.*)$/', $url, $reg); $refreshcache = (empty($conf->global->API_PRODUCTION_DO_NOT_ALWAYS_REFRESH_CACHE) ? true : false); if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { - $refreshcache = true; + $refreshcache = true; } $api = new DolibarrApi($db, '', $refreshcache); @@ -150,104 +150,104 @@ if (!empty($conf->global->API_RESTRICT_ON_IP)) // Call Explorer file for all APIs definitions (this part is slow) if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { - // Scan all API files to load them + // Scan all API files to load them - $listofapis = array(); + $listofapis = array(); - $modulesdir = dolGetModulesDirs(); - foreach ($modulesdir as $dir) - { - // Search available module - dol_syslog("Scan directory ".$dir." for module descriptor files, then search for API files"); + $modulesdir = dolGetModulesDirs(); + foreach ($modulesdir as $dir) + { + // Search available module + dol_syslog("Scan directory ".$dir." for module descriptor files, then search for API files"); - $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $regmod = array(); - if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod)) - { - $module = strtolower($regmod[1]); - $moduledirforclass = getModuleDirForApiClass($module); - $modulenameforenabled = $module; - if ($module == 'propale') { $modulenameforenabled = 'propal'; } - if ($module == 'supplierproposal') { $modulenameforenabled = 'supplier_proposal'; } - if ($module == 'ficheinter') { $modulenameforenabled = 'ficheinter'; } + $handle = @opendir(dol_osencode($dir)); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $regmod = array(); + if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod)) + { + $module = strtolower($regmod[1]); + $moduledirforclass = getModuleDirForApiClass($module); + $modulenameforenabled = $module; + if ($module == 'propale') { $modulenameforenabled = 'propal'; } + if ($module == 'supplierproposal') { $modulenameforenabled = 'supplier_proposal'; } + if ($module == 'ficheinter') { $modulenameforenabled = 'ficheinter'; } - dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass); + dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass); - // Defined if module is enabled - $enabled = true; - if (empty($conf->$modulenameforenabled->enabled)) $enabled = false; + // Defined if module is enabled + $enabled = true; + if (empty($conf->$modulenameforenabled->enabled)) $enabled = false; - if ($enabled) - { - // If exists, load the API class for enable module - // Search files named api_.class.php into /htdocs//class directory - // @todo : use getElementProperties() function ? - $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/'); + if ($enabled) + { + // If exists, load the API class for enable module + // Search files named api_.class.php into /htdocs//class directory + // @todo : use getElementProperties() function ? + $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/'); - $handle_part = @opendir(dol_osencode($dir_part)); - if (is_resource($handle_part)) - { - while (($file_searched = readdir($handle_part)) !== false) - { - if ($file_searched == 'api_access.class.php') continue; + $handle_part = @opendir(dol_osencode($dir_part)); + if (is_resource($handle_part)) + { + while (($file_searched = readdir($handle_part)) !== false) + { + if ($file_searched == 'api_access.class.php') continue; - $regapi = array(); - if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) - { - $classname = ucwords($regapi[1]); - $classname = str_replace('_', '', $classname); - require_once $dir_part.$file_searched; - if (class_exists($classname.'Api')) - { - //dol_syslog("Found API by index.php: classname=".$classname."Api for module ".$dir." into ".$dir_part.$file_searched); - $listofapis[strtolower($classname.'Api')] = $classname.'Api'; - } elseif (class_exists($classname)) - { - //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); - $listofapis[strtolower($classname)] = $classname; - } else { - dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); - } - } - } - } - } - } - } - } - } + $regapi = array(); + if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) + { + $classname = ucwords($regapi[1]); + $classname = str_replace('_', '', $classname); + require_once $dir_part.$file_searched; + if (class_exists($classname.'Api')) + { + //dol_syslog("Found API by index.php: classname=".$classname."Api for module ".$dir." into ".$dir_part.$file_searched); + $listofapis[strtolower($classname.'Api')] = $classname.'Api'; + } elseif (class_exists($classname)) + { + //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); + $listofapis[strtolower($classname)] = $classname; + } else { + dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); + } + } + } + } + } + } + } + } + } - // Sort the classes before adding them to Restler. - // The Restler API Explorer shows the classes in the order they are added and it's a mess if they are not sorted. - asort($listofapis); - foreach ($listofapis as $apiname => $classname) - { - $api->r->addAPIClass($classname, $apiname); - } - //var_dump($api->r); + // Sort the classes before adding them to Restler. + // The Restler API Explorer shows the classes in the order they are added and it's a mess if they are not sorted. + asort($listofapis); + foreach ($listofapis as $apiname => $classname) + { + $api->r->addAPIClass($classname, $apiname); + } + //var_dump($api->r); } // Call one APIs or one definition of an API $regbis = array(); if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root'))) { - $moduleobject = $reg[1]; - if ($moduleobject == 'explorer') // If we call page to explore details of a service - { - $moduleobject = $regbis[2]; - } + $moduleobject = $reg[1]; + if ($moduleobject == 'explorer') // If we call page to explore details of a service + { + $moduleobject = $regbis[2]; + } - $moduleobject = strtolower($moduleobject); - $moduledirforclass = getModuleDirForApiClass($moduleobject); + $moduleobject = strtolower($moduleobject); + $moduledirforclass = getModuleDirForApiClass($moduleobject); - // Load a dedicated API file - dol_syslog("Load a dedicated API file moduleobject=".$moduleobject." moduledirforclass=".$moduledirforclass); + // Load a dedicated API file + dol_syslog("Load a dedicated API file moduleobject=".$moduleobject." moduledirforclass=".$moduledirforclass); - $tmpmodule = $moduleobject; + $tmpmodule = $moduleobject; if ($tmpmodule != 'api') $tmpmodule = preg_replace('/api$/i', '', $tmpmodule); $classfile = str_replace('_', '', $tmpmodule); @@ -274,7 +274,7 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && if ($dir_part_file) $res = include_once $dir_part_file; if (!$res) { - dol_syslog('Failed to make include_once '.$dir_part_file, LOG_WARNING); + dol_syslog('Failed to make include_once '.$dir_part_file, LOG_WARNING); print 'API not found (failed to include API file)'; header('HTTP/1.1 501 API not found (failed to include API file)'); //session_destroy(); diff --git a/htdocs/asset/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php index 0bdbff93569..3334610b927 100644 --- a/htdocs/asset/admin/assets_extrafields.php +++ b/htdocs/asset/admin/assets_extrafields.php @@ -66,11 +66,11 @@ print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup'); $head = asset_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Assets"), -1, 'generic'); +print dol_get_fiche_head($head, 'attributes', $langs->trans("Assets"), -1, 'generic'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/asset/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php index ba42a3374dc..e17d421437d 100644 --- a/htdocs/asset/admin/assets_type_extrafields.php +++ b/htdocs/asset/admin/assets_type_extrafields.php @@ -65,11 +65,11 @@ print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup'); $head = asset_admin_prepare_head(); -dol_fiche_head($head, 'attributes_type', $langs->trans("Assets"), -1, 'generic'); +print dol_get_fiche_head($head, 'attributes_type', $langs->trans("Assets"), -1, 'generic'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') @@ -91,7 +91,7 @@ if ($action == 'create') print "
    "; print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -104,7 +104,7 @@ if ($action == 'edit' && !empty($attrname)) print "
    "; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 64e2bc2b5ad..6fec16ef0a0 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -60,7 +60,7 @@ print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup'); $head = asset_admin_prepare_head(); -dol_fiche_head($head, 'settings', $langs->trans("Assets"), -1, 'generic'); +print dol_get_fiche_head($head, 'settings', $langs->trans("Assets"), -1, 'generic'); if ($action == 'edit') @@ -105,7 +105,7 @@ if ($action == 'edit') print ''; } -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 7ef3d9c011e..0fa78edf9ce 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -168,7 +168,7 @@ if ($action == 'create') if ($backtopage) print ''; if ($backtopageforcancel) print ''; - dol_fiche_head(array(), ''); + print dol_get_fiche_head(array(), ''); print ''."\n"; @@ -180,7 +180,7 @@ if ($action == 'create') print '
    '."\n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -206,7 +206,7 @@ if (($id || $ref) && $action == 'edit') if ($backtopage) print ''; if ($backtopageforcancel) print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print ''."\n"; @@ -218,7 +218,7 @@ if (($id || $ref) && $action == 'edit') print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '   '; @@ -233,7 +233,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $res = $object->fetch_optionals(); $head = asset_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("Asset"), -1, $object->picto); + print dol_get_fiche_head($head, 'card', $langs->trans("Asset"), -1, $object->picto); $formconfirm = ''; @@ -297,7 +297,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); // Buttons for actions diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 2cc48489f7f..25cac778264 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -113,44 +113,44 @@ class Asset extends CommonObject */ public $entity; - /** - * @var string Asset label - */ - public $label; + /** + * @var string Asset label + */ + public $label; public $amount; /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; /** * @var string description */ public $description; - public $note_public; - public $note_private; - /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; public $tms; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_creat; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; + /** + * @var string import key + */ public $import_key; /** @@ -381,7 +381,7 @@ class Asset extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -391,12 +391,14 @@ class Asset extends CommonObject */ public static function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load("contracts"); + $labelStatus = array(); $labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled'); $labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); + $labelStatusShort = array(); $labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Disabled'); $labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled'); @@ -407,7 +409,7 @@ class Asset extends CommonObject } /** - * Charge les informations d'ordre info dans l'objet commande + * Load info into asset object * * @param int $id Id of order * @return void diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index db2407a9376..5af5f3d7591 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -87,7 +87,7 @@ class AssetType extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -100,8 +100,8 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - public function create($user, $notrigger = 0) - { + public function create($user, $notrigger = 0) + { global $conf; $error = 0; @@ -164,7 +164,7 @@ class AssetType extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Met a jour en base donnees du type @@ -173,7 +173,7 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - public function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $hookmanager; @@ -299,7 +299,7 @@ class AssetType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of asset's type * @@ -307,7 +307,7 @@ class AssetType extends CommonObject */ public function liste_array() { - // phpcs:enable + // phpcs:enable global $conf, $langs; $assettypes = array(); @@ -424,8 +424,8 @@ class AssetType extends CommonObject * * @return void */ - public function initAsSpecimen() - { + public function initAsSpecimen() + { global $conf, $user, $langs; // Initialize parameters @@ -440,15 +440,15 @@ class AssetType extends CommonObject $this->asset = array( $user->id => $user ); - } + } - /** - * getLibStatut - * - * @return string Return status of a type of asset - */ - public function getLibStatut() - { - return ''; - } + /** + * getLibStatut + * + * @return string Return status of a type of asset + */ + public function getLibStatut() + { + return ''; + } } diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index b43ec8d40cf..4c2e36aed9a 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -103,7 +103,7 @@ if ($object->id) if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = asset_prepare_head($object); - dol_fiche_head($head, 'document', $langs->trans("Asset"), -1, 'generic'); + print dol_get_fiche_head($head, 'document', $langs->trans("Asset"), -1, 'generic'); // Build file list @@ -135,7 +135,7 @@ if ($object->id) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'asset'; //$permission = $user->rights->asset->create; diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php index 801a7c85b36..d211cf0dbad 100644 --- a/htdocs/asset/info.php +++ b/htdocs/asset/info.php @@ -62,7 +62,7 @@ $object->info($id); $head = asset_prepare_head($object); -dol_fiche_head($head, 'info', $langs->trans("Asset"), -1, 'generic'); +print dol_get_fiche_head($head, 'info', $langs->trans("Asset"), -1, 'generic'); $linkback = ''.$langs->trans("BackToList").''; @@ -82,7 +82,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index d9bfea71510..cffcc8a962d 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -339,7 +339,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort $topicmail = "SendAssetsRef"; $modelmail = "asset"; $objecttmp = new Asset($db); -$trackid = 'xxxx'.$object->id; +$trackid = 'asset'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) @@ -386,7 +386,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index f19249ce1d2..514e05bff72 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -85,7 +85,7 @@ if ($id > 0 || !empty($ref)) $head = asset_prepare_head($object); - dol_fiche_head($head, 'note', $langs->trans("Asset"), -1, 'generic'); + print dol_get_fiche_head($head, 'note', $langs->trans("Asset"), -1, 'generic'); // Object card // ------------------------------------------------------------ @@ -146,7 +146,7 @@ if ($id > 0 || !empty($ref)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 1045e9135ee..28f2ce59df0 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -196,7 +196,7 @@ llxHeader('', $langs->trans("AssetsTypeSetup"), $helpurl); // List of asset type if (!$rowid && $action != 'create' && $action != 'edit') { - //dol_fiche_head(''); + //print dol_get_fiche_head(''); $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; @@ -324,7 +324,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_head(''); + print dol_get_fiche_head(''); print ''; print ''; @@ -382,7 +382,7 @@ if ($action == 'create') print ''; print "
    \n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -416,7 +416,7 @@ if ($rowid > 0) $head = asset_type_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("AssetType"), -1, 'setup'); + print dol_get_fiche_head($head, 'card', $langs->trans("AssetType"), -1, 'setup'); $linkback = ''.$langs->trans("BackToList").''; @@ -490,7 +490,7 @@ if ($rowid > 0) print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Buttons @@ -533,7 +533,7 @@ if ($rowid > 0) print ''; print ''; - dol_fiche_head($head, 'card', $langs->trans("AssetsType"), -1, 'setup'); + print dol_get_fiche_head($head, 'card', $langs->trans("AssetsType"), -1, 'setup'); print ''; @@ -595,7 +595,7 @@ if ($rowid > 0) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '   '; diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/asterisk/cidlookup.php index 87aaeb6d46f..7a3660e350e 100644 --- a/htdocs/asterisk/cidlookup.php +++ b/htdocs/asterisk/cidlookup.php @@ -35,8 +35,8 @@ $notfound = $langs->trans("Unknown"); // Security check if (empty($conf->clicktodial->enabled)) { - print "Error: Module Click to dial is not enabled.\n"; - exit; + print "Error: Module Click to dial is not enabled.\n"; + exit; } // Check parameters diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index ecc7c4fee6c..0a9ac82ce23 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -44,10 +44,10 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); */ function llxHeader() { - print ''."\n"; - print ''."\n"; - print 'Asterisk redirection from Dolibarr...'."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print 'Asterisk redirection from Dolibarr...'."\n"; + print ''."\n"; } /** @@ -58,7 +58,7 @@ function llxHeader() */ function llxFooter() { - print "\n".''."\n"; + print "\n".''."\n"; } require_once '../main.inc.php'; @@ -69,8 +69,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Security check if (empty($conf->clicktodial->enabled)) { - accessforbidden(); - exit; + accessforbidden(); + exit; } @@ -146,46 +146,46 @@ $number = strtolower($called); $pos = strpos($number, "local"); if (!empty($number)) { - if ($pos === false) - { - $errno = 0; - $errstr = 0; - $strCallerId = "Dolibarr call $found <".strtolower($number).">"; - $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10); - if (!$oSocket) - { - print ''."\n"; - $txt = "Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)
    \n"; - print $txt; - dol_syslog($txt, LOG_ERR); - $txt = $errstr." (".$errno.")
    \n"; - print $txt; - dol_syslog($txt, LOG_ERR); - print ''."\n"; - } else { - $txt = "Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login; - dol_syslog($txt); - print ''."\n"; - print ''; - fputs($oSocket, "Action: login\r\n"); - fputs($oSocket, "Events: off\r\n"); - fputs($oSocket, "Username: $login\r\n"); - fputs($oSocket, "Secret: $password\r\n\r\n"); - fputs($oSocket, "Action: originate\r\n"); - fputs($oSocket, "Channel: ".$channel.$caller."\r\n"); - fputs($oSocket, "WaitTime: $strWaitTime\r\n"); - fputs($oSocket, "CallerId: $strCallerId\r\n"); - fputs($oSocket, "Exten: ".$prefix.$number."\r\n"); - fputs($oSocket, "Context: $strContext\r\n"); - fputs($oSocket, "Priority: $strPriority\r\n\r\n"); - fputs($oSocket, "Action: Logoff\r\n\r\n"); - sleep(2); - fclose($oSocket); - print ''."\n"; - } - } + if ($pos === false) + { + $errno = 0; + $errstr = 0; + $strCallerId = "Dolibarr call $found <".strtolower($number).">"; + $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10); + if (!$oSocket) + { + print ''."\n"; + $txt = "Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)
    \n"; + print $txt; + dol_syslog($txt, LOG_ERR); + $txt = $errstr." (".$errno.")
    \n"; + print $txt; + dol_syslog($txt, LOG_ERR); + print ''."\n"; + } else { + $txt = "Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login; + dol_syslog($txt); + print ''."\n"; + print ''; + fputs($oSocket, "Action: login\r\n"); + fputs($oSocket, "Events: off\r\n"); + fputs($oSocket, "Username: $login\r\n"); + fputs($oSocket, "Secret: $password\r\n\r\n"); + fputs($oSocket, "Action: originate\r\n"); + fputs($oSocket, "Channel: ".$channel.$caller."\r\n"); + fputs($oSocket, "WaitTime: $strWaitTime\r\n"); + fputs($oSocket, "CallerId: $strCallerId\r\n"); + fputs($oSocket, "Exten: ".$prefix.$number."\r\n"); + fputs($oSocket, "Context: $strContext\r\n"); + fputs($oSocket, "Priority: $strPriority\r\n\r\n"); + fputs($oSocket, "Action: Logoff\r\n\r\n"); + sleep(2); + fclose($oSocket); + print ''."\n"; + } + } } else { - print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx'; + print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx'; } // End of page diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index dabd05bf745..8a513034a4a 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -148,7 +148,7 @@ if ($action == 'builddoc') $module = new $classname($db); if ($generator != 'tcpdfbarcode') { - // May be phpbarcode + // May be phpbarcode $template = 'standardlabel'; $is2d = false; if ($module->encodingIsSupported($encoding)) @@ -178,19 +178,19 @@ if ($action == 'builddoc') { // List of values to scan for a replacement $substitutionarray = array( - '%LOGIN%' => $user->login, - '%COMPANY%' => $mysoc->name, - '%ADDRESS%' => $mysoc->address, - '%ZIP%' => $mysoc->zip, - '%TOWN%' => $mysoc->town, - '%COUNTRY%' => $mysoc->country, - '%COUNTRY_CODE%' => $mysoc->country_code, - '%EMAIL%' => $mysoc->email, - '%YEAR%' => $year, - '%MONTH%' => $month, - '%DAY%' => $day, - '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, - '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", + '%LOGIN%' => $user->login, + '%COMPANY%' => $mysoc->name, + '%ADDRESS%' => $mysoc->address, + '%ZIP%' => $mysoc->zip, + '%TOWN%' => $mysoc->town, + '%COUNTRY%' => $mysoc->country, + '%COUNTRY_CODE%' => $mysoc->country_code, + '%EMAIL%' => $mysoc->email, + '%YEAR%' => $year, + '%MONTH%' => $month, + '%DAY%' => $day, + '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, + '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", ); complete_substitutions_array($substitutionarray, $langs); @@ -291,8 +291,8 @@ print '
    '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; - print '
    '; - print '
    '; - $form->select_produits(GETPOST('productid', 'int'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); - print '   '; - print '
    '; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; + print '
    '; + print '
    '; + $form->select_produits(GETPOST('productid', 'int'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); + print '   '; + print '
    '; } if (!empty($user->rights->societe->lire)) { - print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; - print '
    '; - print '
    '; - print $form->select_company(GETPOST('socid', 'int'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); - print '   '; - print '
    '; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; + print '
    '; + print '
    '; + print $form->select_company(GETPOST('socid', 'int'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); + print '   '; + print '
    '; } print '
    '; diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index 051f8bb049a..b6ce9cda1bc 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -89,7 +89,7 @@ print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLo if (GETPOST('withtab', 'alpha')) { $head = blockedlogadmin_prepare_head(); - dol_fiche_head($head, 'blockedlog', '', -1); + print dol_get_fiche_head($head, 'blockedlog', '', -1); } @@ -170,7 +170,7 @@ print ''; if (GETPOST('withtab', 'alpha')) { - dol_fiche_end(); + print dol_get_fiche_end(); } print '

    '; diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index d0bee7c613c..67c6c394815 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -286,7 +286,7 @@ print load_fiche_titre($title, $linkback); if (GETPOST('withtab', 'alpha')) { $head = blockedlogadmin_prepare_head(); - dol_fiche_head($head, 'fingerprints', '', -1); + print dol_get_fiche_head($head, 'fingerprints', '', -1); } print ''.$langs->trans("FingerprintsDesc")."
    \n"; @@ -559,7 +559,7 @@ jQuery(document).ready(function () { if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { - ?> + ?> '; - } else { - $html = ' + } else { + $html = ' '; - $html .= ' + $html .= ' '; - $html .= ' + $html .= ' '; - $html .= ' + $html .= ' '; - } + } - return $html; + return $html; } diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 93926e4ba92..b8d0949a1f0 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -32,7 +32,7 @@ $langs->loadLangs(array('bookmarks', 'other')); // Security check if (!$user->rights->bookmark->lire) { - restrictedArea($user, 'bookmarks'); + restrictedArea($user, 'bookmarks'); } $id = GETPOST("id", 'int'); @@ -149,7 +149,7 @@ if ($action == 'create') print load_fiche_titre($langs->trans("NewBookmark")); - dol_fiche_head($head, $hselected, $langs->trans("Bookmark"), 0, 'bookmark'); + print dol_get_fiche_head($head, $hselected, $langs->trans("Bookmark"), 0, 'bookmark'); print ''; @@ -177,7 +177,7 @@ if ($action == 'create') print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print '   '; @@ -215,15 +215,15 @@ if ($id > 0 && !preg_match('/^add/i', $action)) } - dol_fiche_head($head, $hselected, $langs->trans("Bookmark"), -1, 'bookmark'); + print dol_get_fiche_head($head, $hselected, $langs->trans("Bookmark"), -1, 'bookmark'); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0); - print '
    '; + print '
    '; - print '
    '; + print '
    '; print ''; print ''; // Force warehouse (this is not a default value) print ''; @@ -174,11 +174,11 @@ if (!empty($conf->stock->enabled)) // Use Dolibarr Receipt Printer if (!empty($conf->receiptprinter->enabled)) { - print '\n"; + print '\n"; } print '
    '; @@ -295,7 +295,7 @@ if ($id > 0 && !preg_match('/^add/i', $action)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); if ($action == 'edit') { diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index 5fab4496f6e..7f19b1bd21e 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -28,217 +28,217 @@ */ class Bookmark extends CommonObject { - /** + /** * @var string ID to identify managed object */ public $element = 'bookmark'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'bookmark'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'bookmark'; - /** + /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * @var int */ - public $ismultientitymanaged = 1; + public $ismultientitymanaged = 1; - /** + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'bookmark'; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var int ID - */ - public $id; + /** + * @var int ID + */ + public $id; - /** + /** * @var int User ID */ public $fk_user; - /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + /** + * Date creation record (datec) + * + * @var integer + */ + public $datec; - public $url; + public $url; - public $target; // 0=replace, 1=new window + public $target; // 0=replace, 1=new window - public $title; + public $title; - public $position; + public $position; - public $favicon; + public $favicon; - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Directs the bookmark - * - * @param int $id Bookmark Id Loader - * @return int <0 if KO, >0 if OK - */ - public function fetch($id) - { - global $conf; + /** + * Directs the bookmark + * + * @param int $id Bookmark Id Loader + * @return int <0 if KO, >0 if OK + */ + public function fetch($id) + { + global $conf; - $sql = "SELECT rowid, fk_user, dateb as datec, url, target,"; - $sql .= " title, position, favicon"; - $sql .= " FROM ".MAIN_DB_PREFIX."bookmark"; - $sql .= " WHERE rowid = ".$id; - $sql .= " AND entity = ".$conf->entity; + $sql = "SELECT rowid, fk_user, dateb as datec, url, target,"; + $sql .= " title, position, favicon"; + $sql .= " FROM ".MAIN_DB_PREFIX."bookmark"; + $sql .= " WHERE rowid = ".$id; + $sql .= " AND entity = ".$conf->entity; dol_syslog("Bookmark::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->fk_user = $obj->fk_user; - $this->datec = $this->db->jdate($obj->datec); - $this->url = $obj->url; - $this->target = $obj->target; - $this->title = $obj->title; - $this->position = $obj->position; - $this->favicon = $obj->favicon; + $this->fk_user = $obj->fk_user; + $this->datec = $this->db->jdate($obj->datec); + $this->url = $obj->url; + $this->target = $obj->target; + $this->title = $obj->title; + $this->position = $obj->position; + $this->favicon = $obj->favicon; - $this->db->free($resql); - return $this->id; - } else { - dol_print_error($this->db); - return -1; - } - } + $this->db->free($resql); + return $this->id; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Insert bookmark into database - * - * @return int <0 si ko, rowid du bookmark cree si ok - */ - public function create() - { - global $conf; + /** + * Insert bookmark into database + * + * @return int <0 si ko, rowid du bookmark cree si ok + */ + public function create() + { + global $conf; - // Clean parameters - $this->url = trim($this->url); - $this->title = trim($this->title); + // Clean parameters + $this->url = trim($this->url); + $this->title = trim($this->title); if (empty($this->position)) $this->position = 0; $now = dol_now(); - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target"; - $sql .= ",title,favicon,position"; - $sql .= ",entity"; - $sql .= ") VALUES ("; - $sql .= ($this->fk_user > 0 ? $this->fk_user : "0").","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " '".$this->db->escape($this->url)."', '".$this->db->escape($this->target)."',"; - $sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', '".$this->db->escape($this->position)."'"; - $sql .= ", ".$this->db->escape($conf->entity); - $sql .= ")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target"; + $sql .= ",title,favicon,position"; + $sql .= ",entity"; + $sql .= ") VALUES ("; + $sql .= ($this->fk_user > 0 ? $this->fk_user : "0").","; + $sql .= " '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->escape($this->url)."', '".$this->db->escape($this->target)."',"; + $sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', '".$this->db->escape($this->position)."'"; + $sql .= ", ".$this->db->escape($conf->entity); + $sql .= ")"; - dol_syslog("Bookmark::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark"); - if ($id > 0) - { - $this->id = $id; - $this->db->commit(); - return $id; - } else { - $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); - $this->db->rollback(); - return -1; - } - } + dol_syslog("Bookmark::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark"); + if ($id > 0) + { + $this->id = $id; + $this->db->commit(); + return $id; + } else { + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); + $this->db->rollback(); + return -1; + } + } - /** - * Update bookmark record - * - * @return int <0 if KO, > if OK - */ - public function update() - { - // Clean parameters - $this->url = trim($this->url); - $this->title = trim($this->title); + /** + * Update bookmark record + * + * @return int <0 if KO, > if OK + */ + public function update() + { + // Clean parameters + $this->url = trim($this->url); + $this->title = trim($this->title); if (empty($this->position)) $this->position = 0; - $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark"; - $sql .= " SET fk_user = ".($this->fk_user > 0 ? $this->fk_user : "0"); - $sql .= " ,dateb = '".$this->db->idate($this->datec)."'"; - $sql .= " ,url = '".$this->db->escape($this->url)."'"; - $sql .= " ,target = '".$this->db->escape($this->target)."'"; - $sql .= " ,title = '".$this->db->escape($this->title)."'"; - $sql .= " ,favicon = '".$this->db->escape($this->favicon)."'"; - $sql .= " ,position = '".$this->db->escape($this->position)."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark"; + $sql .= " SET fk_user = ".($this->fk_user > 0 ? $this->fk_user : "0"); + $sql .= " ,dateb = '".$this->db->idate($this->datec)."'"; + $sql .= " ,url = '".$this->db->escape($this->url)."'"; + $sql .= " ,target = '".$this->db->escape($this->target)."'"; + $sql .= " ,title = '".$this->db->escape($this->title)."'"; + $sql .= " ,favicon = '".$this->db->escape($this->favicon)."'"; + $sql .= " ,position = '".$this->db->escape($this->position)."'"; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog("Bookmark::update", LOG_DEBUG); - if ($this->db->query($sql)) - { - return 1; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + dol_syslog("Bookmark::update", LOG_DEBUG); + if ($this->db->query($sql)) + { + return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Removes the bookmark - * - * @param int $id Id removed bookmark - * @return int <0 si ko, >0 si ok - */ - public function remove($id) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; - $sql .= " WHERE rowid = ".$id; + /** + * Removes the bookmark + * + * @param int $id Id removed bookmark + * @return int <0 si ko, >0 si ok + */ + public function remove($id) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; + $sql .= " WHERE rowid = ".$id; - dol_syslog("Bookmark::remove", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - return 1; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + dol_syslog("Bookmark::remove", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } /** * Function used to replace a thirdparty id with another one. @@ -265,7 +265,7 @@ class Bookmark extends CommonObject */ public function getLibStatut($mode) { - return ''; + return ''; } /** diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index dfd6e99a9ea..93d287ac501 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -65,13 +65,13 @@ if (GETPOST('action', 'alpha') == 'set') if (!$res > 0) $error++; if (!$error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* @@ -146,13 +146,13 @@ if (!empty($conf->stock->enabled)) print '
    '.$langs->trans("CashDeskDoNotDecreaseStock").''; if (empty($conf->productbatch->enabled)) { - print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); + print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); } else { - if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) { - $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); - } - print $langs->trans("Yes").'
    '; - print ''.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').''; + if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) { + $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); + } + print $langs->trans("Yes").'
    '; + print ''.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').''; } print '
    '; - print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; - print ''; - print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER", $conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER, 1); - print "
    '; + print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; + print ''; + print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER", $conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER, 1); + print "
    '; diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 7b513ada33c..72cb99123a4 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -34,8 +34,8 @@ if ($_GET['id'] == 'NOUV') // Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ... if (isset($_SESSION['serObjFacturation'])) { - $obj_facturation = unserialize($_SESSION['serObjFacturation']); - unset($_SESSION['serObjFacturation']); + $obj_facturation = unserialize($_SESSION['serObjFacturation']); + unset($_SESSION['serObjFacturation']); } else { // ... sinon, c'est une nouvelle vente $obj_facturation = new Facturation(); diff --git a/htdocs/cashdesk/class/Auth.class.php b/htdocs/cashdesk/class/Auth.class.php index cc71d1c20d8..7dbe7ceae3e 100644 --- a/htdocs/cashdesk/class/Auth.class.php +++ b/htdocs/cashdesk/class/Auth.class.php @@ -94,45 +94,45 @@ class Auth $test = true; - // Authentication mode - if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; - // Authentication mode: forceuser - if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto'; - // Set authmode - $authmode = explode(',', $dolibarr_main_authentication); + // Authentication mode + if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; + // Authentication mode: forceuser + if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto'; + // Set authmode + $authmode = explode(',', $dolibarr_main_authentication); - // No authentication mode - if (!count($authmode)) - { - $langs->load('main'); - dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication')); - exit; - } + // No authentication mode + if (!count($authmode)) + { + $langs->load('main'); + dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication')); + exit; + } $usertotest = $aLogin; $passwordtotest = $aPasswd; $entitytotest = $conf->entity; - // Validation tests user / password - // If ok, the variable will be initialized login - // If error, we will put error message in session under the name dol_loginmesg - $goontestloop = false; - if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) $goontestloop = true; - if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) $goontestloop = true; + // Validation tests user / password + // If ok, the variable will be initialized login + // If error, we will put error message in session under the name dol_loginmesg + $goontestloop = false; + if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) $goontestloop = true; + if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) $goontestloop = true; - if ($test && $goontestloop) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + if ($test && $goontestloop) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode); - if ($login) - { - $this->login($aLogin); - $this->passwd($aPasswd); - $ret = 0; - } else { - $ret = -1; - } - } + if ($login) + { + $this->login($aLogin); + $this->passwd($aPasswd); + $ret = 0; + } else { + $ret = -1; + } + } return $ret; } diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index f2223b0b45d..23eafadc7b8 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -25,553 +25,553 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; */ class Facturation { - /** - * Attributs "volatiles" : reinitialises apres chaque traitement d'un article - *

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

    - * int $id => 'rowid' du produit dans llx_product - * string $ref => 'ref' du produit dans llx_product - * int $qte => Quantite pour le produit en cours de traitement - * int $stock => Stock theorique pour le produit en cours de traitement - * int $remise_percent => Remise en pourcent sur le produit en cours - * int $montant_remise => Remise en pourcent sur le produit en cours - * int $prix => Prix HT du produit en cours - * int $tva => 'rowid' du taux de tva dans llx_c_tva - */ + /** + * Attributs "volatiles" : reinitialises apres chaque traitement d'un article + *

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

    + * int $id => 'rowid' du produit dans llx_product + * string $ref => 'ref' du produit dans llx_product + * int $qte => Quantite pour le produit en cours de traitement + * int $stock => Stock theorique pour le produit en cours de traitement + * int $remise_percent => Remise en pourcent sur le produit en cours + * int $montant_remise => Remise en pourcent sur le produit en cours + * int $prix => Prix HT du produit en cours + * int $tva => 'rowid' du taux de tva dans llx_c_tva + */ - /** + /** * @var int ID */ public $id; - protected $ref; - protected $qte; - protected $stock; - protected $remise_percent; - protected $montant_remise; - protected $prix; - protected $tva; + protected $ref; + protected $qte; + protected $stock; + protected $remise_percent; + protected $montant_remise; + protected $prix; + protected $tva; - /** - * Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation) - * string $num_facture => Numero de la facture (de la forme FAYYMM-XXXX) - * string $mode_reglement => Mode de reglement (ESP, CB ou CHQ) - * int $montant_encaisse => Montant encaisse en cas de reglement en especes - * int $montant_rendu => Monnaie rendue en cas de reglement en especes - * int $paiement_le => Date de paiement en cas de paiement differe - * - * int $prix_total_ht => Prix total hors taxes - * int $montant_tva => Montant total de la TVA, tous taux confondus - * int $prix_total_ttc => Prix total TTC - */ - protected $num_facture; - protected $mode_reglement; - protected $montant_encaisse; - protected $montant_rendu; - protected $paiement_le; + /** + * Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation) + * string $num_facture => Numero de la facture (de la forme FAYYMM-XXXX) + * string $mode_reglement => Mode de reglement (ESP, CB ou CHQ) + * int $montant_encaisse => Montant encaisse en cas de reglement en especes + * int $montant_rendu => Monnaie rendue en cas de reglement en especes + * int $paiement_le => Date de paiement en cas de paiement differe + * + * int $prix_total_ht => Prix total hors taxes + * int $montant_tva => Montant total de la TVA, tous taux confondus + * int $prix_total_ttc => Prix total TTC + */ + protected $num_facture; + protected $mode_reglement; + protected $montant_encaisse; + protected $montant_rendu; + protected $paiement_le; - protected $prix_total_ht; - protected $montant_tva; - protected $prix_total_ttc; + protected $prix_total_ht; + protected $montant_tva; + protected $prix_total_ttc; - /** - * Constructor - */ - public function __construct() - { - $this->raz(); - $this->razPers(); - } + /** + * Constructor + */ + public function __construct() + { + $this->raz(); + $this->razPers(); + } - // Data processing methods + // Data processing methods - /** - * Add a product into cart - * - * @return void - */ - public function ajoutArticle() - { - global $conf, $db, $mysoc; + /** + * Add a product into cart + * + * @return void + */ + public function ajoutArticle() + { + global $conf, $db, $mysoc; - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; + $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - $societe = new Societe($db); - $societe->fetch($thirdpartyid); + $societe = new Societe($db); + $societe->fetch($thirdpartyid); - $product = new Product($db); - $product->fetch($this->id); + $product = new Product($db); + $product->fetch($this->id); - $vatrowid = $this->tva(); + $vatrowid = $this->tva(); - $tmp = getTaxesFromId($vatrowid); - $txtva = $tmp['rate'].(empty($tmp['code']) ? '' : ' ('.$tmp['code'].')'); - $vat_npr = $tmp['npr']; + $tmp = getTaxesFromId($vatrowid); + $txtva = $tmp['rate'].(empty($tmp['code']) ? '' : ' ('.$tmp['code'].')'); + $vat_npr = $tmp['npr']; - $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); + $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); - // Clean vat code - $reg = array(); - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + // Clean vat code + $reg = array(); + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } - // Define part of HT, VAT, TTC - $resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); + // Define part of HT, VAT, TTC + $resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); - // Calculation of total HT without discount - $total_ht = $resultarray[0]; - $total_vat = $resultarray[1]; - $total_ttc = $resultarray[2]; - $total_localtax1 = $resultarray[9]; - $total_localtax2 = $resultarray[10]; + // Calculation of total HT without discount + $total_ht = $resultarray[0]; + $total_vat = $resultarray[1]; + $total_ttc = $resultarray[2]; + $total_localtax1 = $resultarray[9]; + $total_localtax2 = $resultarray[10]; - // Calculation of the discount amount - if ($this->remisePercent()) - { - $remise_percent = $this->remisePercent(); - } else { - $remise_percent = 0; - } - $montant_remise_ht = ($resultarray[6] - $resultarray[0]); - $this->amountDiscount($montant_remise_ht); + // Calculation of the discount amount + if ($this->remisePercent()) + { + $remise_percent = $this->remisePercent(); + } else { + $remise_percent = 0; + } + $montant_remise_ht = ($resultarray[6] - $resultarray[0]); + $this->amountDiscount($montant_remise_ht); - $newcartarray = $_SESSION['poscart']; + $newcartarray = $_SESSION['poscart']; - $i = 0; - if (!is_null($newcartarray) && !empty($newcartarray)) { - $i = count($newcartarray); - } + $i = 0; + if (!is_null($newcartarray) && !empty($newcartarray)) { + $i = count($newcartarray); + } - $newcartarray[$i]['id'] = $i; - $newcartarray[$i]['ref'] = $product->ref; - $newcartarray[$i]['label'] = $product->label; - $newcartarray[$i]['price'] = $product->price; - $newcartarray[$i]['price_ttc'] = $product->price_ttc; + $newcartarray[$i]['id'] = $i; + $newcartarray[$i]['ref'] = $product->ref; + $newcartarray[$i]['label'] = $product->label; + $newcartarray[$i]['price'] = $product->price; + $newcartarray[$i]['price_ttc'] = $product->price_ttc; - if (!empty($conf->global->PRODUIT_MULTIPRICES)) - { - if (isset($product->multiprices[$societe->price_level])) - { - $newcartarray[$i]['price'] = $product->multiprices[$societe->price_level]; - $newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; - } - } + if (!empty($conf->global->PRODUIT_MULTIPRICES)) + { + if (isset($product->multiprices[$societe->price_level])) + { + $newcartarray[$i]['price'] = $product->multiprices[$societe->price_level]; + $newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; + } + } - $newcartarray[$i]['fk_article'] = $this->id; - $newcartarray[$i]['qte'] = $this->qte(); - $newcartarray[$i]['fk_tva'] = $this->tva(); // Vat rowid - $newcartarray[$i]['remise_percent'] = $remise_percent; - $newcartarray[$i]['remise'] = price2num($montant_remise_ht); - $newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT'); - $newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT'); - $newcartarray[$i]['total_vat'] = price2num($total_vat, 'MT'); - $newcartarray[$i]['total_localtax1'] = price2num($total_localtax1, 'MT'); - $newcartarray[$i]['total_localtax2'] = price2num($total_localtax2, 'MT'); - $_SESSION['poscart'] = $newcartarray; + $newcartarray[$i]['fk_article'] = $this->id; + $newcartarray[$i]['qte'] = $this->qte(); + $newcartarray[$i]['fk_tva'] = $this->tva(); // Vat rowid + $newcartarray[$i]['remise_percent'] = $remise_percent; + $newcartarray[$i]['remise'] = price2num($montant_remise_ht); + $newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT'); + $newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT'); + $newcartarray[$i]['total_vat'] = price2num($total_vat, 'MT'); + $newcartarray[$i]['total_localtax1'] = price2num($total_localtax1, 'MT'); + $newcartarray[$i]['total_localtax2'] = price2num($total_localtax2, 'MT'); + $_SESSION['poscart'] = $newcartarray; - $this->raz(); - } + $this->raz(); + } - /** - * Remove a product from panel - * - * @param int $aArticle Id of line into cart to remove - * @return void - */ - public function supprArticle($aArticle) - { - $poscart = $_SESSION['poscart']; + /** + * Remove a product from panel + * + * @param int $aArticle Id of line into cart to remove + * @return void + */ + public function supprArticle($aArticle) + { + $poscart = $_SESSION['poscart']; - $j = 0; - $newposcart = array(); - foreach ($poscart as $key => $val) - { - if ($poscart[$key]['id'] != $aArticle) - { - $newposcart[$j] = $poscart[$key]; - $newposcart[$j]['id'] = $j; - $j++; - } - } - unset($poscart); - //var_dump($poscart);exit; - $_SESSION['poscart'] = $newposcart; - } + $j = 0; + $newposcart = array(); + foreach ($poscart as $key => $val) + { + if ($poscart[$key]['id'] != $aArticle) + { + $newposcart[$j] = $poscart[$key]; + $newposcart[$j]['id'] = $j; + $j++; + } + } + unset($poscart); + //var_dump($poscart);exit; + $_SESSION['poscart'] = $newposcart; + } - /** - * Calculation of total HT, total TTC and VAT amounts - * - * @return int Total - */ - public function calculTotaux() - { - global $db; + /** + * Calculation of total HT, total TTC and VAT amounts + * + * @return int Total + */ + public function calculTotaux() + { + global $db; - $total_ht = 0; - $total_ttc = 0; - $total_vat = 0; - $total_localtax1 = 0; - $total_localtax2 = 0; + $total_ht = 0; + $total_ttc = 0; + $total_vat = 0; + $total_localtax1 = 0; + $total_localtax2 = 0; - $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); + $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); - $tab_size = count($tab); - for ($i = 0; $i < $tab_size; $i++) - { - // Total HT - $remise = $tab[$i]['remise']; - $total_ht += ($tab[$i]['total_ht']); - $total_vat += ($tab[$i]['total_vat']); - $total_ttc += ($tab[$i]['total_ttc']); - $total_localtax1 += ($tab[$i]['total_localtax1']); - $total_localtax2 += ($tab[$i]['total_localtax2']); - } + $tab_size = count($tab); + for ($i = 0; $i < $tab_size; $i++) + { + // Total HT + $remise = $tab[$i]['remise']; + $total_ht += ($tab[$i]['total_ht']); + $total_vat += ($tab[$i]['total_vat']); + $total_ttc += ($tab[$i]['total_ttc']); + $total_localtax1 += ($tab[$i]['total_localtax1']); + $total_localtax2 += ($tab[$i]['total_localtax2']); + } - $this->prix_total_ttc = $total_ttc; - $this->prix_total_ht = $total_ht; - $this->prix_total_vat = $total_vat; - $this->prix_total_localtax1 = $total_localtax1; - $this->prix_total_localtax2 = $total_localtax2; + $this->prix_total_ttc = $total_ttc; + $this->prix_total_ht = $total_ht; + $this->prix_total_vat = $total_vat; + $this->prix_total_localtax1 = $total_localtax1; + $this->prix_total_localtax2 = $total_localtax2; - $this->montant_tva = $total_ttc - $total_ht; - //print 'total: '.$this->prix_total_ttc; exit; - } + $this->montant_tva = $total_ttc - $total_ht; + //print 'total: '.$this->prix_total_ttc; exit; + } - /** - * Reset attributes - * - * @return void - */ - public function raz() - { - $this->id('RESET'); - $this->ref('RESET'); - $this->qte('RESET'); - $this->stock('RESET'); - $this->remisePercent('RESET'); - $this->amountDiscount('RESET'); - $this->prix('RESET'); - $this->tva('RESET'); - } + /** + * Reset attributes + * + * @return void + */ + public function raz() + { + $this->id('RESET'); + $this->ref('RESET'); + $this->qte('RESET'); + $this->stock('RESET'); + $this->remisePercent('RESET'); + $this->amountDiscount('RESET'); + $this->prix('RESET'); + $this->tva('RESET'); + } - /** - * Resetting persistent attributes - * - * @return void - */ - private function razPers() - { - $this->numInvoice('RESET'); - $this->getSetPaymentMode('RESET'); - $this->amountCollected('RESET'); - $this->amountReturned('RESET'); - $this->paiementLe('RESET'); + /** + * Resetting persistent attributes + * + * @return void + */ + private function razPers() + { + $this->numInvoice('RESET'); + $this->getSetPaymentMode('RESET'); + $this->amountCollected('RESET'); + $this->amountReturned('RESET'); + $this->paiementLe('RESET'); - $this->amountWithoutTax('RESET'); - $this->amountVat('RESET'); - $this->amountWithTax('RESET'); - } + $this->amountWithoutTax('RESET'); + $this->amountVat('RESET'); + $this->amountWithTax('RESET'); + } - // Methods for modifying protected attributes + // Methods for modifying protected attributes - /** - * Getter for id - * - * @param int $aId Id - * @return int Id - */ - public function id($aId = null) - { + /** + * Getter for id + * + * @param int $aId Id + * @return int Id + */ + public function id($aId = null) + { - if (!$aId) - { - return $this->id; - } elseif ($aId == 'RESET') - { - $this->id = null; - } else { - $this->id = $aId; - } - } + if (!$aId) + { + return $this->id; + } elseif ($aId == 'RESET') + { + $this->id = null; + } else { + $this->id = $aId; + } + } - /** - * Getter for ref - * - * @param string $aRef Ref - * @return string Ref - */ - public function ref($aRef = null) - { + /** + * Getter for ref + * + * @param string $aRef Ref + * @return string Ref + */ + public function ref($aRef = null) + { - if (is_null($aRef)) - { - return $this->ref; - } elseif ($aRef == 'RESET') - { - $this->ref = null; - } else { - $this->ref = $aRef; - } - } + if (is_null($aRef)) + { + return $this->ref; + } elseif ($aRef == 'RESET') + { + $this->ref = null; + } else { + $this->ref = $aRef; + } + } - /** - * Getter for qte - * - * @param int $aQte Qty - * @return int Qty - */ - public function qte($aQte = null) - { - if (is_null($aQte)) - { - return $this->qte; - } elseif ($aQte == 'RESET') - { - $this->qte = null; - } else { - $this->qte = $aQte; - } - } + /** + * Getter for qte + * + * @param int $aQte Qty + * @return int Qty + */ + public function qte($aQte = null) + { + if (is_null($aQte)) + { + return $this->qte; + } elseif ($aQte == 'RESET') + { + $this->qte = null; + } else { + $this->qte = $aQte; + } + } - /** - * Getter for stock - * - * @param string $aStock Stock - * @return string Stock - */ - public function stock($aStock = null) - { + /** + * Getter for stock + * + * @param string $aStock Stock + * @return string Stock + */ + public function stock($aStock = null) + { - if (is_null($aStock)) - { - return $this->stock; - } elseif ($aStock == 'RESET') - { - $this->stock = null; - } else { - $this->stock = $aStock; - } - } + if (is_null($aStock)) + { + return $this->stock; + } elseif ($aStock == 'RESET') + { + $this->stock = null; + } else { + $this->stock = $aStock; + } + } - /** - * Getter for remise_percent - * - * @param string $aRemisePercent Discount - * @return string Discount - */ - public function remisePercent($aRemisePercent = null) - { + /** + * Getter for remise_percent + * + * @param string $aRemisePercent Discount + * @return string Discount + */ + public function remisePercent($aRemisePercent = null) + { - if (is_null($aRemisePercent)) - { - return $this->remise_percent; - } elseif ($aRemisePercent == 'RESET') - { - $this->remise_percent = null; - } else { - $this->remise_percent = $aRemisePercent; - } - } + if (is_null($aRemisePercent)) + { + return $this->remise_percent; + } elseif ($aRemisePercent == 'RESET') + { + $this->remise_percent = null; + } else { + $this->remise_percent = $aRemisePercent; + } + } - /** - * Getter for montant_remise - * - * @param int $aMontantRemise Amount - * @return string Amount - */ - public function amountDiscount($aMontantRemise = null) - { + /** + * Getter for montant_remise + * + * @param int $aMontantRemise Amount + * @return string Amount + */ + public function amountDiscount($aMontantRemise = null) + { - if (is_null($aMontantRemise)) { - return $this->montant_remise; - } elseif ($aMontantRemise == 'RESET') { - $this->montant_remise = null; - } else { - $this->montant_remise = $aMontantRemise; - } - } + if (is_null($aMontantRemise)) { + return $this->montant_remise; + } elseif ($aMontantRemise == 'RESET') { + $this->montant_remise = null; + } else { + $this->montant_remise = $aMontantRemise; + } + } - /** - * Getter for prix - * - * @param int $aPrix Price - * @return string Stock - */ - public function prix($aPrix = null) - { + /** + * Getter for prix + * + * @param int $aPrix Price + * @return string Stock + */ + public function prix($aPrix = null) + { - if (is_null($aPrix)) { - return $this->prix; - } elseif ($aPrix == 'RESET') { - $this->prix = null; - } else { - $this->prix = $aPrix; - } - } + if (is_null($aPrix)) { + return $this->prix; + } elseif ($aPrix == 'RESET') { + $this->prix = null; + } else { + $this->prix = $aPrix; + } + } - /** - * Getter for tva - * - * @param int $aTva Vat - * @return int Vat - */ - public function tva($aTva = null) - { - if (is_null($aTva)) { - return $this->tva; - } elseif ($aTva == 'RESET') { - $this->tva = null; - } else { - $this->tva = $aTva; - } - } + /** + * Getter for tva + * + * @param int $aTva Vat + * @return int Vat + */ + public function tva($aTva = null) + { + if (is_null($aTva)) { + return $this->tva; + } elseif ($aTva == 'RESET') { + $this->tva = null; + } else { + $this->tva = $aTva; + } + } - /** - * Get num invoice - * - * @param string $aNumFacture Invoice ref - * @return string Invoice ref - */ - public function numInvoice($aNumFacture = null) - { - if (is_null($aNumFacture)) { - return $this->num_facture; - } elseif ($aNumFacture == 'RESET') { - $this->num_facture = null; - } else { - $this->num_facture = $aNumFacture; - } - } + /** + * Get num invoice + * + * @param string $aNumFacture Invoice ref + * @return string Invoice ref + */ + public function numInvoice($aNumFacture = null) + { + if (is_null($aNumFacture)) { + return $this->num_facture; + } elseif ($aNumFacture == 'RESET') { + $this->num_facture = null; + } else { + $this->num_facture = $aNumFacture; + } + } - /** - * Get payment mode - * - * @param int $aModeReglement Payment mode - * @return int Payment mode - */ - public function getSetPaymentMode($aModeReglement = null) - { + /** + * Get payment mode + * + * @param int $aModeReglement Payment mode + * @return int Payment mode + */ + public function getSetPaymentMode($aModeReglement = null) + { - if (is_null($aModeReglement)) { - return $this->mode_reglement; - } elseif ($aModeReglement == 'RESET') { - $this->mode_reglement = null; - } else { - $this->mode_reglement = $aModeReglement; - } - } + if (is_null($aModeReglement)) { + return $this->mode_reglement; + } elseif ($aModeReglement == 'RESET') { + $this->mode_reglement = null; + } else { + $this->mode_reglement = $aModeReglement; + } + } - /** - * Get amount - * - * @param int $aMontantEncaisse Amount - * @return int Amount - */ - public function amountCollected($aMontantEncaisse = null) - { + /** + * Get amount + * + * @param int $aMontantEncaisse Amount + * @return int Amount + */ + public function amountCollected($aMontantEncaisse = null) + { - if (is_null($aMontantEncaisse)) { - return $this->montant_encaisse; - } elseif ($aMontantEncaisse == 'RESET') { - $this->montant_encaisse = null; - } else { - $this->montant_encaisse = $aMontantEncaisse; - } - } + if (is_null($aMontantEncaisse)) { + return $this->montant_encaisse; + } elseif ($aMontantEncaisse == 'RESET') { + $this->montant_encaisse = null; + } else { + $this->montant_encaisse = $aMontantEncaisse; + } + } - /** - * Get amount - * - * @param int $aMontantRendu Amount - * @return int Amount - */ - public function amountReturned($aMontantRendu = null) - { + /** + * Get amount + * + * @param int $aMontantRendu Amount + * @return int Amount + */ + public function amountReturned($aMontantRendu = null) + { - if (is_null($aMontantRendu)) { - return $this->montant_rendu; - } elseif ($aMontantRendu == 'RESET') { - $this->montant_rendu = null; - } else { - $this->montant_rendu = $aMontantRendu; - } - } + if (is_null($aMontantRendu)) { + return $this->montant_rendu; + } elseif ($aMontantRendu == 'RESET') { + $this->montant_rendu = null; + } else { + $this->montant_rendu = $aMontantRendu; + } + } - /** - * Get payment date - * - * @param integer $aPaiementLe Date - * @return integer Date - */ - public function paiementLe($aPaiementLe = null) - { - if (is_null($aPaiementLe)) { - return $this->paiement_le; - } elseif ($aPaiementLe == 'RESET') { - $this->paiement_le = null; - } else { - $this->paiement_le = $aPaiementLe; - } - } + /** + * Get payment date + * + * @param integer $aPaiementLe Date + * @return integer Date + */ + public function paiementLe($aPaiementLe = null) + { + if (is_null($aPaiementLe)) { + return $this->paiement_le; + } elseif ($aPaiementLe == 'RESET') { + $this->paiement_le = null; + } else { + $this->paiement_le = $aPaiementLe; + } + } - /** - * Get total HT - * - * @param int $aTotalHt Total amount - * @return int Total amount - */ - public function amountWithoutTax($aTotalHt = null) - { - if (is_null($aTotalHt)) { - return $this->prix_total_ht; - } elseif ($aTotalHt == 'RESET') { - $this->prix_total_ht = null; - } else { - $this->prix_total_ht = $aTotalHt; - } - } + /** + * Get total HT + * + * @param int $aTotalHt Total amount + * @return int Total amount + */ + public function amountWithoutTax($aTotalHt = null) + { + if (is_null($aTotalHt)) { + return $this->prix_total_ht; + } elseif ($aTotalHt == 'RESET') { + $this->prix_total_ht = null; + } else { + $this->prix_total_ht = $aTotalHt; + } + } - /** - * Get amount vat - * - * @param int $aMontantTva Amount vat - * @return int Amount vat - */ - public function amountVat($aMontantTva = null) - { - if (is_null($aMontantTva)) { - return $this->montant_tva; - } elseif ($aMontantTva == 'RESET') { - $this->montant_tva = null; - } else { - $this->montant_tva = $aMontantTva; - } - } + /** + * Get amount vat + * + * @param int $aMontantTva Amount vat + * @return int Amount vat + */ + public function amountVat($aMontantTva = null) + { + if (is_null($aMontantTva)) { + return $this->montant_tva; + } elseif ($aMontantTva == 'RESET') { + $this->montant_tva = null; + } else { + $this->montant_tva = $aMontantTva; + } + } - /** - * Get total TTC - * - * @param int $aTotalTtc Amount ttc - * @return int Amount ttc - */ - public function amountWithTax($aTotalTtc = null) - { - if (is_null($aTotalTtc)) - { - return $this->prix_total_ttc; - } elseif ($aTotalTtc == 'RESET') - { - $this->prix_total_ttc = null; - } else { - $this->prix_total_ttc = $aTotalTtc; - } - } + /** + * Get total TTC + * + * @param int $aTotalTtc Amount ttc + * @return int Amount ttc + */ + public function amountWithTax($aTotalTtc = null) + { + if (is_null($aTotalTtc)) + { + return $this->prix_total_ttc; + } elseif ($aTotalTtc == 'RESET') + { + $this->prix_total_ttc = null; + } else { + $this->prix_total_ttc = $aTotalTtc; + } + } } diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 16b4bfec017..76ad8571118 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -67,15 +67,15 @@ switch ($action) { $ret[$key] = $value; } - // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function + // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function $productid = $ret['rowid']; $product = new Product($db); - $product->fetch($productid); - $prod = $product; + $product->fetch($productid); + $prod = $product; $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - $societe = new Societe($db); + $societe = new Societe($db); $societe->fetch($thirdpartyid); // Update if prices fields are defined @@ -91,39 +91,39 @@ switch ($action) // multiprix if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($societe->price_level)) { - $pu_ht = $prod->multiprices[$societe->price_level]; - $pu_ttc = $prod->multiprices_ttc[$societe->price_level]; - $price_min = $prod->multiprices_min[$societe->price_level]; - $price_base_type = $prod->multiprices_base_type[$societe->price_level]; - if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { - if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx = $prod->multiprices_tva_tx[$societe->price_level]; - if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$societe->price_level]; - } + $pu_ht = $prod->multiprices[$societe->price_level]; + $pu_ttc = $prod->multiprices_ttc[$societe->price_level]; + $price_min = $prod->multiprices_min[$societe->price_level]; + $price_base_type = $prod->multiprices_base_type[$societe->price_level]; + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx = $prod->multiprices_tva_tx[$societe->price_level]; + if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$societe->price_level]; + } } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; - $prodcustprice = new Productcustomerprice($db); + $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $societe->id); + $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $societe->id); - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) - { - if (count($prodcustprice->lines) > 0) - { - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; - $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr = 0; - } - } else { - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); - } + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) + { + if (count($prodcustprice->lines) > 0) + { + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr = 0; + } + } else { + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); + } } $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); @@ -131,17 +131,17 @@ switch ($action) // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? if (!empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). elseif ($tmpvat != $tmpprodvat) { - if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); - } else { - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } + if ($price_base_type != 'HT') { + $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + } else { + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + } } $obj_facturation->id($ret['rowid']); @@ -187,17 +187,17 @@ switch ($action) $newthirdpartyid = GETPOST('CASHDESK_ID_THIRDPARTY', 'int'); if ($newthirdpartyid > 0) { - $_SESSION["CASHDESK_ID_THIRDPARTY"] = $newthirdpartyid; + $_SESSION["CASHDESK_ID_THIRDPARTY"] = $newthirdpartyid; } $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; - break; + break; case 'ajout_article': // We have clicked on button "Add product" if (!empty($obj_facturation->id)) // A product was previously selected and stored in session, so we can add it { - dol_syslog("facturation_verif save vat ".$_POST['selTva']); + dol_syslog("facturation_verif save vat ".$_POST['selTva']); $obj_facturation->qte($_POST['txtQte']); $obj_facturation->tva($_POST['selTva']); // id of vat. Saved so we can use it for next product $obj_facturation->remisePercent($_POST['txtRemise']); diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php index e8366e981cc..45ce3857068 100644 --- a/htdocs/cashdesk/index_verif.php +++ b/htdocs/cashdesk/index_verif.php @@ -51,9 +51,9 @@ if (empty($username)) // Check third party id if (!($thirdpartyid > 0)) { - $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell")); - header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); - exit; + $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell")); + header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); + exit; } // If we setup stock module to ask movement on invoices, we must not allow access if required setup not finished. @@ -107,12 +107,12 @@ if ($retour >= 0) $_SESSION['lastname'] = $tab['lastname']; $_SESSION['firstname'] = $tab['firstname']; $_SESSION['CASHDESK_ID_THIRDPARTY'] = ($thirdpartyid > 0 ? $thirdpartyid : ''); - $_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : ''); + $_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : ''); - //var_dump($_SESSION);exit; + $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : ''); + $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : ''); + $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : ''); + //var_dump($_SESSION);exit; header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&id=NOUV'); exit; @@ -121,7 +121,7 @@ if ($retour >= 0) } } else { // Load translation files required by the page - $langs->loadLangs(array("other", "errors")); + $langs->loadLangs(array("other", "errors")); $retour = $langs->trans("ErrorBadLoginPassword"); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid); exit; diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index e1dc53ed6e8..d48fc544eb0 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -118,7 +118,7 @@ for ($i = 0; $i < $nbtoshow; $i++) $buyer = new Societe($db); if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); echo $form->load_tva('selTva', (GETPOSTISSET("selTva") ? GETPOST("selTva", 'alpha', 2) : $vatrate), $mysoc, $buyer, 0, 0, '', false, -1); - ?> + ?> @@ -141,7 +141,7 @@ for ($i = 0; $i < $nbtoshow; $i++) -
    +
    trans("Amount"); ?> diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index bd73954f6a0..e3c3c285966 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -50,22 +50,22 @@ $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); $tab_size = count($tab); if ($tab_size <= 0) print '
    '.$langs->trans("NoArticle").'

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

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

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

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

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

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

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

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

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

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

    '."\n"); diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php index b5994456252..101ea687e7b 100644 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ b/htdocs/cashdesk/tpl/ticket.tpl.php @@ -55,11 +55,11 @@ $object->fetch($facid);

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

    + // Recuperation et affichage de la date et de l'heure + $now = dol_now(); + print dol_print_date($now, 'dayhourtext').'
    '; + print $object->ref; + ?>

    @@ -78,14 +78,14 @@ $object->fetch($facid); + $tab_size = count($tab); + for ($i = 0; $i < $tab_size; $i++) + { + $remise = $tab[$i]['remise']; + ?> @@ -94,8 +94,8 @@ $object->fetch($facid); currency); ?> + } + ?> diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index 0434473d359..cc558cca058 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -97,7 +97,7 @@ if ($obj_facturation->amountReturned()) { - +

    executeHooks('doActions', $parameters, $obj_facturation); if (empty($reshook)) { - require 'tpl/ticket.tpl.php'; + require 'tpl/ticket.tpl.php'; } diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 6b8e9af94f1..9468c395756 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -39,11 +39,11 @@ $bankaccountid = GETPOST('cashdeskbank'); switch ($action) { default: - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation'; + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation'; break; - case 'valide_achat': - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; + case 'validate_sell': + $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; $company = new Societe($db); $company->fetch($thirdpartyid); @@ -97,9 +97,9 @@ switch ($action) $obj_facturation->amountReturned($encaisse - $total); } else { - //$txtDatePaiement=$_POST['txtDatePaiement']; - $datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']); - $txtDatePaiement = dol_print_date($datePaiement, 'dayrfc'); + //$txtDatePaiement=$_POST['txtDatePaiement']; + $datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']); + $txtDatePaiement = dol_print_date($datePaiement, 'dayrfc'); $obj_facturation->paiementLe($txtDatePaiement); } @@ -112,7 +112,7 @@ switch ($action) break; - case 'valide_facture': + case 'validate_invoice': $now = dol_now(); // Recuperation de la date et de l'heure @@ -252,12 +252,12 @@ switch ($action) } } else { setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; + $error++; } $id = $invoice->id; } else { - $resultcreate = $invoice->create($user, 0, 0); + $resultcreate = $invoice->create($user, 0, 0); if ($resultcreate > 0) { $warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0); @@ -282,8 +282,8 @@ switch ($action) if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); else $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); if ($result < 0) { - setEventMessages($mouvP->error, $mouvP->errors, 'errors'); - $error++; + setEventMessages($mouvP->error, $mouvP->errors, 'errors'); + $error++; } } } @@ -303,33 +303,33 @@ switch ($action) $paiement_id = $payment->create($user); if ($paiement_id > 0) { - if (!$error) - { - $result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', ''); - if (!$result > 0) - { - $errmsg = $paiement->error; - $error++; - } - } + if (!$error) + { + $result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', ''); + if (!$result > 0) + { + $errmsg = $paiement->error; + $error++; + } + } - if (!$error) - { - if ($invoice->total_ttc == $obj_facturation->amountWithTax() - && $obj_facturation->getSetPaymentMode() != 'DIFF') - { - // We set status to payed - $result = $invoice->set_paid($user); - //print 'set paid';exit; - } - } + if (!$error) + { + if ($invoice->total_ttc == $obj_facturation->amountWithTax() + && $obj_facturation->getSetPaymentMode() != 'DIFF') + { + // We set status to payed + $result = $invoice->set_paid($user); + //print 'set paid';exit; + } + } } else { - setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; + setEventMessages($invoice->error, $invoice->errors, 'errors'); + $error++; } } else { setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; + $error++; } } @@ -344,7 +344,7 @@ switch ($action) } break; - // End of case: valide_facture + // End of case: validate_invoice } unset($_SESSION['serObjFacturation']); diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index eb8af1ee44a..693a3e53a2a 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -42,26 +42,26 @@ $action = GETPOST('action', 'aZ09'); $reg = array(); if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - setEventMessages($db->lasterror(), null, 'errors'); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + setEventMessages($db->lasterror(), null, 'errors'); + } } if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - setEventMessages($db->lasterror(), null, 'errors'); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + setEventMessages($db->lasterror(), null, 'errors'); + } } @@ -81,7 +81,7 @@ print load_fiche_titre($langs->trans("CategoriesSetup"), $linkback, 'title_setup $head = categoriesadmin_prepare_head(); -dol_fiche_head($head, 'setup', $langs->trans("Categories"), -1, 'category'); +print dol_get_fiche_head($head, 'setup', $langs->trans("Categories"), -1, 'category'); print ''; diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 72151abdcdb..ff6a4ca7881 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -68,19 +68,19 @@ print load_fiche_titre($langs->trans("CategoriesSetup"), $linkback, 'title_setup $head = categoriesadmin_prepare_head(); -dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), -1, 'category'); +print dol_get_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), -1, 'category'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
    '; - print "".$langs->trans("NewAttribute").""; - print "
    "; + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; } @@ -93,9 +93,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
    '; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -105,10 +105,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
    "; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 096a5497efd..590ffe83cf1 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -5,6 +5,7 @@ * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,26 +36,24 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load("categories"); // Security check -$socid = GETPOST('socid', 'int'); +$socid = (int) GETPOST('socid', 'int'); if (!$user->rights->categorie->lire) accessforbidden(); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $origin = GETPOST('origin', 'alpha'); -$catorigin = GETPOST('catorigin', 'int'); -$type = GETPOST('type', 'alpha'); +$catorigin = (int) GETPOST('catorigin', 'int'); +$type = GETPOST('type', 'aZ09'); $urlfrom = GETPOST('urlfrom', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$socid = GETPOST('socid', 'int'); -$label = GETPOST('label'); -$description = GETPOST('description'); -$color = GETPOST('color'); -$visible = GETPOST('visible'); -$parent = GETPOST('parent'); +$label = (string) GETPOST('label', 'alphanohtml'); +$description = (string) GETPOST('description', 'restricthtml'); +$color = preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('color', 'alphanohtml')); +$visible = (int) GETPOST('visible', 'int'); +$parent = (int) GETPOST('parent', 'int'); -if ($origin) -{ +if ($origin) { if ($type == Categorie::TYPE_PRODUCT) $idProdOrigin = $origin; if ($type == Categorie::TYPE_SUPPLIER) $idSupplierOrigin = $origin; if ($type == Categorie::TYPE_CUSTOMER) $idCompanyOrigin = $origin; @@ -73,6 +72,8 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard')); +$error = 0; + /* * Actions @@ -88,32 +89,25 @@ if ($action == 'add' && $user->rights->categorie->creer) { header("Location: ".$urlfrom); exit; - } elseif ($backtopage) - { + } elseif ($backtopage) { header("Location: ".$backtopage); exit; - } elseif ($idProdOrigin) - { + } elseif ($idProdOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type); exit; - } elseif ($idCompanyOrigin) - { + } elseif ($idCompanyOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type); exit; - } elseif ($idSupplierOrigin) - { + } elseif ($idSupplierOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type); exit; - } elseif ($idMemberOrigin) - { + } elseif ($idMemberOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type); exit; - } elseif ($idContactOrigin) - { + } elseif ($idContactOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type); exit; - } elseif ($idProjectOrigin) - { + } elseif ($idProjectOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type); exit; } else { @@ -127,7 +121,7 @@ if ($action == 'add' && $user->rights->categorie->creer) $object->label = $label; $object->color = $color; $object->description = dol_htmlcleanlastbr($description); - $object->socid = ($socid ? $socid : 'null'); + $object->socid = ($socid > 0 ? $socid : 0); $object->visible = $visible; $object->type = $type; @@ -233,7 +227,7 @@ if ($user->rights->categorie->creer) print load_fiche_titre($langs->trans("CreateCat")); - dol_fiche_head(''); + print dol_get_fiche_head(''); print '
    '; @@ -262,7 +256,7 @@ if ($user->rights->categorie->creer) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); @@ -270,7 +264,7 @@ if ($user->rights->categorie->creer) print '
    '; - dol_fiche_end(''); + print dol_get_fiche_end(''); print '

    '; print ''; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 5f0a28340f9..e182a91d32a 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -658,7 +658,7 @@ class Categories extends DolibarrApi * Clean sensible object datas * * @param Categorie $object Object to clean - * @return array Array of cleaned object properties + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 1bc9f47ded4..3aca92708a7 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -208,6 +208,11 @@ class Categorie extends CommonObject */ public $color; + /** + * @var int Visible + */ + public $visible; + /** * @var int Id of thirdparty when CATEGORY_ASSIGNED_TO_A_CUSTOMER is set */ @@ -312,42 +317,38 @@ class Categorie extends CommonObject $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext"; $sql .= ", date_creation, tms, fk_user_creat, fk_user_modif"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; - if ($id > 0) - { + if ($id > 0) { $sql .= " WHERE rowid = ".$id; - } elseif (!empty($ref_ext)) - { + } elseif (!empty($ref_ext)) { $sql .= " WHERE ref_ext LIKE '".$this->db->escape($ref_ext)."'"; } else { $sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")"; - if (!is_null($type)) $sql .= " AND type = ".$this->db->escape($type); + if (!is_null($type)) $sql .= " AND type = ".((int) $type); } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql) > 0) - { + if ($resql) { + if ($this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); $this->id = $res['rowid']; //$this->ref = $res['rowid']; - $this->fk_parent = $res['fk_parent']; + $this->fk_parent = (int) $res['fk_parent']; $this->label = $res['label']; $this->description = $res['description']; $this->color = $res['color']; - $this->socid = $res['fk_soc']; - $this->visible = $res['visible']; - $this->type = $res['type']; + $this->socid = (int) $res['fk_soc']; + $this->visible = (int) $res['visible']; + $this->type = (int) $res['type']; $this->ref_ext = $res['ref_ext']; - $this->entity = $res['entity']; + $this->entity = (int) $res['entity']; $this->date_creation = $this->db->jdate($res['date_creation']); $this->date_modification = $this->db->jdate($res['tms']); - $this->user_creation = $res['fk_user_creat']; - $this->user_modification = $res['fk_user_modif']; + $this->user_creation = (int) $res['fk_user_creat']; + $this->user_modification = (int) $res['fk_user_modif']; - // Retreive all extrafield + // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); @@ -397,8 +398,7 @@ class Categorie extends CommonObject if (empty($this->visible)) $this->visible = 0; $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); - if ($this->already_exists()) - { + if ($this->already_exists()) { $this->error = $langs->trans("ImpossibleAddCat", $this->label); $this->error .= " : ".$langs->trans("CategoryExistsAtSameLevel"); dol_syslog($this->error, LOG_WARNING); @@ -412,8 +412,7 @@ class Categorie extends CommonObject $sql .= " label,"; $sql .= " description,"; $sql .= " color,"; - if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) - { + if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { $sql .= "fk_soc,"; } $sql .= " visible,"; @@ -424,54 +423,47 @@ class Categorie extends CommonObject $sql .= " date_creation,"; $sql .= " fk_user_creat"; $sql .= ") VALUES ("; - $sql .= $this->db->escape($this->fk_parent).","; - $sql .= "'".$this->db->escape($this->label)."',"; - $sql .= "'".$this->db->escape($this->description)."',"; - $sql .= "'".$this->db->escape($this->color)."',"; - if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) - { - $sql .= ($this->socid != -1 ? $this->socid : 'null').","; + $sql .= (int) $this->fk_parent.","; + $sql .= "'".$this->db->escape($this->label)."', "; + $sql .= "'".$this->db->escape($this->description)."', "; + $sql .= "'".$this->db->escape($this->color)."', "; + if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { + $sql .= ($this->socid > 0 ? $this->socid : 'null').", "; } - $sql .= "'".$this->db->escape($this->visible)."',"; - $sql .= $this->db->escape($type).","; - $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').","; - $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').","; - $sql .= $this->db->escape($conf->entity).","; + $sql .= "'".$this->db->escape($this->visible)."', "; + $sql .= $this->db->escape($type).", "; + $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').", "; + $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').", "; + $sql .= (int) $conf->entity.", "; $sql .= "'".$this->db->idate($now)."', "; $sql .= (int) $user->id; $sql .= ")"; $res = $this->db->query($sql); - if ($res) - { + if ($res) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."categorie"); - if ($id > 0) - { + if ($id > 0) { $this->id = $id; $action = 'create'; // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error) - { + if (!$error) { // Call trigger $result = $this->call_trigger('CATEGORY_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return $id; } else { @@ -510,8 +502,7 @@ class Categorie extends CommonObject $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); $this->visible = ($this->visible != "" ? intval($this->visible) : 0); - if ($this->already_exists()) - { + if ($this->already_exists()) { $this->error = $langs->trans("ImpossibleUpdateCat"); $this->error .= " : ".$langs->trans("CategoryExistsAtSameLevel"); return -1; @@ -524,32 +515,27 @@ class Categorie extends CommonObject $sql .= " description = '".$this->db->escape($this->description)."',"; $sql .= " ref_ext = '".$this->db->escape($this->ref_ext)."',"; $sql .= " color = '".$this->db->escape($this->color)."'"; - if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) - { - $sql .= ", fk_soc = ".($this->socid != -1 ? $this->socid : 'null'); + if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { + $sql .= ", fk_soc = ".($this->socid > 0 ? $this->socid : 'null'); } - $sql .= ", visible = '".$this->db->escape($this->visible)."'"; - $sql .= ", fk_parent = ".$this->fk_parent; + $sql .= ", visible = ".(int) $this->visible; + $sql .= ", fk_parent = ".(int) $this->fk_parent; $sql .= ", fk_user_modif = ".(int) $user->id; $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $action = 'update'; // Actions on extra fields - if (!$error) - { + if (!$error) { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } - if (!$error) - { + if (!$error) { // Call trigger $result = $this->call_trigger('CATEGORY_MODIFY', $user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } @@ -586,8 +572,7 @@ class Categorie extends CommonObject $this->db->begin(); - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CATEGORY_DELETE', $user); if ($result < 0) $error++; @@ -595,14 +580,12 @@ class Categorie extends CommonObject } /* FIX #1317 : Check for child category and move up 1 level*/ - if (!$error) - { + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; $sql .= " SET fk_parent = ".$this->fk_parent; $sql .= " WHERE fk_parent = ".$this->id; - if (!$this->db->query($sql)) - { + if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); $error++; } @@ -630,18 +613,15 @@ class Categorie extends CommonObject } // Removed extrafields - if (!$error) - { + if (!$error) { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; dol_syslog(get_class($this)."::delete erreur ".$this->error, LOG_ERR); } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -676,29 +656,23 @@ class Categorie extends CommonObject $sql .= " VALUES (".$this->id.", ".$obj->id.")"; dol_syslog(get_class($this).'::add_type', LOG_DEBUG); - if ($this->db->query($sql)) - { - if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) - { + if ($this->db->query($sql)) { + if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) { $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'categorie'; $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::add_type", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql) > 0) - { + if ($resql) { + if ($this->db->num_rows($resql) > 0) { $objparent = $this->db->fetch_object($resql); - if (!empty($objparent->fk_parent)) - { + if (!empty($objparent->fk_parent)) { $cat = new Categorie($this->db); $cat->id = $objparent->fk_parent; if (!$cat->containsObject($type, $obj->id)) { $result = $cat->add_type($obj, $type); - if ($result < 0) - { + if ($result < 0) { $this->error = $cat->error; $error++; } @@ -710,8 +684,7 @@ class Categorie extends CommonObject $this->error = $this->db->lasterror(); } - if ($error) - { + if ($error) { $this->db->rollback(); return -1; } @@ -725,8 +698,7 @@ class Categorie extends CommonObject if ($result < 0) { $error++; } // End call triggers - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -735,8 +707,7 @@ class Categorie extends CommonObject } } else { $this->db->rollback(); - if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $this->error = $this->db->lasterrno(); return -3; } else { @@ -778,16 +749,14 @@ class Categorie extends CommonObject $sql .= " AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".$obj->id; dol_syslog(get_class($this).'::del_type', LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { // Call trigger $this->context = array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger $result = $this->call_trigger('CATEGORY_UNLINK', $user); if ($result < 0) { $error++; } // End call triggers - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -829,8 +798,7 @@ class Categorie extends CommonObject $sql .= " AND c.fk_categorie = ".$this->id; $sql .= " AND c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = o.rowid"; // Protection for external users - if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) - { + if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) { $sql .= " AND o.rowid = ".$user->socid; } if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset); @@ -838,10 +806,8 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($rec = $this->db->fetch_array($resql)) - { + if ($resql) { + while ($rec = $this->db->fetch_array($resql)) { if ($onlyids) { $objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])]; } else { @@ -927,20 +893,17 @@ class Categorie extends CommonObject $offset = 0; $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $this->db->query($sql); $nbtotalofrecords = $this->db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } } if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -949,17 +912,14 @@ class Categorie extends CommonObject } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $category_static = new Categorie($this->db); - if ($category_static->fetch($obj->rowid)) - { + if ($category_static->fetch($obj->rowid)) { $categories[$i]['id'] = $category_static->id; $categories[$i]['fk_parent'] = $category_static->fk_parent; $categories[$i]['label'] = $category_static->label; @@ -1004,11 +964,9 @@ class Categorie extends CommonObject $sql .= " AND entity IN (".getEntity('category').")"; $res = $this->db->query($sql); - if ($res) - { + if ($res) { $cats = array(); - while ($rec = $this->db->fetch_array($res)) - { + while ($rec = $this->db->fetch_array($res)) { $cat = new Categorie($this->db); $cat->fetch($rec['rowid']); $cats[] = $cat; @@ -1039,10 +997,8 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->motherof[$obj->id_son] = $obj->id_parent; } return 1; @@ -1083,19 +1039,15 @@ class Categorie extends CommonObject return -1; } - if (is_string($markafterid)) - { + if (is_string($markafterid)) { $markafterid = explode(',', $markafterid); - } elseif (is_numeric($markafterid)) - { - if ($markafterid > 0) - { + } elseif (is_numeric($markafterid)) { + if ($markafterid > 0) { $markafterid = array($markafterid); } else { $markafterid = array(); } - } elseif (!is_array($markafterid)) - { + } elseif (!is_array($markafterid)) { $markafterid = array(); } @@ -1115,11 +1067,9 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::get_full_arbo get category list", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $i = 0; - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['rowid'] = $obj->rowid; $this->cats[$obj->rowid]['id'] = $obj->rowid; $this->cats[$obj->rowid]['fk_parent'] = $obj->fk_parent; @@ -1137,15 +1087,13 @@ class Categorie extends CommonObject // We add the fullpath property to each elements of first level (no parent exists) dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); - foreach ($this->cats as $key => $val) - { + foreach ($this->cats as $key => $val) { //print 'key='.$key.'
    '."\n"; $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) } // Include or exclude leaf including $markafterid from tree - if (count($markafterid) > 0) - { + if (count($markafterid) > 0) { $keyfiltercatid = '('.implode('|', $markafterid).')'; //print "Look to discard category ".$markafterid."\n"; @@ -1153,13 +1101,11 @@ class Categorie extends CommonObject $keyfilter2 = '_'.$keyfiltercatid.'$'; $keyfilter3 = '^'.$keyfiltercatid.'_'; $keyfilter4 = '_'.$keyfiltercatid.'_'; - foreach ($this->cats as $key => $val) - { + foreach ($this->cats as $key => $val) { $test = (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])); - if (($test && !$include) || (!$test && $include)) - { + if (($test && !$include) || (!$test && $include)) { unset($this->cats[$key]); } } @@ -1189,8 +1135,7 @@ class Categorie extends CommonObject // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); - if (!empty($this->cats[$id_categ]['fullpath'])) - { + if (!empty($this->cats[$id_categ]['fullpath'])) { // Already defined dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING); return; @@ -1204,8 +1149,7 @@ class Categorie extends CommonObject $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label']; $i = 0; $cursor_categ = $id_categ; //print 'Work for id_categ='.$id_categ.'
    '."\n"; - while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ])) - { + while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ])) { //print '  cursor_categ='.$cursor_categ.' i='.$i.' '.$this->motherof[$cursor_categ].'
    '."\n"; $this->cats[$id_categ]['fullpath'] = '_'.$this->motherof[$cursor_categ].$this->cats[$id_categ]['fullpath']; $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->motherof[$cursor_categ]]['label'].' >> '.$this->cats[$id_categ]['fulllabel']; @@ -1231,8 +1175,7 @@ class Categorie extends CommonObject { // phpcs:enable // Display $this->cats - foreach ($this->cats as $key => $val) - { + foreach ($this->cats as $key => $val) { print 'id: '.$this->cats[$key]['id']; print ' label: '.$this->cats[$key]['label']; print ' mother: '.$this->cats[$key]['fk_parent']; @@ -1260,16 +1203,14 @@ class Categorie extends CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " WHERE entity IN (".getEntity('category').")"; if (!is_null($type)) - $sql .= " AND type = ".$type; + $sql .= " AND type = ".(int) $type; if ($parent) $sql .= " AND fk_parent = 0"; $res = $this->db->query($sql); - if ($res) - { + if ($res) { $cats = array(); - while ($rec = $this->db->fetch_array($res)) - { + while ($rec = $this->db->fetch_array($res)) { $cat = new Categorie($this->db); $cat->fetch($rec['rowid']); $cats[$rec['rowid']] = $cat; @@ -1319,18 +1260,15 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::already_exists", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql) > 0) // Checking for empty resql - { + if ($resql) { + if ($this->db->num_rows($resql) > 0) { // Checking for empty resql $obj = $this->db->fetch_array($resql); /* If object called create, obj cannot have is id. * If object called update, he mustn't have the same label as an other category for this mother. * So if the result have the same id, update is not for label, and if result have an other one, * update may be for label. */ - if ($obj[0] > 0 && $obj[0] != $this->id) - { + if ($obj[0] > 0 && $obj[0] != $this->id) { dol_syslog(get_class($this)."::already_exists category with name=".$this->label." and parent ".$this->fk_parent." exists: rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG); return 1; } @@ -1361,24 +1299,19 @@ class Categorie extends CommonObject $ways = array(); $allways = $this->get_all_ways(); // Load array of categories - foreach ($allways as $way) - { + foreach ($allways as $way) { $w = array(); $i = 0; $forced_color = ''; - foreach ($way as $cat) - { + foreach ($way as $cat) { $i++; - if (empty($nocolor)) - { + if (empty($nocolor)) { $forced_color = 'toreplace'; - if ($i == count($way)) - { + if ($i == count($way)) { // Check contrast with background and correct text color $forced_color = 'categtextwhite'; - if ($cat->color) - { + if ($cat->color) { if (colorIsLight($cat->color)) $forced_color = 'categtextblack'; } } @@ -1421,12 +1354,9 @@ class Categorie extends CommonObject $res = $this->db->query($sql); - if ($res) - { - while ($rec = $this->db->fetch_array($res)) - { - if ($rec['fk_parent'] > 0) - { + if ($res) { + while ($rec = $this->db->fetch_array($res)) { + if ($rec['fk_parent'] > 0) { $cat = new Categorie($this->db); $cat->fetch($rec['fk_parent']); $parents[] = $cat; @@ -1452,13 +1382,10 @@ class Categorie extends CommonObject $ways = array(); $parents = $this->get_meres(); - if (!empty($parents)) - { - foreach ($parents as $parent) - { + if (!empty($parents)) { + foreach ($parents as $parent) { $allways = $parent->get_all_ways(); - foreach ($allways as $way) - { + foreach ($allways as $way) { $w = $way; $w[] = $this; $ways[] = $w; @@ -1488,19 +1415,17 @@ class Categorie extends CommonObject if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; - if ($type === Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code - { - // Load bank groups + if ($type === Categorie::TYPE_BANK_LINE) { // TODO Remove this with standard category code after migration of llx_bank_categ into llx_categorie + // Load bank categories $sql = "SELECT c.label, c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; + $sql .= " AND c.entity IN (".getEntity('category').")"; $sql .= " ORDER BY c.label"; $res = $this->db->query($sql); - if ($res) - { - while ($obj = $this->db->fetch_object($res)) - { + if ($res) { + while ($obj = $this->db->fetch_object($res)) { if ($mode == 'id') { $cats[] = $obj->rowid; } elseif ($mode == 'label') { @@ -1523,10 +1448,8 @@ class Categorie extends CommonObject $sql .= " AND c.entity IN (".getEntity('category').")"; $res = $this->db->query($sql); - if ($res) - { - while ($obj = $this->db->fetch_object($res)) - { + if ($res) { + while ($obj = $this->db->fetch_object($res)) { if ($mode == 'id') { $cats[] = $obj->rowid; } elseif ($mode == 'label') { @@ -1579,24 +1502,20 @@ class Categorie extends CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " WHERE type = ".$this->MAP_ID[$type]; $sql .= " AND entity IN (".getEntity('category').")"; - if ($nom) - { + if ($nom) { if (!$exact) $nom = '%'.str_replace('*', '%', $nom).'%'; if (!$case) $sql .= " AND label LIKE '".$this->db->escape($nom)."'"; else $sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'"; } - if ($id) - { + if ($id) { $sql .= " AND rowid = '".$id."'"; } $res = $this->db->query($sql); - if ($res) - { - while ($rec = $this->db->fetch_array($res)) - { + if ($res) { + while ($rec = $this->db->fetch_array($res)) { $cat = new Categorie($this->db); $cat->fetch($rec['rowid']); $cats[] = $cat; @@ -1628,12 +1547,11 @@ class Categorie extends CommonObject // Check contrast with background and correct text color $forced_color = 'categtextwhite'; - if ($this->color) - { + if ($this->color) { if (colorIsLight($this->color)) $forced_color = 'categtextblack'; } - $link = ''; + $link = ''; $linkend = ''; $picto = 'category'; @@ -1662,14 +1580,12 @@ class Categorie extends CommonObject $dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, 'category').$this->id."/"; $dir .= "photos/"; - if (!file_exists($dir)) - { + if (!file_exists($dir)) { dol_mkdir($dir); } if (file_exists($dir)) { - if (is_array($file['name']) && count($file['name']) > 0) - { + if (is_array($file['name']) && count($file['name']) > 0) { $nbfile = count($file['name']); for ($i = 0; $i <= $nbfile; $i++) { $originImage = $dir.$file['name'][$i]; @@ -1714,22 +1630,17 @@ class Categorie extends CommonObject $dirthumb = $dir.'thumbs/'; - if (file_exists($dir)) - { + if (file_exists($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) { $nbphoto++; $photo = $file; // On determine nom du fichier vignette $photo_vignette = ''; - if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) - { + if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) { $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; } @@ -1773,11 +1684,9 @@ class Categorie extends CommonObject dol_delete_file($file, 1); // Si elle existe, on efface la vignette - if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $filename, $regs)) - { + if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $filename, $regs)) { $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $filename).'_small'.$regs[0]; - if (file_exists($dirthumb.$photo_vignette)) - { + if (file_exists($dirthumb.$photo_vignette)) { dol_delete_file($dirthumb.$photo_vignette, 1); } } @@ -1812,8 +1721,7 @@ class Categorie extends CommonObject $langs_available = $langs->get_available_languages(); $current_lang = $langs->getDefaultLang(); - foreach ($langs_available as $key => $value) - { + foreach ($langs_available as $key => $value) { $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang"; $sql .= " WHERE fk_category=".$this->id; @@ -1821,10 +1729,8 @@ class Categorie extends CommonObject $result = $this->db->query($sql); - if ($key == $current_lang) - { - if ($this->db->num_rows($result)) // si aucune ligne dans la base - { + if ($key == $current_lang) { + if ($this->db->num_rows($result)) { // si aucune ligne dans la base $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; $sql2 .= " SET label='".$this->db->escape($this->label)."',"; $sql2 .= " description='".$this->db->escape($this->description)."'"; @@ -1835,15 +1741,12 @@ class Categorie extends CommonObject $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')"; } dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if (!$this->db->query($sql2)) - { + if (!$this->db->query($sql2)) { $this->error = $this->db->lasterror(); return -1; } - } elseif (isset($this->multilangs["$key"])) - { - if ($this->db->num_rows($result)) // si aucune ligne dans la base - { + } elseif (isset($this->multilangs["$key"])) { + if ($this->db->num_rows($result)) { // si aucune ligne dans la base $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang"; $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; @@ -1857,8 +1760,7 @@ class Categorie extends CommonObject // on ne sauvegarde pas des champs vides if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"]) dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG); - if (!$this->db->query($sql2)) - { + if (!$this->db->query($sql2)) { $this->error = $this->db->lasterror(); return -1; } @@ -1892,13 +1794,10 @@ class Categorie extends CommonObject $sql .= " WHERE fk_category=".$this->id; $result = $this->db->query($sql); - if ($result) - { - while ($obj = $this->db->fetch_object($result)) - { + if ($result) { + while ($obj = $this->db->fetch_object($result)) { //print 'lang='.$obj->lang.' current='.$current_lang.'
    '; - if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. - { + if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales. $this->label = $obj->label; $this->description = $obj->description; } @@ -1988,26 +1887,21 @@ class Categorie extends CommonObject { if ($type == 'bank_account') $type = 'account'; - if (empty($searchList) && !is_array($searchList)) - { + if (empty($searchList) && !is_array($searchList)) { return ""; } - foreach ($searchList as $searchCategory) - { - if (intval($searchCategory) == -2) - { + foreach ($searchList as $searchCategory) { + if (intval($searchCategory) == -2) { $searchCategorySqlList[] = " cp.fk_categorie IS NULL"; - } elseif (intval($searchCategory) > 0) - { + } elseif (intval($searchCategory) > 0) { $searchCategorySqlList[] = " ".$rowIdName ." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type ." WHERE fk_categorie = ".$searchCategory.")"; } } - if (!empty($searchCategorySqlList)) - { + if (!empty($searchCategorySqlList)) { return " AND (".implode(' AND ', $searchCategorySqlList).")"; } else { return ""; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 7c8c683bf18..a27295fcd84 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -3,6 +3,7 @@ * Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,20 +35,19 @@ $langs->load("categories"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alphanohtml'); -$type = GETPOST('type', 'alphanohtml'); +$type = (int) GETPOST('type', 'int'); $action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit'); $confirm = GETPOST('confirm'); $cancel = GETPOST('cancel', 'alpha'); -$socid = GETPOST('socid', 'int'); -$label = GETPOST('label', 'alphanohtml'); -$description = GETPOST('description', 'restricthtml'); -$color = preg_replace('/[^0-9a-f#]/i', '', GETPOST('color', 'alphanohtml')); -$visible = GETPOST('visible'); -$parent = GETPOST('parent'); +$socid = (int) GETPOST('socid', 'int'); +$label = (string) GETPOST('label', 'alphanohtml'); +$description = (string) GETPOST('description', 'restricthtml'); +$color = preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('color', 'alphanohtml')); +$visible = (int) GETPOST('visible', 'int'); +$parent = (int) GETPOST('parent', 'int'); -if ($id == "") -{ +if ($id == "") { dol_print_error('', 'Missing parameter id'); exit(); } @@ -56,9 +56,8 @@ if ($id == "") $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -if ($id > 0) -{ - $result = $object->fetch($id); +if ($id > 0) { + $result = $object->fetch($id); } $extrafields = new ExtraFields($db); @@ -67,45 +66,39 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard')); +$error = 0; + /* * Actions */ -if ($cancel) -{ - header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); - exit; +if ($cancel) { + header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); + exit; } // Action mise a jour d'une categorie -if ($action == 'update' && $user->rights->categorie->creer) -{ - $object->oldcopy = dol_clone($object); +if ($action == 'update' && $user->rights->categorie->creer) { + $object->oldcopy = dol_clone($object); $object->label = $label; $object->description = dol_htmlcleanlastbr($description); $object->color = $color; - $object->socid = ($socid ? $socid : 'null'); + $object->socid = ($socid > 0 ? $socid : 0); $object->visible = $visible; - - if ($parent != "-1") - $object->fk_parent = $parent; - else $object->fk_parent = ""; + $object->fk_parent = $parent != -1 ? $parent : 0; - if (empty($object->label)) - { - $error++; + if (empty($object->label)) { + $error++; $action = 'edit'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } - if (!$error && empty($object->error)) - { + if (!$error && empty($object->error)) { $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (!$error && $object->update($user) > 0) - { + if (!$error && $object->update($user) > 0) { header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); exit; } else { @@ -139,7 +132,7 @@ print ''; print ''; print ''; -dol_fiche_head(''); +print dol_get_fiche_head(''); print ''; @@ -173,15 +166,14 @@ print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (empty($reshook)) -{ +if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); print '
     
    '; diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index bef54f9dd6b..f64f3be8f9e 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -44,8 +44,8 @@ $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); if (!$object->fetch($id) > 0) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } $type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -64,7 +64,7 @@ $title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $head = categories_prepare_head($object, $type); -dol_fiche_head($head, 'info', $langs->trans($title), -1, 'category'); +print dol_get_fiche_head($head, 'info', $langs->trans($title), -1, 'category'); $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = ' type = '.$type; @@ -72,7 +72,7 @@ $object->ref = $object->label; $morehtmlref = '
    '.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); foreach ($ways as $way) { - $morehtmlref .= $way."
    \n"; + $morehtmlref .= $way."
    \n"; } $morehtmlref .= '
    '; @@ -95,7 +95,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 866a98fd816..73c7664f6c2 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -117,7 +117,7 @@ if ($object->id) $head = categories_prepare_head($object, $type); - dol_fiche_head($head, 'photos', $langs->trans($title), -1, 'category'); + print dol_get_fiche_head($head, 'photos', $langs->trans($title), -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = ' type = '.$object->type; @@ -161,7 +161,7 @@ if ($object->id) print "\n"; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index f4e073c4e1c..660dbf9317d 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -187,7 +187,7 @@ if (!empty($object->multilangs)) } } -dol_fiche_head($head, 'translation', $langs->trans($title), -1, 'category'); +print dol_get_fiche_head($head, 'translation', $langs->trans($title), -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = ' type = '.$object->type; @@ -223,7 +223,7 @@ print ''; print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 30b706a4b3a..8c1eccfa846 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2020 Josep Lluís Amador * * 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 @@ -125,19 +126,19 @@ if ($id > 0 && $removeelem > 0) $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; - } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) - { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $tmpobject = new Account($db); - $result = $tmpobject->fetch($removeelem); - $elementtype = 'account'; - } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) - { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $tmpobject = new Project($db); - $result = $tmpobject->fetch($removeelem); - $elementtype = 'project'; - } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) + } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $tmpobject = new Account($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'account'; + } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) + { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $tmpobject = new Project($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'project'; + } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $tmpobject = new User($db); @@ -160,12 +161,29 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi } } -if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer)) +if ($elemid && $action == 'addintocategory' && + (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || + ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || + ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) + )) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $newobject = new Product($db); + if ($type == Categorie::TYPE_PRODUCT) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $newobject = new Product($db); + $elementtype = 'product'; + } elseif ($type == Categorie::TYPE_CUSTOMER) + { + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $newobject = new Societe($db); + $elementtype = 'customer'; + } elseif ($type == Categorie::TYPE_SUPPLIER) + { + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $newobject = new Societe($db); + $elementtype = 'supplier'; + } $result = $newobject->fetch($elemid); - $elementtype = 'product'; // TODO Add into categ $result = $object->add_type($newobject, $elementtype); @@ -200,7 +218,7 @@ $title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $head = categories_prepare_head($object, $type); -dol_fiche_head($head, 'card', $langs->trans($title), -1, 'category'); +print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category'); $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = ' type = '.$object->type; @@ -209,7 +227,7 @@ $morehtmlref = '
    '; @@ -249,7 +267,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* @@ -260,13 +278,13 @@ print ""; @@ -513,6 +531,27 @@ if ($type == Categorie::TYPE_SUPPLIER) { dol_print_error($db, $object->error, $object->errors); } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) + { + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '; + print $langs->trans("AddSupplierIntoCategory").'  '; + print $form->select_company('', 'elemid', 's.fournisseur = 1'); + print '
    '; + print ''; + } + print '
    '; print ''; print ''; @@ -570,6 +609,27 @@ if ($type == Categorie::TYPE_CUSTOMER) { dol_print_error($db, $object->error, $object->errors); } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) + { + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '; + print $langs->trans("AddCustomerIntoCategory").'  '; + print $form->select_company('', 'elemid', 's.client IN (1,3)'); + print '
    '; + print '
    '; + } + print '
    '; print ''; print ''; @@ -741,61 +801,61 @@ if ($type == Categorie::TYPE_CONTACT) // List of bank accounts if ($type == Categorie::TYPE_ACCOUNT) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $permission = $user->rights->banque->creer; + $permission = $user->rights->banque->creer; - $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($accounts < 0) - { - dol_print_error($db, $object->error, $object->errors); - } else { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($accounts < 0) + { + dol_print_error($db, $object->error, $object->errors); + } else { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print '
    '; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($accounts); $nbtotalofrecords = ''; $newcardbutton = ''; - print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); + print '
    '; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($accounts); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); - print "\n"; - print ''."\n"; + print "
    '.$langs->trans("Ref").'
    \n"; + print ''."\n"; - if (count($accounts) > 0) - { - $i = 0; - foreach ($accounts as $key => $account) - { - $i++; - if ($i > $limit) break; + if (count($accounts) > 0) + { + $i = 0; + foreach ($accounts as $key => $account) + { + $i++; + if ($i > $limit) break; - print "\t".''."\n"; - print '\n"; - print '\n"; - print '\n"; - // Link to delete from category - print '\n"; - } - } else { - print ''; - } - print "
    '.$langs->trans("Ref").'
    '; - print $account->getNomUrl(1, 0); - print "'.$account->bank."'.$account->number."'; - if ($permission) - { - print ""; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print "
    '.$langs->trans("ThisCategoryHasNoItems").'
    \n"; + print "\t".''."\n"; + print ''; + print $account->getNomUrl(1, 0); + print "\n"; + print ''.$account->bank."\n"; + print ''.$account->number."\n"; + // Link to delete from category + print ''; + if ($permission) + { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "\n"; + } + } else { + print ''.$langs->trans("ThisCategoryHasNoItems").''; + } + print "\n"; - print '
    '."\n"; - } + print ''."\n"; + } } // List of Project diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 4b88cc7797a..0b1eba637d4 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -71,8 +71,6 @@ $offsetunit = GETPOST('offsetunittype_duration', 'aZ09'); $remindertype = GETPOST('selectremindertype', 'aZ09'); $modelmail = GETPOST('actioncommsendmodel_mail', 'int'); -//var_dump($_POST); exit; - $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); @@ -98,21 +96,19 @@ $formactions = new FormActions($db); // Load object if ($id > 0 && $action != 'add') { - $ret = $object->fetch($id); - if ($ret > 0) { - $ret = $object->fetch_optionals(); - $ret1 = $object->fetch_userassigned(); - } - if ($ret < 0 || $ret1 < 0) { - dol_print_error('', $object->error); - } + $ret = $object->fetch($id); + if ($ret > 0) { + $ret = $object->fetch_optionals(); + $ret1 = $object->fetch_userassigned(); + } + if ($ret < 0 || $ret1 < 0) { + dol_print_error('', $object->error); + } } // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -//var_dump($_POST); - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('actioncard', 'globalcard')); @@ -144,7 +140,7 @@ if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') { if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]); } - //var_dump($_POST['removedassigned']);exit; + $_SESSION['assignedtouser'] = json_encode($tmpassigneduserids); $donotclearsession = 1; if ($action == 'add') $action = 'create'; @@ -176,10 +172,10 @@ if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedt // Link to a project if (empty($reshook) && $action == 'classin' && ($user->rights->agenda->allactions->create || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) { - //$object->fetch($id); - $object->setProject(GETPOST('projectid', 'int')); + //$object->fetch($id); + $object->setProject(GETPOST('projectid', 'int')); } // Action clone object @@ -191,10 +187,10 @@ if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') } else { if ($id > 0) { //$object->fetch($id); - if (!empty($object->socpeopleassigned)) { - reset($object->socpeopleassigned); - $object->contact_id = key($object->socpeopleassigned); - } + if (!empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contact_id = key($object->socpeopleassigned); + } $result = $object->createFromClone($user, GETPOST('socid', 'int')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -212,13 +208,13 @@ if (empty($reshook) && $action == 'add') { $error = 0; - if (empty($backtopage)) - { - if ($socid > 0) $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; - else $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; - } + if (empty($backtopage)) + { + if ($socid > 0) $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; + else $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; + } - if (!empty($socpeopleassigned[0])) + if (!empty($socpeopleassigned[0])) { $result = $contact->fetch($socpeopleassigned[0]); } @@ -229,9 +225,9 @@ if (empty($reshook) && $action == 'add') exit; } - $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status - // Clean parameters + // Clean parameters $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); @@ -288,13 +284,13 @@ if (empty($reshook) && $action == 'add') $taskid = GETPOST('taskid', 'int'); if (!empty($taskid)) { - $taskProject = new Task($db); - if ($taskProject->fetch($taskid) > 0) { - $object->fk_project = $taskProject->fk_project; - } + $taskProject = new Task($db); + if ($taskProject->fetch($taskid) > 0) { + $object->fk_project = $taskProject->fk_project; + } - $object->fk_element = $taskid; - $object->elementtype = 'task'; + $object->fk_element = $taskid; + $object->elementtype = 'task'; } $object->datep = $datep; @@ -393,27 +389,27 @@ if (empty($reshook) && $action == 'add') $moreparam = ''; if ($user->id != $object->userownerid) $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. - //Create reminders - if ($addreminder == 'on'){ - $actionCommReminder = new ActionCommReminder($db); + // Create reminders + if ($addreminder == 'on') { + $actionCommReminder = new ActionCommReminder($db); - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); - $actionCommReminder->dateremind = $dateremind; - $actionCommReminder->typeremind = $remindertype; - $actionCommReminder->offsetunit = $offsetunit; - $actionCommReminder->offsetvalue = $offsetvalue; - $actionCommReminder->status = $actionCommReminder::STATUS_TODO; - $actionCommReminder->fk_actioncomm = $object->id; - if ($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail; + $actionCommReminder->dateremind = $dateremind; + $actionCommReminder->typeremind = $remindertype; + $actionCommReminder->offsetunit = $offsetunit; + $actionCommReminder->offsetvalue = $offsetvalue; + $actionCommReminder->status = $actionCommReminder::STATUS_TODO; + $actionCommReminder->fk_actioncomm = $object->id; + if ($remindertype == 'email') $actionCommReminder->fk_email_template = $modelmail; - // the notification must be created for every user assigned to the event + // the notification must be created for every user assigned to the event foreach ($object->userassigned as $userassigned) { $actionCommReminder->fk_user = $userassigned['id']; $res = $actionCommReminder->create($user); - if ($res <= 0){ + if ($res <= 0) { // If error $db->rollback(); $langs->load("errors"); @@ -423,13 +419,13 @@ if (empty($reshook) && $action == 'add') break; } } - } + } - if ($error) { - $db->rollback(); - } else { + if ($error) { + $db->rollback(); + } else { $db->commit(); - } + } if (!empty($backtopage)) { @@ -465,14 +461,14 @@ if (empty($reshook) && $action == 'update') { if (empty($cancel)) { - $fulldayevent = GETPOST('fullday'); - $aphour = GETPOST('aphour'); - $apmin = GETPOST('apmin'); - $p2hour = GETPOST('p2hour'); - $p2min = GETPOST('p2min'); + $fulldayevent = GETPOST('fullday'); + $aphour = GETPOST('aphour'); + $apmin = GETPOST('apmin'); + $p2hour = GETPOST('p2hour'); + $p2min = GETPOST('p2min'); $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status - // Clean parameters + // Clean parameters if ($aphour == -1) $aphour = '0'; if ($apmin == -1) $apmin = '0'; if ($p2hour == -1) $p2hour = '0'; @@ -492,17 +488,17 @@ if (empty($reshook) && $action == 'update') $object->datef = $datef; $object->percentage = $percentage; $object->priority = GETPOST("priority", "int"); - $object->fulldayevent = GETPOST("fullday") ? 1 : 0; - $object->location = GETPOST('location', "alphanohtml"); + $object->fulldayevent = GETPOST("fullday") ? 1 : 0; + $object->location = GETPOST('location', "alphanohtml"); $object->socid = GETPOST("socid", "int"); $socpeopleassigned = GETPOST("socpeopleassigned", 'array'); $object->socpeopleassigned = array(); foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array('id' => $cid); - $object->contact_id = GETPOST("contactid", 'int'); - if (empty($object->contact_id) && !empty($object->socpeopleassigned)) { - reset($object->socpeopleassigned); - $object->contact_id = key($object->socpeopleassigned); - } + $object->contact_id = GETPOST("contactid", 'int'); + if (empty($object->contact_id) && !empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contact_id = key($object->socpeopleassigned); + } $object->fk_project = GETPOST("projectid", 'int'); $object->note_private = trim(GETPOST("note", "restricthtml")); $object->fk_element = GETPOST("fk_element", "int"); @@ -568,64 +564,64 @@ if (empty($reshook) && $action == 'update') $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (!$error) { - // check if an event resource is already in use - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { - $eventDateStart = $object->datep; - $eventDateEnd = $object->datef; + if (!$error) { + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { + $eventDateStart = $object->datep; + $eventDateEnd = $object->datef; - $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; - $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; - $sql .= " WHERE ac.id != ".$object->id; - $sql .= " AND er.resource_id IN ("; - $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; - $sql .= " WHERE element_id = ".$object->id; - $sql .= " AND element_type = '".$db->escape($object->element)."'"; - $sql .= " AND busy = 1"; - $sql .= ")"; - $sql .= " AND er.busy = 1"; - $sql .= " AND ("; + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; + $sql .= " WHERE ac.id != ".$object->id; + $sql .= " AND er.resource_id IN ("; + $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; + $sql .= " WHERE element_id = ".$object->id; + $sql .= " AND element_type = '".$db->escape($object->element)."'"; + $sql .= " AND busy = 1"; + $sql .= ")"; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; - // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) - $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; - // event date end between ac.datep and ac.datep2 - if (!empty($eventDateEnd)) { - $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; - } - // event date start before ac.datep and event date end after ac.datep2 - $sql .= " OR ("; - $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; - if (!empty($eventDateEnd)) { - $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; - } - $sql .= ")"; + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; + } + $sql .= ")"; - $sql .= ")"; - $resql = $db->query($sql); - if (!$resql) { - $error++; - $object->error = $db->lasterror(); - $object->errors[] = $object->error; - } else { - if ($db->num_rows($resql) > 0) { - // already in use - $error++; - $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; - while ($obj = $db->fetch_object($resql)) { - $object->error .= '
    - '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); - } - $object->errors[] = $object->error; - } - $db->free($resql); - } + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql) > 0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
    - '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); + } + $object->errors[] = $object->error; + } + $db->free($resql); + } - if ($error) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } if (!$error) { @@ -650,7 +646,7 @@ if (empty($reshook) && $action == 'update') } //Create reminders - if ($addreminder == 'on' && $object->datep > dol_now()){ + if ($addreminder == 'on' && $object->datep > dol_now()) { $actionCommReminder = new ActionCommReminder($db); $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); @@ -669,7 +665,7 @@ if (empty($reshook) && $action == 'update') $actionCommReminder->fk_user = $userassigned['id']; $res = $actionCommReminder->create($user); - if ($res <= 0){ + if ($res <= 0) { // If error $langs->load("errors"); $error = $langs->trans('ErrorReminderActionCommCreation'); @@ -693,12 +689,12 @@ if (empty($reshook) && $action == 'update') if (!$error) { - if (!empty($backtopage)) - { - unset($_SESSION['assignedtouser']); - header("Location: ".$backtopage); - exit; - } + if (!empty($backtopage)) + { + unset($_SESSION['assignedtouser']); + header("Location: ".$backtopage); + exit; + } } } @@ -708,9 +704,9 @@ if (empty($reshook) && $action == 'update') if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes') { $object->fetch($id); - $object->fetch_optionals(); - $object->fetch_userassigned(); - $object->oldcopy = clone $object; + $object->fetch_optionals(); + $object->fetch_userassigned(); + $object->oldcopy = clone $object; if ($user->rights->agenda->myactions->delete || $user->rights->agenda->allactions->delete) @@ -733,112 +729,112 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes */ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { - $error = 0; + $error = 0; - $shour = dol_print_date($object->datep, "%H"); - $smin = dol_print_date($object->datep, "%M"); + $shour = dol_print_date($object->datep, "%H"); + $smin = dol_print_date($object->datep, "%M"); - $newdate = GETPOST('newdate', 'alpha'); - if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) - { - header("Location: ".$backtopage); - exit; - } + $newdate = GETPOST('newdate', 'alpha'); + if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) + { + header("Location: ".$backtopage); + exit; + } - $datep = dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4)); - if ($datep != $object->datep) - { - if (!empty($object->datef)) - { - $object->datef += $datep - $object->datep; - } - $object->datep = $datep; + $datep = dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4)); + if ($datep != $object->datep) + { + if (!empty($object->datef)) + { + $object->datef += $datep - $object->datep; + } + $object->datep = $datep; - if (!$error) { - // check if an event resource is already in use - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { - $eventDateStart = $object->datep; - $eventDateEnd = $object->datef; + if (!$error) { + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { + $eventDateStart = $object->datep; + $eventDateEnd = $object->datef; - $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; - $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; - $sql .= " WHERE ac.id != ".$object->id; - $sql .= " AND er.resource_id IN ("; - $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; - $sql .= " WHERE element_id = ".$object->id; - $sql .= " AND element_type = '".$db->escape($object->element)."'"; - $sql .= " AND busy = 1"; - $sql .= ")"; - $sql .= " AND er.busy = 1"; - $sql .= " AND ("; + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; + $sql .= " WHERE ac.id != ".$object->id; + $sql .= " AND er.resource_id IN ("; + $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; + $sql .= " WHERE element_id = ".$object->id; + $sql .= " AND element_type = '".$db->escape($object->element)."'"; + $sql .= " AND busy = 1"; + $sql .= ")"; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; - // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) - $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; - // event date end between ac.datep and ac.datep2 - if (!empty($eventDateEnd)) { - $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; - } - // event date start before ac.datep and event date end after ac.datep2 - $sql .= " OR ("; - $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; - if (!empty($eventDateEnd)) { - $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; - } - $sql .= ")"; + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; + } + $sql .= ")"; - $sql .= ")"; - $resql = $db->query($sql); - if (!$resql) { - $error++; - $object->error = $db->lasterror(); - $object->errors[] = $object->error; - } else { - if ($db->num_rows($resql) > 0) { - // already in use - $error++; - $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; - while ($obj = $db->fetch_object($resql)) { - $object->error .= '
    - '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); - } - $object->errors[] = $object->error; - } - $db->free($resql); - } + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql) > 0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
    - '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); + } + $object->errors[] = $object->error; + } + $db->free($resql); + } - if ($error) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } - if (!$error) { - $db->begin(); - $result = $object->update($user); - if ($result < 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); - } else { - $db->commit(); - } - } - } - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } else { - $action = ''; - } + if (!$error) { + $db->begin(); + $result = $object->update($user); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } else { + $db->commit(); + } + } + } + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } else { + $action = ''; + } } // Actions to delete doc $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); $permissiontoadd = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read)); if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -873,10 +869,10 @@ if ($action == 'create') dol_set_focus("#label"); - if (!empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - } + print ''."\n"; + } print '
    '; print ''; @@ -939,7 +935,7 @@ if ($action == 'create') if (GETPOST("actioncode", 'aZ09') == 'AC_RDV') print load_fiche_titre($langs->trans("AddActionRendezVous"), '', 'title_agenda'); else print load_fiche_titre($langs->trans("AddAnAction"), '', 'title_agenda'); - dol_fiche_head(); + print dol_get_fiche_head(); print ''; @@ -955,39 +951,39 @@ if ($action == 'create') // Title print 'global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Label").''; - // Full day - print ''; + // Full day + print ''; - $datep = ($datep ? $datep : $object->datep); - if (GETPOST('datep', 'int', 1)) $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0); - $datef = ($datef ? $datef : $object->datef); - if (GETPOST('datef', 'int', 1)) $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0); - 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'); - } - } + $datep = ($datep ? $datep : $object->datep); + if (GETPOST('datep', 'int', 1)) $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0); + $datef = ($datef ? $datef : $object->datef); + if (GETPOST('datef', 'int', 1)) $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0); + 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 + // Date start print ''; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); + } else { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); + } + print ''; // Date end /*print '';*/ - // Dev in progress + // Dev in progress $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); if ($userepeatevent) { @@ -1065,29 +1061,32 @@ if ($action == 'create') $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) - { + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { print ''; - } + } // Assigned to print ''; } @@ -1122,8 +1121,7 @@ if ($action == 'create') { // Related company print '\n"; } elseif ($tmpday <= $max_day_in_month) { @@ -1278,14 +1278,14 @@ if (empty($action) || $action == 'show_month') // View by month if ($today) $style = 'cal_today'; if ($curtime < $todaytms) $style .= ' cal_past'; //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); - echo ' \n"; + echo "\n"; } else { /* Show days after the current month (next month) */ $style = 'cal_other_month'; if ($iter_day == 6) $style .= ' cal_other_month_right'; - echo ' \n"; } @@ -1477,28 +1477,30 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa print "\n"; - // Line with title of day $curtime = dol_mktime(0, 0, 0, $month, $day, $year); - print '
    '."\n"; + $urltoshow = DOL_URL_ROOT.'/comm/action/index.php?action=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year.$newparam; + $urltocreate = ''; + if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) + { + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; + $hourminsec = '100000'; + $urltocreate = DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $year, $month, $day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); + } + + // Line with title of day + print '
    '."\n"; if ($nonew <= 0) { - print '
    '; - print ''; + print '
    '; + print '
    '; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { - $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; - - //$param='month='.$monthshown.'&year='.$year; - $hourminsec = '100000'; - print ''; + print ''; // Explicit link, usefull for nojs interfaces print img_picto($langs->trans("NewAction"), 'edit_add.png'); print ''; } @@ -1838,7 +1840,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa break; } } - if (!$i) print ' '; + if (!$i) { // No events + print ' '; + } if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) { diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 8575ac67653..40787abb8c3 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -29,8 +29,8 @@ 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)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page @@ -41,8 +41,8 @@ $id = GETPOST('id', 'int'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); @@ -62,7 +62,7 @@ $object->fetch($id); $object->info($object->id); $head = actions_prepare_head($object); -dol_fiche_head($head, 'info', $langs->trans("Action"), -1, 'action'); +print dol_get_fiche_head($head, 'info', $langs->trans("Action"), -1, 'action'); $linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); $linkback .= ''.$langs->trans("BackToList").''; @@ -86,19 +86,19 @@ $morehtmlref = '
    '; // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - //$morehtmlref.='
    '.$langs->trans('Project') . ' '; - $morehtmlref .= $langs->trans('Project').': '; - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - if ($proj->title) $morehtmlref .= ' - '.$proj->title; - } else { - $morehtmlref .= ''; - } + $langs->load("projects"); + //$morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').': '; + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; + } else { + $morehtmlref .= ''; + } } $morehtmlref .= '
    '; @@ -112,7 +112,7 @@ print '
    '.$langs->trans("EventOnFullDay").'
    '.$langs->trans("EventOnFullDay").'
    '; 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'); // 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'); - } - print '     -     '; + print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart'); // 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'); + } + print '     -     '; //print ' - '; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); - } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); - } - print '
    '; @@ -1001,7 +997,7 @@ if ($action == 'create') } print '
    '.$langs->trans("Location").'
    '.$langs->trans("ActionAffectedTo").''; $listofuserid = array(); $listofcontactid = array(); $listofotherid = array(); + if (empty($donotclearsession)) { $assignedtouser = GETPOST("assignedtouser") ?GETPOST("assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id); if ($assignedtouser) $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first - $listofuserid[$user->id]['transparency'] = GETPOSTISSET('transparency') ?GETPOST('transparency', 'alpha') : 1; // 1 by default at first init + //$listofuserid[$user->id] = array('id'=>$user->id, 'mandatory'=>0, 'transparency'=>(GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1)); // 1 by default at first init + $listofuserid[$assignedtouser]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1); // 1 by default at first init $_SESSION['assignedtouser'] = json_encode($listofuserid); } else { if (!empty($_SESSION['assignedtouser'])) { $listofuserid = json_decode($_SESSION['assignedtouser'], true); } - $listofuserid[$user->id]['transparency'] = GETPOSTISSET('transparency') ?GETPOST('transparency', 'alpha') : 0; // 0 by default when refreshing + $firstelem = reset($listofuserid); + if (isset($listofuserid[$firstelem['id']])) $listofuserid[$firstelem['id']]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 0); // 0 by default when refreshing } print '
    '; print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid); @@ -1098,7 +1097,7 @@ if ($action == 'create') if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) { print '
    '.$langs->trans("ActionDoneBy").''; - print $form->select_dolusers(GETPOST("doneby") ?GETPOST("doneby") : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0), 'doneby', 1); + print $form->select_dolusers(GETPOSTISSET("doneby") ? GETPOST("doneby", 'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0), 'doneby', 1); print '
    '.$langs->trans("ActionOnCompany").''; - if (GETPOST('socid', 'int') > 0) - { + if (GETPOST('socid', 'int') > 0) { $societe = new Societe($db); $societe->fetch(GETPOST('socid', 'int')); print $societe->getNomUrl(1); @@ -1158,7 +1156,7 @@ if ($action == 'create') print '
    '.$langs->trans("Project").''; print img_picto('', 'project', 'class="paddingrightonly"'); - $numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500 widthcentpercentminusxx'); + print $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); print ' '; $urloption = '?action=create&donotclearsession=1'; @@ -1168,10 +1166,11 @@ if ($action == 'create') print "\n".''."\n"; - } + print ''."\n"; + } - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1328,7 +1327,7 @@ if ($id > 0) if ($listUserAssignedUpdated || $donotclearsession) { - $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); @@ -1339,7 +1338,7 @@ if ($id > 0) $object->datef = $datef; $object->percentage = $percentage; $object->priority = GETPOST("priority", "alphanohtml"); - $object->fulldayevent = GETPOST("fullday") ? 1 : 0; + $object->fulldayevent = GETPOST("fullday") ? 1 : 0; $object->location = GETPOST('location', "alpanohtml"); $object->socid = GETPOST("socid", "int"); $socpeopleassigned = GETPOST("socpeopleassigned", 'array'); @@ -1347,7 +1346,7 @@ if ($id > 0) $object->contact_id = GETPOST("contactid", 'int'); $object->fk_project = GETPOST("projectid", 'int'); - $object_private = GETPOST("note", 'restricthtml'); + $object->note_private = GETPOST("note", 'restricthtml'); } if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) @@ -1377,10 +1376,10 @@ if ($id > 0) if ($action == 'edit') { - if (!empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - } + print ''."\n"; + } print ''; print ''; @@ -1411,7 +1410,7 @@ if ($id > 0) if ($backtopage) print ''; if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) print ''; - dol_fiche_head($head, 'card', $langs->trans("Action"), 0, 'action'); + print dol_get_fiche_head($head, 'card', $langs->trans("Action"), 0, 'action'); print ''; @@ -1421,42 +1420,42 @@ if ($id > 0) // Type of event if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''; } // Title print ''; - // Full day event - print ''; + // Full day event + print ''; // Date start print ''; - // Dev in progress + // Dev in progress $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); if ($userepeatevent) { @@ -1513,50 +1512,50 @@ if ($id > 0) $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) - { + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { print ''; - } + } // Assigned to - $listofuserid = array(); // User assigned - if (empty($donotclearsession)) - { - if ($object->userownerid > 0) - { - $listofuserid[$object->userownerid] = array( - 'id'=>$object->userownerid, - 'type'=>'user', - //'transparency'=>$object->userassigned[$user->id]['transparency'], - 'transparency'=>$object->transparency, // Force transparency on ownerfrom event - 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], - 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] - ); - } - if (!empty($object->userassigned)) // Now concat assigned users - { - // Restore array with key with same value than param 'id' - $tmplist1 = $object->userassigned; - foreach ($tmplist1 as $key => $val) - { - if ($val['id'] && $val['id'] != $object->userownerid) - { - $listofuserid[$val['id']] = $val; - } - } - } - $_SESSION['assignedtouser'] = json_encode($listofuserid); - } else { - if (!empty($_SESSION['assignedtouser'])) - { - $listofuserid = json_decode($_SESSION['assignedtouser'], true); - } - } - $listofcontactid = $object->socpeopleassigned; // Contact assigned - $listofotherid = $object->otherassigned; // Other undefined email (not used yet) + $listofuserid = array(); // User assigned + if (empty($donotclearsession)) + { + if ($object->userownerid > 0) + { + $listofuserid[$object->userownerid] = array( + 'id'=>$object->userownerid, + 'type'=>'user', + //'transparency'=>$object->userassigned[$user->id]['transparency'], + 'transparency'=>$object->transparency, // Force transparency on ownerfrom event + 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], + 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] + ); + } + if (!empty($object->userassigned)) // Now concat assigned users + { + // Restore array with key with same value than param 'id' + $tmplist1 = $object->userassigned; + foreach ($tmplist1 as $key => $val) + { + if ($val['id'] && $val['id'] != $object->userownerid) + { + $listofuserid[$val['id']] = $val; + } + } + } + $_SESSION['assignedtouser'] = json_encode($listofuserid); + } else { + if (!empty($_SESSION['assignedtouser'])) + { + $listofuserid = json_decode($_SESSION['assignedtouser'], true); + } + } + $listofcontactid = $object->socpeopleassigned; // Contact assigned + $listofotherid = $object->otherassigned; // Other undefined email (not used yet) - print ''; } // Tags-Categories - if ($conf->categorie->enabled) { + if ($conf->categorie->enabled) { print ''; @@ -1646,19 +1645,19 @@ if ($id > 0) if (!empty($object->fk_element) && !empty($object->elementtype)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print ''; + print ''; print ''; if ($object->elementtype == 'task' && !empty($conf->projet->enabled)) { - print ''; + print ''; } else { - print ''; + print ''; } print ''; } - // Description - print ''; + // Description + print ''; - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } @@ -1783,7 +1782,7 @@ if ($id > 0) print ''."\n"; } - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1793,7 +1792,7 @@ if ($id > 0) print ''; } else { - dol_fiche_head($head, 'card', $langs->trans("Action"), -1, 'action'); + print dol_get_fiche_head($head, 'card', $langs->trans("Action"), -1, 'action'); // Clone event @@ -1833,46 +1832,46 @@ if ($id > 0) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - //$morehtmlref.='
    '.$langs->trans('Project') . ' '; - $morehtmlref .= $langs->trans('Project').' '; - if ($user->rights->agenda->allactions->create || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) - { - if ($action != 'classify') { + $langs->load("projects"); + //$morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; + if ($user->rights->agenda->allactions->create || + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) + { + if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - } - 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 .= ''; - if ($proj->title) $morehtmlref .= ' - '.$proj->title; - } else { - $morehtmlref .= ''; - } - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
    '; + $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 .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
    '; dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref); - print '
    '; - print '
    '; + print '
    '; + print '
    '; print '
    '; @@ -1885,8 +1884,8 @@ if ($id > 0) print '
    '; } - // Full day event - print ''; + // Full day event + print ''; $rowspan = 4; if (empty($conf->global->AGENDA_DISABLE_LOCATION)) $rowspan++; @@ -1901,19 +1900,19 @@ if ($id > 0) // Date end print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) - { + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { print ''; - } + } // Assigned to - print ''; - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - // Reminders - if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) - { - $filtreuserid = $user->id; - if ($user->rights->agenda->allactions->read) $filtreuserid = 0; - $object->loadReminders('', $filteruserid, false); + // Reminders + if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) + { + $filtreuserid = $user->id; + if ($user->rights->agenda->allactions->read) $filtreuserid = 0; + $object->loadReminders('', $filteruserid, false); - print ''; - } + print ''; + } print '
    '.$langs->trans("Type").''; - if ($object->type_code != 'AC_OTH_AUTO') - { - $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto"); - } else { - print ''.$langs->trans("Action".$object->type_code); - } + print '
    '.$langs->trans("Type").''; + if ($object->type_code != 'AC_OTH_AUTO') + { + $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto"); + } else { + print ''.$langs->trans("Action".$object->type_code); + } print '
    '.$langs->trans("Title").'
    '.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>
    '.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>
    '.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").''; if (GETPOST("afaire") == 1) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); - } else { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); - } - print ' - '; + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + } else { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + } + print ' - '; if (GETPOST("afaire") == 1) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); - } else { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); - } + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } else { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } print '
    '.$langs->trans("Location").'
    '.$langs->trans("ActionAssignedTo").''; + print '
    '.$langs->trans("ActionAssignedTo").''; print '
    '; print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid); print '
    '; @@ -1576,7 +1575,7 @@ if ($id > 0) print '
    '.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -1636,7 +1635,7 @@ if ($id > 0) } // Priority - if (! empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { + if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { print '
    '.$langs->trans("Priority").''; print ''; print '
    '.$langs->trans("LinkedObject").''; + print ''; $urloption = '?action=create&donotclearsession=1'; // we use create not edit for more flexibility - $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; + $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; - // update task list - print "\n".''."\n"; + print ''."\n"; - $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); - print ''; + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); + print ''; - print ''; - print dolGetElementUrl($object->fk_element, $object->elementtype, 1); - print ''; - print ''; - print ''; + print dolGetElementUrl($object->fk_element, $object->elementtype, 1); + print ''; + print ''; + 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->Create(); - 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->Create(); + print '
    '.$langs->trans("Type").''.$langs->trans($object->type).'
    '.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).'
    '.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).'
    '.$langs->trans("DateActionEnd").''; - if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); + if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); else print dol_print_date($object->datef, 'day'); if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print '
    '.$langs->trans("Location").''.$object->location.'
    '.$langs->trans("ActionAssignedTo").''; + print '
    '.$langs->trans("ActionAssignedTo").''; $listofuserid = array(); if (empty($donotclearsession)) { @@ -1951,8 +1950,6 @@ if ($id > 0) /* if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid))) { - //var_dump($object->userassigned); - //var_dump($listofuserid); print '
    '; print $langs->trans("MyAvailability").': '.(($object->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody print '
    '; @@ -1991,8 +1988,8 @@ if ($id > 0) if ($conf->societe->enabled) { - // Related company - print '
    '.$langs->trans("ActionOnCompany").''.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").'')); + // Related company + 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') { if ($object->thirdparty->fetch($object->thirdparty->id)) @@ -2054,43 +2051,43 @@ if ($id > 0) print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private)); print '
    '.$langs->trans("Reminders").''; + print '
    '.$langs->trans("Reminders").''; - if (count($object->reminders) > 0) { - $tmpuserstatic = new User($db); + if (count($object->reminders) > 0) { + $tmpuserstatic = new User($db); - foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) { - print $TRemindTypes[$actioncommreminder->typeremind]; - if ($actioncommreminder->fk_user > 0) { - $tmpuserstatic->fetch($actioncommreminder->fk_user); - print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; - } - print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit]; - if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) { - print ' - '; - print $langs->trans("NotSent"); - print ' '; - } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) { - print ' - '; - print $langs->trans("Done"); - print ' '; - } - print '
    '; - } - } + foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) { + print $TRemindTypes[$actioncommreminder->typeremind]; + if ($actioncommreminder->fk_user > 0) { + $tmpuserstatic->fetch($actioncommreminder->fk_user); + print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; + } + print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit]; + if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) { + print ' - '; + print $langs->trans("NotSent"); + print ' '; + } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) { + print ' - '; + print $langs->trans("Done"); + print ' '; + } + print '
    '; + } + } - print '
    '; @@ -2098,7 +2095,7 @@ if ($id > 0) print '
    '; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } @@ -2147,26 +2144,26 @@ if ($id > 0) if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) { print '
    '; - print ''; // ancre + print ''; // ancre - /* + /* * Documents generes */ - $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->agenda->myactions->read; - $delallowed = $user->rights->agenda->myactions->create; + $genallowed = $user->rights->agenda->myactions->read; + $delallowed = $user->rights->agenda->myactions->create; - print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); + print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); print '
    '; print '
    '; - } + } } } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 97896448a3f..59d5a6b6691 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -524,7 +524,7 @@ class ActionComm extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); + $this->ref =$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); // Now insert assigned users if (!$error) @@ -626,7 +626,7 @@ class ActionComm extends CommonObject // Load source object $objFrom = clone $this; - // Retreive all extrafield + // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 16384edfcde..09c9a25ca1a 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -77,8 +77,8 @@ class ActionCommReminder extends CommonObject */ public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), - 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), + 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,), 'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",), 'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,), 'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,), @@ -93,10 +93,10 @@ class ActionCommReminder extends CommonObject */ public $rowid; - /** - * @var int Entity - */ - public $entity; + /** + * @var int Entity + */ + public $entity; public $dateremind; public $typeremind; @@ -204,7 +204,7 @@ class ActionCommReminder extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -214,7 +214,7 @@ class ActionCommReminder extends CommonObject */ public static function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; if ($mode == 0 || $mode == 1) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 473c87e22a0..ca551c51e50 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -29,361 +29,361 @@ class AgendaEvents extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + ); - /** - * @var ActionComm $actioncomm {@type ActionComm} - */ - public $actioncomm; + /** + * @var ActionComm $actioncomm {@type ActionComm} + */ + public $actioncomm; - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - $this->actioncomm = new ActionComm($this->db); - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->actioncomm = new ActionComm($this->db); + } - /** - * Get properties of a Agenda Events object - * - * Return an array with Agenda Events informations - * - * @param int $id ID of Agenda Events - * @return array|mixed Data without useless information - * - * @throws RestException - */ - public function get($id) - { - if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { - throw new RestException(401, "Insufficient rights to read an event"); - } - if ($id == 0) { - $result = $this->actioncomm->initAsSpecimen(); - } else { - $result = $this->actioncomm->fetch($id); - if ($result) { - $this->actioncomm->fetch_optionals(); - $this->actioncomm->fetchObjectLinked(); - } - } - if (!$result) { - throw new RestException(404, 'Agenda Events not found'); - } + /** + * Get properties of a Agenda Events object + * + * Return an array with Agenda Events informations + * + * @param int $id ID of Agenda Events + * @return array|mixed Data without useless information + * + * @throws RestException + */ + public function get($id) + { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { + throw new RestException(401, "Insufficient rights to read an event"); + } + if ($id == 0) { + $result = $this->actioncomm->initAsSpecimen(); + } else { + $result = $this->actioncomm->fetch($id); + if ($result) { + $this->actioncomm->fetch_optionals(); + $this->actioncomm->fetchObjectLinked(); + } + } + if (!$result) { + throw new RestException(404, 'Agenda Events not found'); + } - if (!DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->userownerid != DolibarrApiAccess::$user->id) { - throw new RestException(401, "Insufficient rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); - } + if (!DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->userownerid != DolibarrApiAccess::$user->id) { + throw new RestException(401, "Insufficient rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + } - if (!DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - return $this->_cleanObjectDatas($this->actioncomm); - } + if (!DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + return $this->_cleanObjectDatas($this->actioncomm); + } - /** - * List Agenda Events - * - * Get a list of Agenda Events - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $user_ids User ids filter field (owners of event). Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%dol%') and (t.datec:<:'20160101')" - * @return array Array of Agenda Events objects - */ - public function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') - { - global $db, $conf; + /** + * List Agenda Events + * + * Get a list of Agenda Events + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $user_ids User ids filter field (owners of event). Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%dol%') and (t.datec:<:'20160101')" + * @return array Array of Agenda Events objects + */ + public function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { - throw new RestException(401, "Insufficient rights to read events"); - } + if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { + throw new RestException(401, "Insufficient rights to read events"); + } - // case of external user - $socid = 0; - if (!empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; + // case of external user + $socid = 0; + if (!empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; - if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists - $sql = "SELECT t.id as rowid"; - if (!empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; - if (!empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql .= ' WHERE t.entity IN ('.getEntity('agenda').')'; - if (!empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; - if ($user_ids) $sql .= " AND t.fk_user_action IN (".$user_ids.")"; - if ($socid > 0) $sql .= " AND t.fk_soc = ".$socid; - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $sql = "SELECT t.id as rowid"; + if (!empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; + if (!empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql .= ' WHERE t.entity IN ('.getEntity('agenda').')'; + if (!empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($user_ids) $sql .= " AND t.fk_user_action IN (".$user_ids.")"; + if ($socid > 0) $sql .= " AND t.fk_soc = ".$socid; + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (!DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit + 1, $offset); - } + $sql .= $this->db->plimit($limit + 1, $offset); + } - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($result) - { - $i = 0; - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { - $obj = $this->db->fetch_object($result); - $actioncomm_static = new ActionComm($this->db); - if ($actioncomm_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($actioncomm_static); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve Agenda Event list : '.$this->db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No Agenda Event found'); - } - return $obj_ret; - } + if ($result) + { + $i = 0; + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $this->db->fetch_object($result); + $actioncomm_static = new ActionComm($this->db); + if ($actioncomm_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($actioncomm_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve Agenda Event list : '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No Agenda Event found'); + } + return $obj_ret; + } - /** - * Create Agenda Event object - * - * @param array $request_data Request data - * @return int ID of Agenda Event - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { - throw new RestException(401, "Insufficient rights to create your Agenda Event"); - } - if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { - throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); - } + /** + * Create Agenda Event object + * + * @param array $request_data Request data + * @return int ID of Agenda Event + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { + throw new RestException(401, "Insufficient rights to create your Agenda Event"); + } + if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + } - // Check mandatory fields - $result = $this->_validate($request_data); + // Check mandatory fields + $result = $this->_validate($request_data); - foreach ($request_data as $field => $value) { - $this->actioncomm->$field = $value; - } - /*if (isset($request_data["lines"])) { + foreach ($request_data as $field => $value) { + $this->actioncomm->$field = $value; + } + /*if (isset($request_data["lines"])) { $lines = array(); foreach ($request_data["lines"] as $line) { array_push($lines, (object) $line); } $this->expensereport->lines = $lines; }*/ - if ($this->actioncomm->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, "Error creating event", array_merge(array($this->actioncomm->error), $this->actioncomm->errors)); - } + if ($this->actioncomm->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating event", array_merge(array($this->actioncomm->error), $this->actioncomm->errors)); + } - return $this->actioncomm->id; - } + return $this->actioncomm->id; + } - /** - * Update Agenda Event general fields - * - * @param int $id Id of Agenda Event to update - * @param array $request_data Datas - * - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { - throw new RestException(401, "Insufficient rights to create your Agenda Event"); - } - if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { - throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); - } + /** + * Update Agenda Event general fields + * + * @param int $id Id of Agenda Event to update + * @param array $request_data Datas + * + * @return int + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { + throw new RestException(401, "Insufficient rights to create your Agenda Event"); + } + if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + } - $result = $this->actioncomm->fetch($id); - if ($result) { - $this->actioncomm->fetch_optionals(); - $this->actioncomm->fetch_userassigned(); - $this->actioncomm->oldcopy = clone $this->actioncomm; - } - if (!$result) { - throw new RestException(404, 'actioncomm not found'); - } + $result = $this->actioncomm->fetch($id); + if ($result) { + $this->actioncomm->fetch_optionals(); + $this->actioncomm->fetch_userassigned(); + $this->actioncomm->oldcopy = clone $this->actioncomm; + } + if (!$result) { + throw new RestException(404, 'actioncomm not found'); + } - if (!DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - $this->actioncomm->$field = $value; - } + if (!DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + $this->actioncomm->$field = $value; + } - if ($this->actioncomm->update(DolibarrApiAccess::$user, 1) > 0) - return $this->get($id); + if ($this->actioncomm->update(DolibarrApiAccess::$user, 1) > 0) + return $this->get($id); - return false; - } + return false; + } - /** - * Delete Agenda Event - * - * @param int $id Agenda Event ID - * - * @return array - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->agenda->myactions->delete) { - throw new RestException(401, "Insufficient rights to delete your Agenda Event"); - } + /** + * Delete Agenda Event + * + * @param int $id Agenda Event ID + * + * @return array + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->delete) { + throw new RestException(401, "Insufficient rights to delete your Agenda Event"); + } - $result = $this->actioncomm->fetch($id); - if ($result) { - $this->actioncomm->fetch_optionals(); - $this->actioncomm->fetch_userassigned(); - $this->actioncomm->oldcopy = clone $this->actioncomm; - } + $result = $this->actioncomm->fetch($id); + if ($result) { + $this->actioncomm->fetch_optionals(); + $this->actioncomm->fetch_userassigned(); + $this->actioncomm->oldcopy = clone $this->actioncomm; + } - if (!DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { - throw new RestException(401, "Insufficient rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); - } + if (!DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { + throw new RestException(401, "Insufficient rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + } - if (!$result) { - throw new RestException(404, 'Agenda Event not found'); - } + if (!$result) { + throw new RestException(404, 'Agenda Event not found'); + } - if (!DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!$this->actioncomm->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error); - } + if (!$this->actioncomm->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Agenda Event deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Agenda Event deleted' + ) + ); + } - /** - * Validate fields before create or update object - * - * @param array $data Array with data to verify - * @return array - * @throws RestException - */ - private function _validate($data) - { - $event = array(); - foreach (AgendaEvents::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $event[$field] = $data[$field]; - } - return $event; - } + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + private function _validate($data) + { + $event = array(); + foreach (AgendaEvents::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $event[$field] = $data[$field]; + } + return $event; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param object $object Object to clean - * @return array Array of cleaned object properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - unset($object->note); // alreaydy into note_private - unset($object->usermod); - unset($object->libelle); - unset($object->context); - unset($object->canvas); - unset($object->contact); - unset($object->contact_id); - unset($object->thirdparty); - unset($object->user); - unset($object->origin); - unset($object->origin_id); - unset($object->ref_ext); - unset($object->statut); - unset($object->state_code); - unset($object->state_id); - unset($object->state); - unset($object->region); - unset($object->region_code); - unset($object->country); - unset($object->country_id); - unset($object->country_code); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); - unset($object->mode_reglement_id); - unset($object->cond_reglement_id); - unset($object->cond_reglement); - unset($object->fk_delivery_address); - unset($object->shipping_method_id); - unset($object->fk_account); - unset($object->total_ht); - unset($object->total_tva); - unset($object->total_localtax1); - unset($object->total_localtax2); - unset($object->total_ttc); - unset($object->fk_incoterms); - unset($object->label_incoterms); - unset($object->location_incoterms); - unset($object->name); - unset($object->lastname); - unset($object->firstname); - unset($object->civility_id); - unset($object->contact); - unset($object->societe); + unset($object->note); // alreaydy into note_private + unset($object->usermod); + unset($object->libelle); + unset($object->context); + unset($object->canvas); + unset($object->contact); + unset($object->contact_id); + unset($object->thirdparty); + unset($object->user); + unset($object->origin); + unset($object->origin_id); + unset($object->ref_ext); + unset($object->statut); + unset($object->state_code); + unset($object->state_id); + unset($object->state); + unset($object->region); + unset($object->region_code); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); + unset($object->fk_account); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->fk_incoterms); + unset($object->label_incoterms); + unset($object->location_incoterms); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->contact); + unset($object->societe); - unset($object->actions); - unset($object->lines); + unset($object->actions); + unset($object->lines); - return $object; - } + return $object; + } } diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 6e86a556a1a..3b932b2f59c 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -28,201 +28,226 @@ */ class CActionComm { - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var int ID - */ - public $id; + /** + * @var int ID + */ + public $id; - public $code; - public $type; - public $libelle; // deprecated + /** + * @var string code + */ + public $code; - /** - * @var string Type of agenda event label - */ - public $label; + /** + * @var string type + */ + public $type; - public $active; - public $color; + /** + * @var string label + * @deprecated + * @see $label + */ + public $libelle; - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto; + /** + * @var string Type of agenda event label + */ + public $label; - public $type_actions = array(); + /** + * @var int active + */ + public $active; + + /** + * @var string color hex + */ + public $color; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto; + + /** + * @var array array of type_actions + */ + public $type_actions = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Load action type from database - * - * @param int $id id or code of action type to read - * @return int 1=ok, 0=not found, -1=error - */ - public function fetch($id) - { - $sql = "SELECT id, code, type, libelle as label, color, active, picto"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; - if (is_numeric($id)) $sql .= " WHERE id=".$id; - else $sql .= " WHERE code='".$this->db->escape($id)."'"; + /** + * Load action type from database + * + * @param int|string $id id or code of action type to read + * @return int 1=ok, 0=not found, -1=error + */ + public function fetch($id) + { + $sql = "SELECT id, code, type, libelle as label, color, active, picto"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; + if (is_numeric($id)) $sql .= " WHERE id=".(int) $id; + else $sql .= " WHERE code='".$this->db->escape($id)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->id; - $this->code = $obj->code; - $this->type = $obj->type; - $this->libelle = $obj->label; // deprecated - $this->label = $obj->label; - $this->active = $obj->active; - $this->color = $obj->color; + $this->id = $obj->id; + $this->code = $obj->code; + $this->type = $obj->type; + $this->libelle = $obj->label; // deprecated + $this->label = $obj->label; + $this->active = $obj->active; + $this->color = $obj->color; - $this->db->free($resql); - return 1; - } else { - $this->db->free($resql); - return 0; - } - } else { - $this->error = $this->db->error(); - return -1; - } - } + $this->db->free($resql); + return 1; + } else { + $this->db->free($resql); + return 0; + } + } else { + $this->error = $this->db->error(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return list of event types: array(id=>label) or array(code=>label) - * - * @param string|int $active 1 or 0 to filter on event state active or not ('' by default = no filter) - * @param string $idorcode 'id' or 'code' - * @param string $excludetype Type to exclude ('system' or 'systemauto') - * @param int $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual" - * @param string $morefilter Add more SQL filter - * @param int $shortlabel 1=Get short label instead of long label - * @return mixed Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode. - */ - public function liste_array($active = '', $idorcode = 'id', $excludetype = '', $onlyautoornot = 0, $morefilter = '', $shortlabel = 0) - { - // phpcs:enable - global $langs, $conf; - $langs->load("commercial"); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of event types: array(id=>label) or array(code=>label) + * + * @param string|int $active 1 or 0 to filter on event state active or not ('' by default = no filter) + * @param string $idorcode 'id' or 'code' + * @param string $excludetype Type to exclude ('system' or 'systemauto') + * @param int $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual" + * @param string $morefilter Add more SQL filter + * @param int $shortlabel 1=Get short label instead of long label + * @return mixed Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode. + */ + public function liste_array($active = '', $idorcode = 'id', $excludetype = '', $onlyautoornot = 0, $morefilter = '', $shortlabel = 0) + { + // phpcs:enable + global $langs, $conf; + $langs->load("commercial"); - $repid = array(); - $repcode = array(); + $repid = array(); + $repcode = array(); - $sql = "SELECT id, code, libelle as label, module, type, color, picto"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; - $sql .= " WHERE 1=1"; - if ($active != '') $sql .= " AND active=".$active; - if (!empty($excludetype)) $sql .= " AND type <> '".$this->db->escape($excludetype)."'"; - if ($morefilter) $sql .= " AND ".$morefilter; - $sql .= " ORDER BY module, position, type"; + $sql = "SELECT id, code, libelle as label, module, type, color, picto"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; + $sql .= " WHERE 1=1"; + if ($active != '') { + $sql .= " AND active=".(int) $active; + } + if (!empty($excludetype)) $sql .= " AND type <> '".$this->db->escape($excludetype)."'"; + if ($morefilter) $sql .= " AND ".$morefilter; + $sql .= " ORDER BY module, position, type"; - dol_syslog(get_class($this)."::liste_array", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $nump = $this->db->num_rows($resql); - if ($nump) - { - $i = 0; - while ($i < $nump) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::liste_array", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $nump = $this->db->num_rows($resql); + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = $this->db->fetch_object($resql); - $qualified = 1; + $qualified = 1; - // $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto - if ($qualified && $onlyautoornot > 0 && preg_match('/^system/', $obj->type) && !preg_match('/^AC_OTH/', $obj->code)) $qualified = 0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO) + // $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto + if ($qualified && $onlyautoornot > 0 && preg_match('/^system/', $obj->type) && !preg_match('/^AC_OTH/', $obj->code)) $qualified = 0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO) - if ($qualified && $obj->module) - { - if ($obj->module == 'invoice' && !$conf->facture->enabled) $qualified=0; - if ($obj->module == 'order' && !$conf->commande->enabled) $qualified=0; - if ($obj->module == 'propal' && !$conf->propal->enabled) $qualified=0; - if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ! $conf->supplier_invoice->enabled)) $qualified=0; - if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ! $conf->supplier_order->enabled)) $qualified=0; - if ($obj->module == 'shipping' && !$conf->expedition->enabled) $qualified=0; - } + if ($qualified && $obj->module) + { + if ($obj->module == 'invoice' && !$conf->facture->enabled) $qualified = 0; + if ($obj->module == 'order' && !$conf->commande->enabled) $qualified = 0; + if ($obj->module == 'propal' && !$conf->propal->enabled) $qualified = 0; + if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_invoice->enabled)) $qualified = 0; + if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_order->enabled)) $qualified = 0; + if ($obj->module == 'shipping' && !$conf->expedition->enabled) $qualified = 0; + } - if ($qualified) - { - $keyfortrans = ''; - $transcode = ''; - $code = $obj->code; - if ($onlyautoornot > 0 && $code == 'AC_OTH') $code = 'AC_MANUAL'; - if ($onlyautoornot > 0 && $code == 'AC_OTH_AUTO') $code = 'AC_AUTO'; - if ($shortlabel) - { - $keyfortrans = "Action".$code.'Short'; - $transcode = $langs->trans($keyfortrans); - } - if (empty($keyfortrans) || $keyfortrans == $transcode) - { - $keyfortrans = "Action".$code; - $transcode = $langs->trans($keyfortrans); - } - $label = (($transcode != $keyfortrans) ? $transcode : $langs->trans($obj->label)); - if ($onlyautoornot == -1 && !empty($conf->global->AGENDA_USE_EVENT_TYPE) && !preg_match('/auto/i', $code)) - { - $label = '  '.$label; - $repid[-99] = $langs->trans("ActionAC_MANUAL"); - $repcode['AC_NON_AUTO'] = $langs->trans("ActionAC_MANUAL"); - } - $repid[$obj->id] = $label; - $repcode[$obj->code] = $label; - if ($onlyautoornot > 0 && preg_match('/^module/', $obj->type) && $obj->module) $repcode[$obj->code] .= ' ('.$langs->trans("Module").': '.$obj->module.')'; - } - $i++; - } - } - if ($idorcode == 'id') $this->liste_array = $repid; - if ($idorcode == 'code') $this->liste_array = $repcode; - return $this->liste_array; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + if ($qualified) + { + $keyfortrans = ''; + $transcode = ''; + $code = $obj->code; + if ($onlyautoornot > 0 && $code == 'AC_OTH') $code = 'AC_MANUAL'; + if ($onlyautoornot > 0 && $code == 'AC_OTH_AUTO') $code = 'AC_AUTO'; + if ($shortlabel) + { + $keyfortrans = "Action".$code.'Short'; + $transcode = $langs->trans($keyfortrans); + } + if (empty($keyfortrans) || $keyfortrans == $transcode) + { + $keyfortrans = "Action".$code; + $transcode = $langs->trans($keyfortrans); + } + $label = (($transcode != $keyfortrans) ? $transcode : $langs->trans($obj->label)); + if ($onlyautoornot == -1 && !empty($conf->global->AGENDA_USE_EVENT_TYPE) && !preg_match('/auto/i', $code)) + { + $label = '  '.$label; + $repid[-99] = $langs->trans("ActionAC_MANUAL"); + $repcode['AC_NON_AUTO'] = $langs->trans("ActionAC_MANUAL"); + } + $repid[$obj->id] = $label; + $repcode[$obj->code] = $label; + if ($onlyautoornot > 0 && preg_match('/^module/', $obj->type) && $obj->module) $repcode[$obj->code] .= ' ('.$langs->trans("Module").': '.$obj->module.')'; + } + $i++; + } + } + if ($idorcode == 'id') $this->liste_array = $repid; + if ($idorcode == 'code') $this->liste_array = $repcode; + return $this->liste_array; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Return name of action type as a label translated - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only - * @return string Label of action type - */ - public function getNomUrl($withpicto = 0) - { - global $langs; + /** + * Return name of action type as a label translated + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only + * @return string Label of action type + */ + public function getNomUrl($withpicto = 0) + { + global $langs; - // Check if translation available - $transcode = $langs->trans("Action".$this->code); - if ($transcode != "Action".$this->code) return $transcode; - } + // Check if translation available + $transcode = $langs->trans("Action".$this->code); + if ($transcode != "Action".$this->code) return $transcode; + } } diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index b806dde94f9..4789e49f44a 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -32,144 +32,144 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/xcal.lib.php'; */ class ICal { - // Text in file - public $file_text; - public $cal; // Array to save iCalendar parse data - public $event_count; // Number of Events - public $todo_count; // Number of Todos - public $freebusy_count; // Number of Freebusy - public $last_key; //Help variable save last key (multiline string) + // Text in file + public $file_text; + public $cal; // Array to save iCalendar parse data + public $event_count; // Number of Events + public $todo_count; // Number of Todos + public $freebusy_count; // Number of Freebusy + public $last_key; //Help variable save last key (multiline string) - /** - * Constructor - */ - public function __construct() - { - } + /** + * Constructor + */ + public function __construct() + { + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Read text file, icalender text file - * - * @param string $file File - * @return string - */ - public function read_file($file) - { - // phpcs:enable - $this->file = $file; - $file_text = ''; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Read text file, icalender text file + * + * @param string $file File + * @return string + */ + public function read_file($file) + { + // phpcs:enable + $this->file = $file; + $file_text = ''; - $tmparray = file($file); - if (is_array($tmparray)) - { - $file_text = join("", $tmparray); //load file - $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); - } - return $file_text; // return all text - } + $tmparray = file($file); + if (is_array($tmparray)) + { + $file_text = join("", $tmparray); //load file + $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); + } + return $file_text; // return all text + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Returns the number of calendar events - * - * @return int - */ - public function get_event_count() - { - // phpcs:enable - return $this->event_count; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the number of calendar events + * + * @return int + */ + public function get_event_count() + { + // phpcs:enable + return $this->event_count; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Returns the number of to do - * - * @return int - */ - public function get_todo_count() - { - // phpcs:enable - return $this->todo_count; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the number of to do + * + * @return int + */ + public function get_todo_count() + { + // phpcs:enable + return $this->todo_count; + } - /** - * Translate Calendar - * - * @param string $uri Url - * @return array|string - */ - public function parse($uri) - { - $this->cal = array(); // new empty array + /** + * Translate Calendar + * + * @param string $uri Url + * @return array|string + */ + public function parse($uri) + { + $this->cal = array(); // new empty array - $this->event_count = -1; + $this->event_count = -1; - // read FILE text - $this->file_text = $this->read_file($uri); + // read FILE text + $this->file_text = $this->read_file($uri); - $this->file_text = preg_split("[\n]", $this->file_text); + $this->file_text = preg_split("[\n]", $this->file_text); - // is this text vcalendar standard text ? on line 1 is BEGIN:VCALENDAR - if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) return 'error not VCALENDAR'; + // is this text vcalendar standard text ? on line 1 is BEGIN:VCALENDAR + if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) return 'error not VCALENDAR'; - $insidealarm = 0; - $tmpkey = ''; $tmpvalue = ''; $type = ''; - foreach ($this->file_text as $text) - { - $text = trim($text); // trim one line - if (!empty($text)) - { - // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin - list($key, $value) = $this->retun_key_value($text); - //var_dump($text.' -> '.$key.' - '.$value); + $insidealarm = 0; + $tmpkey = ''; $tmpvalue = ''; $type = ''; + foreach ($this->file_text as $text) + { + $text = trim($text); // trim one line + if (!empty($text)) + { + // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin + list($key, $value) = $this->retun_key_value($text); + //var_dump($text.' -> '.$key.' - '.$value); - switch ($text) // search special string - { - case "BEGIN:VTODO": - $this->todo_count = $this->todo_count + 1; // new to do begin - $type = "VTODO"; - break; + switch ($text) // search special string + { + case "BEGIN:VTODO": + $this->todo_count = $this->todo_count + 1; // new to do begin + $type = "VTODO"; + break; - case "BEGIN:VEVENT": - $this->event_count = $this->event_count + 1; // new event begin - $type = "VEVENT"; - break; + case "BEGIN:VEVENT": + $this->event_count = $this->event_count + 1; // new event begin + $type = "VEVENT"; + break; - case "BEGIN:VFREEBUSY": - $this->freebusy_count = $this->freebusy_count + 1; // new event begin - $type = "VFREEBUSY"; - break; + case "BEGIN:VFREEBUSY": + $this->freebusy_count = $this->freebusy_count + 1; // new event begin + $type = "VFREEBUSY"; + break; - case "BEGIN:VCALENDAR": // all other special string - case "BEGIN:DAYLIGHT": - case "BEGIN:VTIMEZONE": - case "BEGIN:STANDARD": - $type = $value; // save array under value key - break; + case "BEGIN:VCALENDAR": // all other special string + case "BEGIN:DAYLIGHT": + case "BEGIN:VTIMEZONE": + case "BEGIN:STANDARD": + $type = $value; // save array under value key + break; - case "END:VTODO": // end special text - goto VCALENDAR key - case "END:VEVENT": - case "END:VFREEBUSY": + case "END:VTODO": // end special text - goto VCALENDAR key + case "END:VEVENT": + case "END:VFREEBUSY": - case "END:VCALENDAR": - case "END:DAYLIGHT": - case "END:VTIMEZONE": - case "END:STANDARD": - $type = "VCALENDAR"; - break; + case "END:VCALENDAR": + case "END:DAYLIGHT": + case "END:VTIMEZONE": + case "END:STANDARD": + $type = "VCALENDAR"; + break; - // Manage VALARM that are inside a VEVENT to avoid fields of VALARM to overwrites fields of VEVENT - case "BEGIN:VALARM": - $insidealarm = 1; - break; - case "END:VALARM": - $insidealarm = 0; - break; + // Manage VALARM that are inside a VEVENT to avoid fields of VALARM to overwrites fields of VEVENT + case "BEGIN:VALARM": + $insidealarm = 1; + break; + case "END:VALARM": + $insidealarm = 0; + break; - default: // no special string (SUMMARY, DESCRIPTION, ...) - if ($tmpvalue) + default: // no special string (SUMMARY, DESCRIPTION, ...) + if ($tmpvalue) { $tmpvalue .= $text; if (!preg_match('/=$/', $text)) // No more lines @@ -180,96 +180,96 @@ class ICal $tmpvalue = ''; } } elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value)) - { - if (preg_match('/=$/', $value)) - { - $tmpkey = $key; - $tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message - } else { - $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value)); - } - } //$value=quotedPrintDecode($tmpvalue.$value); - if (!$insidealarm && !$tmpkey) $this->add_to_array($type, $key, $value); // add to array - break; - } - } - } + { + if (preg_match('/=$/', $value)) + { + $tmpkey = $key; + $tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message + } else { + $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value)); + } + } //$value=quotedPrintDecode($tmpvalue.$value); + if (!$insidealarm && !$tmpkey) $this->add_to_array($type, $key, $value); // add to array + break; + } + } + } - //var_dump($this->cal); - return $this->cal; - } + //var_dump($this->cal); + return $this->cal; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Add to $this->ical array one value and key. - * - * @param string $type Type ('VTODO', 'VEVENT', 'VFREEBUSY', 'VCALENDAR'...) - * @param string $key Key ('DTSTART', ...). Note: Field is never 'DTSTART;TZID=...' because ';...' was before removed and added as another property - * @param string $value Value - * @return void - */ - public function add_to_array($type, $key, $value) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Add to $this->ical array one value and key. + * + * @param string $type Type ('VTODO', 'VEVENT', 'VFREEBUSY', 'VCALENDAR'...) + * @param string $key Key ('DTSTART', ...). Note: Field is never 'DTSTART;TZID=...' because ';...' was before removed and added as another property + * @param string $value Value + * @return void + */ + public function add_to_array($type, $key, $value) + { + // phpcs:enable - //print 'type='.$type.' key='.$key.' value='.$value.'
    '."\n"; + //print 'type='.$type.' key='.$key.' value='.$value.'
    '."\n"; - if (empty($key)) - { - $key = $this->last_key; - switch ($type) - { - case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value; break; - case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value; break; - case 'VTODO': $value = $this->cal[$type][$this->todo_count][$key].$value; break; - } - } + if (empty($key)) + { + $key = $this->last_key; + switch ($type) + { + case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value; break; + case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value; break; + case 'VTODO': $value = $this->cal[$type][$this->todo_count][$key].$value; break; + } + } - if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) $value = $this->ical_date_to_unix($value); - //if ($key == "RRULE" ) $value = $this->ical_rrule($value); + if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) $value = $this->ical_date_to_unix($value); + //if ($key == "RRULE" ) $value = $this->ical_rrule($value); - if (stristr($key, "DTSTART") || stristr($key, "DTEND") || stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) - { - if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) - { - list($key, $value) = array($key, $value); - } else { - list($key, $value) = $this->ical_dt_date($key, $value); - } - } + if (stristr($key, "DTSTART") || stristr($key, "DTEND") || stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) + { + if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) + { + list($key, $value) = array($key, $value); + } else { + list($key, $value) = $this->ical_dt_date($key, $value); + } + } - switch ($type) - { - case "VTODO": - $this->cal[$type][$this->todo_count][$key] = $value; - break; + switch ($type) + { + case "VTODO": + $this->cal[$type][$this->todo_count][$key] = $value; + break; - case "VEVENT": - $this->cal[$type][$this->event_count][$key] = $value; - break; + case "VEVENT": + $this->cal[$type][$this->event_count][$key] = $value; + break; - case "VFREEBUSY": - $this->cal[$type][$this->freebusy_count][$key] = $value; - break; + case "VFREEBUSY": + $this->cal[$type][$this->freebusy_count][$key] = $value; + break; - default: - $this->cal[$type][$key] = $value; - break; - } - $this->last_key = $key; - } + default: + $this->cal[$type][$key] = $value; + break; + } + $this->last_key = $key; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); - * - * @param string $text Text - * @return array - */ - public function retun_key_value($text) - { - // phpcs:enable - /* + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); + * + * @param string $text Text + * @return array + */ + public function retun_key_value($text) + { + // phpcs:enable + /* preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches); if (empty($matches)) @@ -281,173 +281,173 @@ class ICal $matches = array_splice($matches, 1, 2); return $matches; }*/ - return explode(':', $text, 2); - } + return explode(':', $text, 2); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Parse RRULE return array - * - * @param string $value string - * @return array - */ - public function ical_rrule($value) - { - // phpcs:enable - $result = array(); - $rrule = explode(';', $value); - foreach ($rrule as $line) - { - $rcontent = explode('=', $line); - $result[$rcontent[0]] = $rcontent[1]; - } - return $result; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Parse RRULE return array + * + * @param string $value string + * @return array + */ + public function ical_rrule($value) + { + // phpcs:enable + $result = array(); + $rrule = explode(';', $value); + foreach ($rrule as $line) + { + $rcontent = explode('=', $line); + $result[$rcontent[0]] = $rcontent[1]; + } + return $result; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return Unix time from ical date time fomrat (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS) - * - * @param string $ical_date String date - * @return int - */ - public function ical_date_to_unix($ical_date) - { - // phpcs:enable - $ical_date = str_replace('T', '', $ical_date); - $ical_date = str_replace('Z', '', $ical_date); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return Unix time from ical date time fomrat (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS) + * + * @param string $ical_date String date + * @return int + */ + public function ical_date_to_unix($ical_date) + { + // phpcs:enable + $ical_date = str_replace('T', '', $ical_date); + $ical_date = str_replace('Z', '', $ical_date); - $ntime = 0; - // TIME LIMITED EVENT - if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) - $ntime = dol_mktime($date[4], $date[5], $date[6], $date[2], $date[3], $date[1], true); + $ntime = 0; + // TIME LIMITED EVENT + if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) + $ntime = dol_mktime($date[4], $date[5], $date[6], $date[2], $date[3], $date[1], true); - //if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1]; - //print dol_print_date($ntime,'dayhour');exit; - return $ntime; // ntime is a GTM time - } + //if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1]; + //print dol_print_date($ntime,'dayhour');exit; + return $ntime; // ntime is a GTM time + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return unix date from iCal date format - * - * @param string $key Key - * @param string $value Value - * @return array - */ - public function ical_dt_date($key, $value) - { - // phpcs:enable - $return_value = array(); - $value = $this->ical_date_to_unix($value); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return unix date from iCal date format + * + * @param string $key Key + * @param string $value Value + * @return array + */ + public function ical_dt_date($key, $value) + { + // phpcs:enable + $return_value = array(); + $value = $this->ical_date_to_unix($value); - // Analyse TZID - $temp = explode(";", $key); + // Analyse TZID + $temp = explode(";", $key); - if (empty($temp[1])) // not TZID - { - $value = str_replace('T', '', $value); - return array($key, $value); - } + if (empty($temp[1])) // not TZID + { + $value = str_replace('T', '', $value); + return array($key, $value); + } - $key = $temp[0]; - $temp = explode("=", $temp[1]); - $return_value[$temp[0]] = $temp[1]; - $return_value['unixtime'] = $value; + $key = $temp[0]; + $temp = explode("=", $temp[1]); + $return_value[$temp[0]] = $temp[1]; + $return_value['unixtime'] = $value; - return array($key, $return_value); - } + return array($key, $return_value); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return sorted eventlist as array or false if calendar is empty - * - * @return array|false - */ - public function get_sort_event_list() - { - // phpcs:enable - $temp = $this->get_event_list(); - if (!empty($temp)) - { - usort($temp, array(&$this, "ical_dtstart_compare")); - return $temp; - } else { - return false; - } - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return sorted eventlist as array or false if calendar is empty + * + * @return array|false + */ + public function get_sort_event_list() + { + // phpcs:enable + $temp = $this->get_event_list(); + if (!empty($temp)) + { + usort($temp, array(&$this, "ical_dtstart_compare")); + return $temp; + } else { + return false; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Compare two unix timestamp - * - * @param array $a Operand a - * @param array $b Operand b - * @return integer - */ - public function ical_dtstart_compare($a, $b) - { - // phpcs:enable - return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Compare two unix timestamp + * + * @param array $a Operand a + * @param array $b Operand b + * @return integer + */ + public function ical_dtstart_compare($a, $b) + { + // phpcs:enable + return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return eventlist array (not sorted eventlist array) - * - * @return array - */ - public function get_event_list() - { - // phpcs:enable - return (!empty($this->cal['VEVENT']) ? $this->cal['VEVENT'] : ''); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return eventlist array (not sorted eventlist array) + * + * @return array + */ + public function get_event_list() + { + // phpcs:enable + return (!empty($this->cal['VEVENT']) ? $this->cal['VEVENT'] : ''); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return eventlist array (not sort eventlist array) - * - * @return array - */ - public function get_freebusy_list() - { - // phpcs:enable - return $this->cal['VFREEBUSY']; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return eventlist array (not sort eventlist array) + * + * @return array + */ + public function get_freebusy_list() + { + // phpcs:enable + return $this->cal['VFREEBUSY']; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return to do array (not sorted todo array) - * - * @return array - */ - public function get_todo_list() - { - // phpcs:enable - return $this->cal['VTODO']; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return to do array (not sorted todo array) + * + * @return array + */ + public function get_todo_list() + { + // phpcs:enable + return $this->cal['VTODO']; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return base calendar data - * - * @return array - */ - public function get_calender_data() - { - // phpcs:enable - return $this->cal['VCALENDAR']; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return base calendar data + * + * @return array + */ + public function get_calender_data() + { + // phpcs:enable + return $this->cal['VCALENDAR']; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return array with all data - * - * @return array - */ - public function get_all_data() - { - // phpcs:enable - return $this->cal; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return array with all data + * + * @return array + */ + public function get_all_data() + { + // phpcs:enable + return $this->cal; + } } diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index bed4054e018..613ac76380e 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -120,7 +120,7 @@ if ($object->id > 0) $now = dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; - dol_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action'); + print dol_get_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action'); $linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); $linkback .= ''.$langs->trans("BackToList").''; @@ -254,7 +254,7 @@ if ($object->id > 0) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'actions'; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 7a52183b195..313aaa0e2e4 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -415,9 +415,9 @@ print '
    '; print ''; -//dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); +//print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); //print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); -//dol_fiche_end(); +//print dol_get_fiche_end(); $viewmode = ''; $viewmode .= ''; @@ -1265,7 +1265,7 @@ if (empty($action) || $action == 'show_month') // View by month /* Show days before the beginning of the current month (previous month) */ $style = 'cal_other_month cal_past'; if ($iter_day == 6) $style .= ' cal_other_month_right'; - echo '
    '; + echo ' '; show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo " '; + echo ' '; show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); - echo " '; + echo ' '; show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); echo "
    '; dol_print_object_info($object); print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 92975aafec0..a9e365534f3 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -57,10 +57,10 @@ $confirm = GETPOST('confirm', 'alpha'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $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)); + $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); $search_id = GETPOST('search_id', 'alpha'); @@ -166,13 +166,13 @@ if (GETPOST('cancel', 'alpha')) if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { $param = ''; - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { - $param .= '&'.$key.'='.urlencode($val); - } - } + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + $param .= '&'.$key.'='.urlencode($val); + } + } //print $param; header("Location: ".DOL_URL_ROOT.'/comm/action/index.php?'.$param); exit; @@ -187,15 +187,15 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - //$actioncode=''; - $search_id = ''; + //$actioncode=''; + $search_id = ''; $search_title = ''; - $search_note = ''; - $datestart = ''; - $dateend = ''; - $search_status = ''; + $search_note = ''; + $datestart = ''; + $dateend = ''; + $search_status = ''; $toselect = ''; - $search_array_options = array(); + $search_array_options = array(); } if (empty($reshook) && !empty($massaction)) @@ -341,26 +341,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (!empty($actioncode)) { - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; - } - } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; - else { - if (is_array($actioncode)) - { - $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; - } - } - } + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; + } + } else { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else { + if (is_array($actioncode)) + { + $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } + } } if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); @@ -381,10 +381,10 @@ if ($search_note) $sql .= natural_search('a.note', $search_note); // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) @@ -405,13 +405,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -452,13 +452,13 @@ if ($resql) if ($showbirthday) $nav .= ''; print $nav; - //dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); - //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - //dol_fiche_end(); + //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); + //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + //print dol_get_fiche_end(); - // Add link to show birthdays - $link = ''; - /* + // Add link to show birthdays + $link = ''; + /* if (empty($conf->use_javascript_ajax)) { $newparam=$param; // newparam is for birthday links @@ -473,49 +473,49 @@ if ($resql) } */ - $s = $newtitle; + $s = $newtitle; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } - $viewmode = ''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewList").''; + $viewmode = ''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewList").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewCal").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewCal").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewWeek").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewWeek").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewDay").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewDay").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewPerUser").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewPerUser").''; $viewmode .= ''; @@ -538,21 +538,21 @@ if ($resql) print $s; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - $moreforfilter = ''; + $moreforfilter = ''; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); - $i = 0; + $i = 0; - print '
    '; - print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - print '
    '; + print '
    '; + print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + print '
    '; - print '
    '; - print ''."\n"; + print '
    '; + print '
    '."\n"; print ''; if (!empty($arrayfields['a.id']['checked'])) print ''; @@ -571,8 +571,8 @@ if ($resql) print ''; } if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - } + print ''; + } if (!empty($arrayfields['a.fk_contact']['checked'])) print ''; if (!empty($arrayfields['a.fk_element']['checked'])) print ''; @@ -588,10 +588,10 @@ if ($resql) if (!empty($arrayfields['a.tms']['checked'])) print ''; if (!empty($arrayfields['a.percent']['checked'])) { print ''; - } + $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); + print ajax_combobox('selectsearch_status'); + print ''; + } // Action column print ''; + print ''; } // Extra fields @@ -858,7 +858,7 @@ if ($resql) $i++; } print "
    '; - $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); - print ajax_combobox('selectsearch_status'); - print ''; $searchpicto = $form->showFilterButtons(); @@ -610,10 +610,10 @@ if ($resql) if (!empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -634,18 +634,18 @@ if ($resql) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; $caction = new CActionComm($db); $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); - $contactListCache = array(); + $contactListCache = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') - { - $i++; - continue; - } + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + { + $i++; + continue; + } $actionstatic->id = $obj->id; $actionstatic->ref = $obj->id; @@ -771,29 +771,29 @@ if ($resql) if (!empty($arrayfields['a.fk_contact']['checked'])) { print ''; - if (!empty($actionstatic->socpeopleassigned)) - { - $contactList = array(); - foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) - { - if (!isset($contactListCache[$socpeopleassigned['id']])) - { - // if no cache found we fetch it - $contact = new Contact($db); - if ($contact->fetch($socpeopleassigned['id']) > 0) - { - $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); - $contactList[] = $contact->getNomUrl(1, '', 0); - } - } else { - // use cache - $contactList[] = $contactListCache[$socpeopleassigned['id']]; - } - } - if (!empty($contactList)) { - print implode(', ', $contactList); - } - } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event + if (!empty($actionstatic->socpeopleassigned)) + { + $contactList = array(); + foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) + { + if (!isset($contactListCache[$socpeopleassigned['id']])) + { + // if no cache found we fetch it + $contact = new Contact($db); + if ($contact->fetch($socpeopleassigned['id']) > 0) + { + $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); + $contactList[] = $contact->getNomUrl(1, '', 0); + } + } else { + // use cache + $contactList[] = $contactListCache[$socpeopleassigned['id']]; + } + } + if (!empty($contactList)) { + print implode(', ', $contactList); + } + } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event { $contactstatic->id = $obj->fk_contact; $contactstatic->email = $obj->email; @@ -812,15 +812,15 @@ if ($resql) // Linked object if (!empty($arrayfields['a.fk_element']['checked'])) { - print ''; - //var_dump($obj->fkelement.' '.$obj->elementtype); - if ($obj->fk_element > 0 && !empty($obj->elementtype)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); - } else { - print " "; - } - print ''; + //var_dump($obj->fkelement.' '.$obj->elementtype); + if ($obj->fk_element > 0 && !empty($obj->elementtype)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); + } else { + print " "; + } + print '
    "; - print '
    '; + print ''; print ''; $db->free($resql); diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index f0c1a0d1951..4f292047700 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -74,7 +74,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden(); if (!$user->rights->agenda->allactions->read) $canedit = 0; if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert = $user->id; + $filtert = $user->id; } //$action=GETPOST('action','alpha'); @@ -92,10 +92,10 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $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)); + $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); @@ -126,16 +126,16 @@ if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $statu if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { - $action = 'show_month'; $day = ''; + $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { - $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); } // View by week if (GETPOST('viewday', 'alpha') || $action == 'show_day') { - $action = 'show_day'; $day = ($day ? $day : date("d")); + $action = 'show_day'; $day = ($day ? $day : date("d")); } // View by day if (GETPOST('viewyear', 'alpha') || $action == 'show_year') { - $action = 'show_year'; + $action = 'show_year'; } // View by year // Load translation files required by the page @@ -151,13 +151,13 @@ $hookmanager->initHooks(array('agenda')); if ($action == 'delete_action') { - $event = new ActionComm($db); - $event->fetch($actionid); - $event->fetch_optionals(); - $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event = new ActionComm($db); + $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; - $result = $event->delete(); + $result = $event->delete(); } @@ -317,8 +317,8 @@ if ($conf->use_javascript_ajax) $s .= 'jQuery(".family_birthday").toggle();'."\n"; if ($action == "show_week" || $action == "show_month" || empty($action)) { - $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; - $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; + $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; + $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; } $s .= '});'."\n"; $s .= ''."\n"; @@ -345,15 +345,15 @@ if ($conf->use_javascript_ajax) //$s.='
    '.$langs->trans("AgendaShowBirthdayEvents").'  
    '; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } } } @@ -451,26 +451,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (!empty($actioncode)) { - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; - } - } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if (is_array($actioncode)) - { - $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; - } - } - } + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; + } + } else { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } + } } if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); @@ -480,28 +480,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; } else { - // To limit array - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; // End 7 days after - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; - $sql .= ')'; + // To limit array + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; // End 7 days after + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; + $sql .= ')'; } if ($type) $sql .= " AND ca.id = ".$type; if ($status == '0') { $sql .= " AND a.percent = 0"; } @@ -512,10 +512,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action @@ -525,104 +525,104 @@ dol_syslog("comm/action/pertype.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); - // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') - { - $i++; - continue; - } + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') + { + $i++; + continue; + } - $datep = $db->jdate($obj->datep); - $datep2 = $db->jdate($obj->datep2); + $datep = $db->jdate($obj->datep); + $datep2 = $db->jdate($obj->datep2); - // Create a new object action - $event = new ActionComm($db); - $event->id = $obj->id; - $event->datep = $datep; // datep and datef are GMT date - $event->datef = $datep2; - $event->type_code = $obj->code; - $event->type_color = $obj->color; - $event->label = $obj->label; - $event->percentage = $obj->percent; - $event->authorid = $obj->fk_user_author; // user id of creator - $event->userownerid = $obj->fk_user_action; // user id of owner - $event->priority = $obj->priority; - $event->fulldayevent = $obj->fulldayevent; - $event->location = $obj->location; - $event->transparency = $obj->transparency; + // Create a new object action + $event = new ActionComm($db); + $event->id = $obj->id; + $event->datep = $datep; // datep and datef are GMT date + $event->datef = $datep2; + $event->type_code = $obj->code; + $event->type_color = $obj->color; + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; - $event->fk_project = $obj->fk_project; + $event->fk_project = $obj->fk_project; - $event->socid = $obj->fk_soc; - $event->contact_id = $obj->fk_contact; + $event->socid = $obj->fk_soc; + $event->contact_id = $obj->fk_contact; - $event->fk_element = $obj->fk_element; - $event->elementtype = $obj->elementtype; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; - // Defined date_start_in_calendar and date_end_in_calendar property - // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) - { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } else { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } - // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { - $event->ponctuel = 1; - } + // Defined date_start_in_calendar and date_end_in_calendar property + // They are date start and end of action but modified to not be outside calendar view. + if ($event->percentage <= 0) + { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } else { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + } - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || - $event->date_start_in_calendar >= $lastdaytoshow) - { - // This record is out of visible range - unset($event); - } else { + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || + $event->date_start_in_calendar >= $lastdaytoshow) + { + // This record is out of visible range + unset($event); + } else { //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
    '."\n"; $event->fetch_userassigned(); // This load $event->userassigned if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); - // Add an entry in actionarray for each day - $daycursor = $event->date_start_in_calendar; - $annee = date('Y', $daycursor); - $mois = date('m', $daycursor); - $jour = date('d', $daycursor); + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); - // Loop on each day covered by action to prepare an index to show on calendar - $loop = true; $j = 0; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
    '; + // Loop on each day covered by action to prepare an index to show on calendar + $loop = true; $j = 0; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do { + //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
    '; - $eventarray[$daykey][] = $event; - $j++; + $eventarray[$daykey][] = $event; + $j++; - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; - } while ($loop); + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } while ($loop); - //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); - //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
    '; - } - $i++; - } - $db->free($resql); + //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); + //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
    '; + } + $i++; + } + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } $maxnbofchar = 18; @@ -634,7 +634,7 @@ $cacheusers = array(); $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; if (is_readable($color_file)) { - include_once $color_file; + include_once $color_file; } if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); @@ -722,7 +722,7 @@ foreach ($typeofevents as $typeofevent) continue; } - // Show days of the current week + // Show days of the current week $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); $tmparray = dol_getdate($curtime, 'fast'); $tmpday = $tmparray['mday']; @@ -946,15 +946,15 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $busy = $event->transparency; $cases1[$h][$event->id]['busy'] = $busy; $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); - if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } - if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; - $cases1[$h][$event->id]['typecode'] = $event->type_code; + if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } + if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; + $cases1[$h][$event->id]['typecode'] = $event->type_code; $cases1[$h][$event->id]['color'] = $color; if ($event->fk_project > 0) { @@ -993,13 +993,13 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $cases2[$h][$event->id]['busy'] = $busy; $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } - if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } + if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; $cases2[$h][$event->id]['typecode'] = $event->type_code; $cases2[$h][$event->id]['color'] = $color; if ($event->fk_project > 0) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 899925b16f6..8983dbff7f6 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -74,7 +74,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden(); if (!$user->rights->agenda->allactions->read) $canedit = 0; if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert = $user->id; + $filtert = $user->id; } //$action=GETPOST('action','alpha'); @@ -92,10 +92,10 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $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)); + $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); @@ -129,13 +129,13 @@ if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $statu if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { - $action = 'show_month'; $day = ''; + $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { - $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); } // View by week if (GETPOST('viewday', 'alpha') || $action == 'show_day') { - $action = 'show_day'; $day = ($day ? $day : date("d")); + $action = 'show_day'; $day = ($day ? $day : date("d")); } // View by day // Load translation files required by the page @@ -151,13 +151,13 @@ $hookmanager->initHooks(array('agenda')); if ($action == 'delete_action') { - $event = new ActionComm($db); - $event->fetch($actionid); - $event->fetch_optionals(); - $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event = new ActionComm($db); + $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; - $result = $event->delete(); + $result = $event->delete(); } @@ -323,8 +323,8 @@ if ($conf->use_javascript_ajax) $s .= 'jQuery(".family_birthday").toggle();'."\n"; if ($action == "show_week" || $action == "show_month" || empty($action)) { - $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; - $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; + $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; + $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; } $s .= '});'."\n"; $s .= ''."\n"; @@ -351,15 +351,15 @@ if ($conf->use_javascript_ajax) //$s.='
    '.$langs->trans("AgendaShowBirthdayEvents").'  
    '; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } } } @@ -408,7 +408,7 @@ if ($user->rights->agenda->myactions->create || $user->rights->agenda->allaction //$param='month='.$monthshown.'&year='.$year; $hourminsec = '100000'; - $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); + $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); } print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); @@ -457,26 +457,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode if (!empty($actioncode)) { - if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; - } - } else { - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; - else { - if (is_array($actioncode)) - { - $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; - } - } - } + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; + } + } else { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else { + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } + } } if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); @@ -486,28 +486,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; } else { - // To limit array - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow - $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; // End 2 day after $lastdaytoshow - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; - $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; - $sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; - $sql .= ')'; + // To limit array + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow + $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; // End 2 day after $lastdaytoshow + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; + $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; + $sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; + $sql .= ')'; } if ($type) $sql .= " AND ca.id = ".$type; if ($status == '0') { $sql .= " AND a.percent = 0"; } @@ -518,10 +518,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action @@ -531,105 +531,105 @@ dol_syslog("comm/action/peruser.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); - // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') - { - $i++; - continue; - } + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') + { + $i++; + continue; + } - $datep = $db->jdate($obj->datep); - $datep2 = $db->jdate($obj->datep2); + $datep = $db->jdate($obj->datep); + $datep2 = $db->jdate($obj->datep2); - // Create a new object action - $event = new ActionComm($db); - $event->id = $obj->id; - $event->datep = $datep; // datep and datef are GMT date - $event->datef = $datep2; - $event->type_code = $obj->code; - $event->type_color = $obj->color; - $event->label = $obj->label; - $event->percentage = $obj->percent; - $event->authorid = $obj->fk_user_author; // user id of creator - $event->userownerid = $obj->fk_user_action; // user id of owner - $event->priority = $obj->priority; - $event->fulldayevent = $obj->fulldayevent; - $event->location = $obj->location; - $event->transparency = $obj->transparency; + // Create a new object action + $event = new ActionComm($db); + $event->id = $obj->id; + $event->datep = $datep; // datep and datef are GMT date + $event->datef = $datep2; + $event->type_code = $obj->code; + $event->type_color = $obj->color; + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; - $event->fk_project = $obj->fk_project; + $event->fk_project = $obj->fk_project; - $event->socid = $obj->fk_soc; - $event->contact_id = $obj->fk_contact; + $event->socid = $obj->fk_soc; + $event->contact_id = $obj->fk_contact; - $event->fk_element = $obj->fk_element; - $event->elementtype = $obj->elementtype; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; - // Defined date_start_in_calendar and date_end_in_calendar property - // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) - { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } else { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } - // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { - $event->ponctuel = 1; - } + // Defined date_start_in_calendar and date_end_in_calendar property + // They are date start and end of action but modified to not be outside calendar view. + if ($event->percentage <= 0) + { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } else { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + } - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || - $event->date_start_in_calendar >= $lastdaytoshow) - { - // This record is out of visible range - unset($event); - } else { + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || + $event->date_start_in_calendar >= $lastdaytoshow) + { + // This record is out of visible range + unset($event); + } else { //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
    '."\n"; - $event->fetch_userassigned(); // This load $event->userassigned + $event->fetch_userassigned(); // This load $event->userassigned if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); - // Add an entry in actionarray for each day - $daycursor = $event->date_start_in_calendar; - $annee = date('Y', $daycursor); - $mois = date('m', $daycursor); - $jour = date('d', $daycursor); + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); - // Loop on each day covered by action to prepare an index to show on calendar - $loop = true; $j = 0; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
    '; + // Loop on each day covered by action to prepare an index to show on calendar + $loop = true; $j = 0; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do { + //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
    '; - $eventarray[$daykey][] = $event; - $j++; + $eventarray[$daykey][] = $event; + $j++; - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; - } while ($loop); + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } while ($loop); - //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); - //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
    '; - } - $i++; - } - $db->free($resql); + //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); + //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
    '; + } + $i++; + } + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } $maxnbofchar = 18; @@ -641,7 +641,7 @@ $cacheusers = array(); $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; if (is_readable($color_file)) { - include_once $color_file; + include_once $color_file; } if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); @@ -750,15 +750,15 @@ while ($currentdaytoshow < $lastdaytoshow) { { foreach ($eventarray as $daykey => $notused) { - // Get all assigned users for each event - foreach ($eventarray[$daykey] as $index => $event) - { - $event->fetch_userassigned(); + // Get all assigned users for each event + foreach ($eventarray[$daykey] as $index => $event) + { + $event->fetch_userassigned(); $listofuserid = $event->userassigned; foreach ($listofuserid as $userid => $tmp) { if (!in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; } - } + } } } else { /* Use this list to have for all users */ @@ -770,17 +770,17 @@ while ($currentdaytoshow < $lastdaytoshow) { //print $sql; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $num = $db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); $usernamesid[$obj->rowid] = $obj->rowid; $i++; - } - } + } + } } else dol_print_error($db); } //var_dump($usernamesid); @@ -846,7 +846,7 @@ while ($currentdaytoshow < $lastdaytoshow) { continue; } - // Show days of the current week + // Show days of the current week $curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd'); $tmparray = dol_getdate($curtime, 'fast'); $tmpday = $tmparray['mday']; @@ -1102,13 +1102,13 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $busy = $event->transparency; $cases1[$h][$event->id]['busy'] = $busy; $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); - if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } + if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; $cases1[$h][$event->id]['typecode'] = $event->type_code; $cases1[$h][$event->id]['color'] = $color; @@ -1149,12 +1149,12 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $cases2[$h][$event->id]['busy'] = $busy; $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; $cases2[$h][$event->id]['typecode'] = $event->type_code; $cases2[$h][$event->id]['color'] = $color; @@ -1241,7 +1241,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & } $ids1 = ''; - $ids2 = ''; + $ids2 = ''; if (is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h])); if (is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$h])); diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index fbb49772d3e..3534d3d8996 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -91,13 +91,13 @@ $sql .= " ORDER BY year DESC, month DESC, df DESC"; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -113,7 +113,7 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; print '
    '; - if ($optioncss != '') print ''; + if ($optioncss != '') print ''; print ''; print ''; print ''; @@ -125,10 +125,10 @@ if ($resql) $moreforfilter = ''; $i = 0; - print '
    '; - print ''."\n"; + print '
    '; + print '
    '."\n"; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php index d154dc7aafb..84af27bb7b9 100644 --- a/htdocs/comm/admin/propal_extrafields.php +++ b/htdocs/comm/admin/propal_extrafields.php @@ -68,19 +68,19 @@ print load_fiche_titre($langs->trans("PropalSetup"), $linkback, 'title_setup'); $head = propal_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Proposals"), -1, 'propal'); +print dol_get_fiche_head($head, 'attributes', $langs->trans("Proposals"), -1, 'propal'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
    '; - print ''; - print "
    "; + print '
    '; + print ''; + print "
    "; } @@ -92,10 +92,10 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
    "; - print load_fiche_titre($langs->trans('NewAttribute')); + print "
    "; + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -105,10 +105,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
    "; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php index 1acdbfa5ca1..fa12fe9b555 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -75,11 +75,11 @@ print load_fiche_titre($langs->trans("PropalSetup"), $linkback, 'title_setup'); $head = propal_admin_prepare_head(); -dol_fiche_head($head, 'attributeslines', $langs->trans("Proposals"), -1, 'propal'); +print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Proposals"), -1, 'propal'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 8dabe102066..624526a9a5d 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -245,7 +245,7 @@ if ($object->id > 0) { $head = societe_prepare_head($object); - dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), -1, 'company'); + print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -487,26 +487,26 @@ if ($object->id > 0) print ''; } - if (! empty($conf->intracommreport->enabled)) - { - // Transport mode by default - print '"; - print ''; - } + if (!empty($conf->intracommreport->enabled)) + { + // Transport mode by default + print '"; + print ''; + } // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { @@ -639,10 +639,11 @@ if ($object->id > 0) if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { // Box factures - $tmp = $object->getOutstandingBills(); + $tmp = $object->getOutstandingBills('customer', 0); $outstandingOpened = $tmp['opened']; $outstandingTotal = $tmp['total_ht']; $outstandingTotalIncTax = $tmp['total_ttc']; + $text = $langs->trans("OverAllInvoices"); $link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id; $icon = 'bill'; @@ -668,6 +669,24 @@ if ($object->id > 0) $boxstat .= ''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; $boxstat .= ''; if ($link) $boxstat .= ''; + + $tmp = $object->getOutstandingBills('customer', 1); + $outstandingOpenedLate = $tmp['opened']; + if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) { + $warn = ''; + if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpenedLate) { + $warn = ' '.img_warning($langs->trans("OutstandingBillReached")); + } + $text = $langs->trans("CurrentOutstandingBillLate"); + $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; + $icon = 'bill'; + if ($link) $boxstat .= ''; + $boxstat .= '
    '; + $boxstat .= ''.img_object("", $icon).' '.$text.'
    '; + $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; + $boxstat .= '
    '; + if ($link) $boxstat .= '
    '; + } } $parameters = array(); @@ -954,7 +973,7 @@ if ($object->id > 0) $late = ''; foreach ($contrat->lines as $line) { if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) { - if (((!empty($line->date_fin_validite)?$line->date_fin_validite:0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); + if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); } } @@ -1237,7 +1256,7 @@ if ($object->id > 0) print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 1038afa923f..9c4e1437ced 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -59,13 +59,13 @@ llxHeader('', $langs->trans("Contacts")); if ($type == "c" || $type == "p") { - $label = $langs->trans("Customers"); - $urlfiche = "card.php"; + $label = $langs->trans("Customers"); + $urlfiche = "card.php"; } if ($type == "f") { - $label = $langs->trans("Suppliers"); - $urlfiche = "card.php"; + $label = $langs->trans("Suppliers"); + $urlfiche = "card.php"; } /* @@ -88,29 +88,29 @@ if ($socid) $sql .= " AND s.rowid = ".$socid; if (dol_strlen($stcomm)) { - $sql .= " AND s.fk_stcomm=".$db->escape($stcomm); + $sql .= " AND s.fk_stcomm=".$db->escape($stcomm); } if (!empty($search_lastname)) { - $sql .= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; + $sql .= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; } if (!empty($search_firstname)) { - $sql .= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; + $sql .= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; } if (!empty($search_company)) { - $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; + $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; } if (!empty($contactname)) // acces a partir du module de recherche { - $sql .= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; - $sortfield = "p.name"; - $sortorder = "ASC"; + $sql .= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; + $sortfield = "p.name"; + $sortorder = "ASC"; } $sql .= $db->order($sortfield, $sortorder); @@ -171,7 +171,7 @@ if ($resql) $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } // End of page diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 1e09d3f0beb..8ce38ba4ea3 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -137,10 +137,10 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { * Draft customer proposals */ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { - $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc"; - $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta"; - $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.fk_statut as status,"; + $sql .= " s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; $sql .= " AND p.fk_soc = s.rowid"; @@ -167,6 +167,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $propalstatic->total_ht = $obj->total_ht; $propalstatic->total_tva = $obj->total_tva; $propalstatic->total_ttc = $obj->total_ttc; + $propalstatic->statut = $obj->status; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; @@ -181,7 +182,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { print ''; print ''; print ''; - print ''; + print ''; print ''; $i++; @@ -203,10 +204,10 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { * Draft supplier proposals */ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { - $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc"; - $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.code_fournisseur, s.entity, s.email"; - $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql = "SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.fk_statut as status,"; + $sql .= " s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.code_fournisseur, s.entity, s.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE p.entity IN (".getEntity($supplierproposalstatic->element).")"; $sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT; @@ -232,6 +233,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $supplierproposalstatic->total_ht = $obj->total_ht; $supplierproposalstatic->total_tva = $obj->total_tva; $supplierproposalstatic->total_ttc = $obj->total_ttc; + $supplierproposalstatic->statut = $obj->status; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; @@ -245,7 +247,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa print ''; print ''; print ''; - print ''; + print ''; print ''; $i++; @@ -267,10 +269,10 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa * Draft customer orders */ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { - $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc"; - $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, c.fk_statut as status,"; + $sql .= " s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")"; $sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT; @@ -297,6 +299,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $orderstatic->total_ht = $obj->total_ht; $orderstatic->total_tva = $obj->total_tva; $orderstatic->total_ttc = $obj->total_ttc; + $orderstatic->statut = $obj->status; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; @@ -310,7 +313,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { print ''; print ''; print ''; - print ''; + print ''; print ''; $i++; @@ -329,13 +332,13 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { /* - * Draft suppliers orders + * Draft purchase orders */ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { - $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc"; - $sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.code_fournisseur, s.entity, s.email"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, cf.fk_statut as status,"; + $sql .= " s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.code_fournisseur, s.entity, s.email"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE cf.entity IN (".getEntity($supplierorderstatic->element).")"; $sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT; @@ -362,6 +365,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $supplierorderstatic->total_ht = $obj->total_ht; $supplierorderstatic->total_tva = $obj->total_tva; $supplierorderstatic->total_ttc = $obj->total_ttc; + $supplierorderstatic->statut = $obj->status; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; @@ -375,7 +379,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU print ''; print ''; print ''; - print ''; + print ''; print ''; $i++; @@ -442,8 +446,28 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; $i++; @@ -464,7 +488,7 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { * Last suppliers */ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) { - $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm, s.code_fournisseur, s.entity, s.email"; + $sql = "SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm, s.code_fournisseur, s.entity, s.email, s.fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")"; @@ -477,7 +501,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - startSimpleTable($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f"); + startSimpleTable($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f", 1); if ($num) { $i = 0; @@ -491,17 +515,37 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $companystatic->canvas = $objp->canvas; $companystatic->entity = $objp->entity; $companystatic->email = $objp->email; + $companystatic->fournisseur = $objp->fournisseur; print ''; print ''; - print ''; + print ''; + print ''; print ''; $i++; } } - addSummaryTableLine(2, $num); + addSummaryTableLine(3, $num); finishSimpleTable(true); $db->free($resql); @@ -566,8 +610,11 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T $companystatic->entity = $objp->entity; $companystatic->email = $objp->email; + $staticcontrat->id = $obj->contratid; + $staticcontrat->ref = $obj->ref; + print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -657,8 +704,8 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; @@ -758,8 +805,8 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 64e7df053ea..eb6d29d12a5 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -415,7 +415,7 @@ $formother = new FormOther($db); if ($object->fetch($id) >= 0) { $head = emailing_prepare_head($object); - dol_fiche_head($head, 'advtargets', $langs->trans("Mailing"), 0, 'email'); + print dol_get_fiche_head($head, 'advtargets', $langs->trans("Mailing"), 0, 'email'); print '
    '.$langs->trans("Period").''.$langs->trans("EventsNb").''.$langs->trans("Action").'
    '; - print ''; - print '
    '; - print $langs->trans('IntracommReportTransportMode'); - print ''; - if (($action != 'edittransportmode') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
    '; - print '
    '; - if ($action == 'edittransportmode') - { - $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'fk_transport_mode', 1); - } - else { - $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'none'); - } - print "
    '; + print ''; + print '
    '; + print $langs->trans('IntracommReportTransportMode'); + print ''; + if (($action != 'edittransportmode') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
    '; + print '
    '; + if ($action == 'edittransportmode') + { + $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'fk_transport_mode', 1); + } + else { + $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'none'); + } + print "
    '.$propalstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer').''.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).''.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).'
    '.$supplierproposalstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'supplier').''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'
    '.$orderstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer').''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'
    '.$supplierorderstatic->getNomUrl(1).''.$companystatic->getNomUrl(1, 'supplier').''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'
    '.$companystatic->getNomUrl(1, 'customer').''.$companystatic->getLibCustProspStatut().''.dol_print_date($db->jdate($objp->tms), 'day').''; + //print $companystatic->getLibCustProspStatut(); + + $obj = $companystatic; + $s = ''; + if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) + { + $s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).''; + } + if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; + } + /* + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) + { + $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; + }*/ + print $s; + + print ''.dol_print_date($db->jdate($objp->tms), 'day').'
    '.$companystatic->getNomUrl(1, 'supplier').''.dol_print_date($db->jdate($objp->dm), 'day').''; + + $obj = $companystatic; + $s = ''; + /*if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) + { + $s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).''; + } + if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; + }*/ + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) + { + $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; + } + print $s; + + print ''.dol_print_date($db->jdate($objp->dm), 'day').'
    contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'.$staticcontrat->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 44).''.$staticcontrat->LibStatut($obj->statut, 3).'
    '.$companystatic->getNomUrl(1, 'customer', 44).''.dol_print_date($db->jdate($obj->dp), 'day').''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''.dol_print_date($db->jdate($obj->dp), 'day').''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''.$propalstatic->LibStatut($obj->fk_statut, 3).'
    '.$companystatic->getNomUrl(1, 'customer', 44).''.dol_print_date($db->jdate($obj->dp), 'day').''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''.dol_print_date($db->jdate($obj->dp), 'day').''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).'
    '; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 4fe46859dc7..8697d9dffb2 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -103,7 +103,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - $action = ''; + $action = ''; } // Action send emailing for everybody @@ -188,18 +188,18 @@ if (empty($reshook)) // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... $other = explode(';', $obj->other); $tmpfield = explode('=', $other[0], 2); $other1 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); - $targetobject = null; // Not defined with mass emailing - $parameters = array('mode'=>'emailing'); - $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object + $targetobject = null; // Not defined with mass emailing + $parameters = array('mode'=>'emailing'); + $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object - // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; $substitutionarray['__EMAIL__'] = $obj->email; $substitutionarray['__LASTNAME__'] = $obj->lastname; @@ -253,7 +253,7 @@ if (empty($reshook)) } //$substitutionisok=true; - complete_substitutions_array($substitutionarray, $langs); + complete_substitutions_array($substitutionarray, $langs); $newsubject = make_substitutions($subject, $substitutionarray); $newmessage = make_substitutions($message, $substitutionarray); @@ -319,7 +319,7 @@ if (empty($reshook)) dol_print_error($db); } - //Update status communication of contact prospect + //Update status communication of contact prospect $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("card.php: set prospect contact status", LOG_DEBUG); @@ -331,13 +331,13 @@ if (empty($reshook)) } } - if (!empty($conf->global->MAILING_DELAY)) - { - dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY); - sleep($conf->global->MAILING_DELAY); - } + if (!empty($conf->global->MAILING_DELAY)) + { + dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY); + sleep($conf->global->MAILING_DELAY); + } - //test if CHECK READ change statut prospect contact + //test if CHECK READ change statut prospect contact } else { // Mail failed $nbko++; @@ -417,7 +417,7 @@ if (empty($reshook)) $object->substitutionarrayfortest['__MAILTOEMAIL__'] = ''.$object->sendto.''; // Subject and message substitutions - complete_substitutions_array($object->substitutionarrayfortest, $langs); + complete_substitutions_array($object->substitutionarrayfortest, $langs); $tmpsujet = make_substitutions($object->sujet, $object->substitutionarrayfortest); $tmpbody = make_substitutions($object->body, $object->substitutionarrayfortest); @@ -426,11 +426,11 @@ if (empty($reshook)) $arr_name = array(); $arr_css = array(); - // Add CSS - if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; - if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; + // Add CSS + if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; + if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; - // Attached files + // Attached files $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); if (count($listofpaths)) { @@ -462,9 +462,9 @@ if (empty($reshook)) { $mesgs = array(); - $object->email_from = GETPOST("from"); - $object->email_replyto = GETPOST("replyto"); - $object->email_errorsto = GETPOST("errorsto"); + $object->email_from = GETPOST("from", "none"); // Must allow 'name ' + $object->email_replyto = GETPOST("replyto", "none"); // Must allow 'name ' + $object->email_errorsto = GETPOST("errorsto", "none"); // Must allow 'name ' $object->title = GETPOST("title"); $object->sujet = GETPOST("sujet"); $object->body = GETPOST("bodyemail", 'restricthtml'); @@ -491,7 +491,7 @@ if (empty($reshook)) $mesgs[] = $object->error; } - setEventMessages($mesg, $mesgs, 'errors'); + setEventMessages(null, $mesgs, 'errors'); $action = "create"; } @@ -501,11 +501,10 @@ if (empty($reshook)) $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); if ($action == 'settitle') $object->title = trim(GETPOST('title', 'alpha')); - elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'alpha')); - elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'alpha')); - elseif ($action == 'setemail_errorsto') { - $object->email_errorsto = trim(GETPOST('email_errorsto', 'alpha')); - } elseif ($action == 'settitle' && empty($object->title)) { + elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name ' + elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name ' + elseif ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name ' + elseif ($action == 'settitle' && empty($object->title)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } elseif ($action == 'setfrom' && empty($object->email_from)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); @@ -534,8 +533,8 @@ if (empty($reshook)) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - // Set tmp user directory - dol_add_file_process($upload_dir, 0, 0); + // Set tmp user directory + dol_add_file_process($upload_dir, 0, 0); $action = "edit"; } @@ -547,7 +546,7 @@ if (empty($reshook)) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing + dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing $action = "edit"; } @@ -612,14 +611,14 @@ if (empty($reshook)) if ($object->id > 0) { $result = $object->setStatut(0); - if ($result > 0) - { - //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result > 0) + { + //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } } else { dol_print_error($db); } @@ -708,17 +707,17 @@ if ($action == 'create') // Print mail form print load_fiche_titre($langs->trans("NewMailing"), $availablelink, 'object_email'); - dol_fiche_head(); + print dol_get_fiche_head(); print '
    '; - print ''; + print ''; print ''; print ''; // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); @@ -742,7 +741,7 @@ if ($action == 'create') $doleditor->Create(); print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; @@ -776,14 +775,14 @@ if ($action == 'create') if ($action != 'edit' && $action != 'edithtml') { - dol_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); + print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); /* * View mode mailing */ if ($action == 'sendall') { - // Define message to recommand from command line + // Define message to recommand from command line $sendingmode = $conf->global->EMAILING_MAIL_SENDMODE; if (empty($sendingmode)) $sendingmode = $conf->global->MAIN_MAIL_SENDMODE; if (empty($sendingmode)) $sendingmode = 'mail'; // If not defined, we use php mail function @@ -803,29 +802,29 @@ if ($action == 'create') $_GET["action"] = ''; } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { - if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); - if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); // The feature is forbidden from GUI, we show just message to use from command line. - setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); setEventMessages('', null, 'warnings'); if ($conf->file->mailing_limit_sendbyweb != '-1') // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it. { - setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... + setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... } $_GET["action"] = ''; } else { - if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); - if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); - $text = ''; - if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) - { - $text .= $langs->trans("MailingNeedCommand"); - $text .= '
    '; - $text .= '

    '; - } - $text .= $langs->trans('ConfirmSendingEmailing').'
    '; + $text = ''; + if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) + { + $text .= $langs->trans("MailingNeedCommand"); + $text .= '
    '; + $text .= '

    '; + } + $text .= $langs->trans('ConfirmSendingEmailing').'
    '; $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', $formquestion, '', 1, 330, 600); } @@ -868,7 +867,11 @@ if ($action == 'create') if ($email && !isValidEmail($email)) { $langs->load("errors"); print img_warning($langs->trans("ErrorBadEMail", $email)); + } elseif ($email && !isValidMailDomain($email)) { + $langs->load("errors"); + print img_warning($langs->trans("ErrorBadMXDomain", $email)); } + print ''; // Errors to @@ -880,6 +883,9 @@ if ($action == 'create') if ($email && !isValidEmail($email)) { $langs->load("errors"); print img_warning($langs->trans("ErrorBadEMail", $email)); + } elseif ($email && !isValidMailDomain($email)) { + $langs->load("errors"); + print img_warning($langs->trans("ErrorBadMXDomain", $email)); } print ''; @@ -890,23 +896,23 @@ if ($action == 'create') $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { - $text = ''; - if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) - { - if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) - { - $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - } else { - $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); - } - } - if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + $text = ''; + if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) + { + if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) + { + $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); + } else { + $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); + } + } + if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; if ($text) - { - print $form->textwithpicto($nbemail, $text, 1, 'warning'); - } else { - print $nbemail; - } + { + print $form->textwithpicto($nbemail, $text, 1, 'warning'); + } else { + print $nbemail; + } } print ''; @@ -917,7 +923,7 @@ if ($action == 'create') print ""; - dol_fiche_end(); + print dol_get_fiche_end(); // Clone confirmation @@ -1024,12 +1030,12 @@ if ($action == 'create') // Display of the TEST form if ($action == 'test') { - print '
    '; - print load_fiche_titre($langs->trans("TestMailing")); + print '
    '; + print load_fiche_titre($langs->trans("TestMailing")); - dol_fiche_head(null, '', '', -1); + print dol_get_fiche_head(null, '', '', -1); - // Create mail form object + // Create mail form object include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->fromname = $object->email_from; @@ -1058,7 +1064,7 @@ if ($action == 'create') print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print dol_set_focus('#sendto'); } @@ -1074,7 +1080,7 @@ if ($action == 'create') // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto(''.$langs->trans("AvailableVariables").'', $htmltext, 1, 'helpclickable', '', 0, 2, 'emailsubstitionhelp'), 'generic'); - dol_fiche_head('', '', '', -1); + print dol_get_fiche_head('', '', '', -1); print '
    '.$langs->trans("MailTitle").'
    '.$langs->trans("MailTitle").'
    '.$langs->trans("MailFrom").'
    '.$langs->trans("MailErrorsTo").'
    '; @@ -1097,14 +1103,14 @@ if ($action == 'create') } print ''; - // Background color - /*print '';*/ print '
    '.$langs->trans("BackgroundColorByDefault").''; + // Background color + /*print '
    '.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($object->bgcolor,'bgcolor','',0); print '
    '; - // Message + // Message print '
    '; if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') // CKEditor does not apply the color of the div into its content area { @@ -1116,13 +1122,13 @@ if ($action == 'create') } else print dol_htmlentitiesbr($object->body); print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } else { /* * Edition mode mailing (CKeditor or HTML source) */ - dol_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); + print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); $linkback = ''.$langs->trans("BackToList").''; @@ -1180,7 +1186,7 @@ if ($action == 'create') // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); @@ -1189,7 +1195,7 @@ if ($action == 'create') print ''; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); @@ -1210,7 +1216,7 @@ if ($action == 'create') // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'generic'); - dol_fiche_head(null, '', '', -1); + print dol_get_fiche_head(null, '', '', -1); print ''; @@ -1255,7 +1261,7 @@ if ($action == 'create') print $out; print ''; - // Background color + // Background color print ''; @@ -1283,7 +1289,7 @@ if ($action == 'create') print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index ff9bb98f639..0d621dfa186 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -78,13 +78,13 @@ if ($action == 'add') foreach ($modulesdir as $dir) { - // Load modules attributes in arrays (name, numero, orders) from dir directory - //print $dir."\n
    "; - dol_syslog("Scan directory ".$dir." for modules"); + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
    "; + dol_syslog("Scan directory ".$dir." for modules"); - // Loading Class - $file = $dir."/".$module.".modules.php"; - $classname = "mailing_".$module; + // Loading Class + $file = $dir."/".$module.".modules.php"; + $classname = "mailing_".$module; if (file_exists($file)) { @@ -213,7 +213,7 @@ if ($object->fetch($id) >= 0) { $head = emailing_prepare_head($object); - dol_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, 'email'); + print dol_get_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, 'email'); $linkback = ''.$langs->trans("BackToList").''; @@ -305,7 +305,7 @@ if ($object->fetch($id) >= 0) print "
    "; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; @@ -337,12 +337,12 @@ if ($object->fetch($id) >= 0) foreach ($modulesdir as $dir) { - $modulenames = array(); + $modulenames = array(); - // Load modules attributes in arrays (name, numero, orders) from dir directory - //print $dir."\n
    "; - dol_syslog("Scan directory ".$dir." for modules"); - $handle = @opendir($dir); + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
    "; + dol_syslog("Scan directory ".$dir." for modules"); + $handle = @opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) @@ -396,7 +396,7 @@ if ($object->fetch($id) >= 0) print ''; print ''; } else { - print '
    '; + print '
    '; } print '
    '; @@ -425,14 +425,14 @@ if ($object->fetch($id) >= 0) print '
    '; if ($allowaddtarget) { - try { - $filter = $obj->formFilter(); - } catch (Exception $e) - { - dol_syslog($e->getMessage(), LOG_ERR); - } - if ($filter) print $filter; - else print $langs->trans("None"); + try { + $filter = $obj->formFilter(); + } catch (Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } + if ($filter) print $filter; + else print $langs->trans("None"); } print '
    '; @@ -441,7 +441,7 @@ if ($object->fetch($id) >= 0) { print ''; } else { - print ''; + print ''; //print $langs->trans("MailNoChangePossible"); print " "; } @@ -474,13 +474,13 @@ if ($object->fetch($id) >= 0) $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets @@ -503,7 +503,7 @@ if ($object->fetch($id) >= 0) print ''; print ''; print ''; - print ''; + print ''; print ''; $morehtmlcenter = ''; @@ -521,7 +521,7 @@ if ($object->fetch($id) >= 0) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -611,30 +611,30 @@ if ($object->fetch($id) >= 0) print '
    '; print ''; print ''; // Date last update @@ -680,9 +680,9 @@ if ($object->fetch($id) >= 0) } else { if ($object->statut < 2) { - print ''; + print ''; } } print "
    '.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($object->bgcolor, 'bgcolor', '', 0); print '
    '.$obj->firstname.''.$obj->other.''; - if (empty($obj->source_id) || empty($obj->source_type)) - { - print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility - } else { - if ($obj->source_type == 'member') - { + if (empty($obj->source_id) || empty($obj->source_type)) + { + print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility + } else { + if ($obj->source_type == 'member') + { $objectstaticmember->fetch($obj->source_id); - print $objectstaticmember->getNomUrl(1); - } elseif ($obj->source_type == 'user') - { + print $objectstaticmember->getNomUrl(1); + } elseif ($obj->source_type == 'user') + { $objectstaticuser->fetch($obj->source_id); - print $objectstaticuser->getNomUrl(1); - } elseif ($obj->source_type == 'thirdparty') - { + print $objectstaticuser->getNomUrl(1); + } elseif ($obj->source_type == 'thirdparty') + { $objectstaticcompany->fetch($obj->source_id); - print $objectstaticcompany->getNomUrl(1); - } elseif ($obj->source_type == 'contact') - { - $objectstaticcontact->fetch($obj->source_id); - print $objectstaticcontact->getNomUrl(1); - } else { - print $obj->source_url; - } - } + print $objectstaticcompany->getNomUrl(1); + } elseif ($obj->source_type == 'contact') + { + $objectstaticcontact->fetch($obj->source_id); + print $objectstaticcontact->getNomUrl(1); + } else { + print $obj->source_url; + } + } print '
    '; - print $langs->trans("NoTargetYet"); - print '
    '; + print $langs->trans("NoTargetYet"); + print '

    "; diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index f82ebec9d6f..447b970f39e 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -28,10 +28,10 @@ */ class AdvanceTargetingMailing extends CommonObject { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -58,20 +58,20 @@ class AdvanceTargetingMailing extends CommonObject */ public $id; - public $name; - public $entity; - public $fk_element; - public $type_element; - public $filtervalue; - public $fk_user_author; - public $datec = ''; - public $fk_user_mod; - public $tms = ''; + public $name; + public $entity; + public $fk_element; + public $type_element; + public $filtervalue; + public $fk_user_author; + public $datec = ''; + public $fk_user_mod; + public $tms = ''; - public $select_target_type = array(); - public $type_statuscommprospect = array(); - public $thirdparty_lines; - public $contact_lines; + public $select_target_type = array(); + public $type_statuscommprospect = array(); + public $thirdparty_lines; + public $contact_lines; /** @@ -79,7 +79,7 @@ class AdvanceTargetingMailing extends CommonObject * * @param DoliDb $db Database handler */ - public function __construct($db) + public function __construct($db) { global $langs; $langs->load('customers'); @@ -108,7 +108,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - public function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error = 0; @@ -177,7 +177,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - public function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -226,16 +226,16 @@ class AdvanceTargetingMailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * * @param int $id Id object * @return int <0 if KO, >0 if OK */ - public function fetch_by_mailing($id = 0) + public function fetch_by_mailing($id = 0) { - // phpcs:enable + // phpcs:enable global $langs; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -290,7 +290,7 @@ class AdvanceTargetingMailing extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * @@ -298,9 +298,9 @@ class AdvanceTargetingMailing extends CommonObject * @param string $type_element Type target * @return int <0 if KO, >0 if OK */ - public function fetch_by_element($id = 0, $type_element = 'mailing') + public function fetch_by_element($id = 0, $type_element = 'mailing') { - // phpcs:enable + // phpcs:enable global $langs; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -359,7 +359,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error = 0; @@ -389,9 +389,9 @@ class AdvanceTargetingMailing extends CommonObject dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; - $this->errors[] = "Error ".$this->db->lasterror(); - } + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } // Commit or rollback if ($error) @@ -416,7 +416,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error = 0; @@ -451,13 +451,13 @@ class AdvanceTargetingMailing extends CommonObject /** - * Save query in database to retreive it + * Save query in database to retrieve it * * @param User $user User that deletes * @param array $arrayquery All element to Query * @return int <0 if KO, >0 if OK */ - public function savequery($user, $arrayquery) + public function savequery($user, $arrayquery) { global $langs, $conf; @@ -477,16 +477,16 @@ class AdvanceTargetingMailing extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from database * * @param array $arrayquery All element to Query * @return int <0 if KO, >0 if OK */ - public function query_thirdparty($arrayquery) + public function query_thirdparty($arrayquery) { - // phpcs:enable + // phpcs:enable global $langs, $conf, $extrafields; $sql = "SELECT"; @@ -625,7 +625,7 @@ class AdvanceTargetingMailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from database * @@ -633,9 +633,9 @@ class AdvanceTargetingMailing extends CommonObject * @param int $withThirdpartyFilter add contact with tridparty filter * @return int <0 if KO, >0 if OK */ - public function query_contact($arrayquery, $withThirdpartyFilter = 0) + public function query_contact($arrayquery, $withThirdpartyFilter = 0) { - // phpcs:enable + // phpcs:enable global $langs, $conf; $sql = "SELECT"; @@ -878,8 +878,8 @@ class AdvanceTargetingMailing extends CommonObject * For exemple jean;joe;jim%%;!jimo;!jima%> will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima * @return string Sql to use for the where condition */ - public function transformToSQL($column_to_test, $criteria) - { + public function transformToSQL($column_to_test, $criteria) + { $return_sql_criteria = '('; //This is a multiple value test diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 53fafb0ce61..9d230404cba 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -28,9 +28,9 @@ class FormAdvTargetEmailing extends Form { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -42,12 +42,12 @@ class FormAdvTargetEmailing extends Form * * @param DoliDB $db handler */ - public function __construct($db) - { - global $langs; + public function __construct($db) + { + global $langs; - $this->db = $db; - } + $this->db = $db; + } /** * Affiche un champs select contenant une liste @@ -56,8 +56,8 @@ class FormAdvTargetEmailing extends Form * @param string $htmlname select field * @return string select field */ - public function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') - { + public function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') + { global $conf, $langs; $options_array = array(); @@ -84,7 +84,7 @@ class FormAdvTargetEmailing extends Form dol_print_error($this->db); } return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return combo list of activated countries, into language of user @@ -93,8 +93,8 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array or Code or Label of preselected country * @return string HTML string with select */ - public function multiselectCountry($htmlname = 'country_id', $selected_array = array()) - { + public function multiselectCountry($htmlname = 'country_id', $selected_array = array()) + { global $conf, $langs; $langs->load("dict"); @@ -142,7 +142,7 @@ class FormAdvTargetEmailing extends Form } return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return select list for categories (to use in form search selectors) @@ -152,14 +152,14 @@ class FormAdvTargetEmailing extends Form * @param User $user User action * @return string combo list code */ - public function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) - { + public function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) + { global $conf; $options_array = array(); - $sql_usr = ''; + $sql_usr = ''; $sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login"; $sql_usr .= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql_usr .= " WHERE u2.entity IN (0,".$conf->entity.")"; @@ -183,7 +183,7 @@ class FormAdvTargetEmailing extends Form } return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return select list for categories (to use in form search selectors) @@ -192,8 +192,8 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array selected array * @return string combo list code */ - public function multiselectselectLanguage($htmlname = '', $selected_array = array()) - { + public function multiselectselectLanguage($htmlname = '', $selected_array = array()) + { global $conf, $langs; @@ -208,7 +208,7 @@ class FormAdvTargetEmailing extends Form } asort($options_array); return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return multiselect list of entities for extrafeild type sellist @@ -330,14 +330,14 @@ class FormAdvTargetEmailing extends Form * @param int $showempty show empty * @return string HTML combo */ - public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) - { + public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) + { global $conf, $langs; $form = new Form($this->db); $return = $form->multiselectarray($htmlname, $options_array, $selected_array, 0, 0, '', 0, 295); return $return; - } + } /** * Return a combo list to select emailing target selector @@ -349,8 +349,8 @@ class FormAdvTargetEmailing extends Form * @param string $morecss More CSS * @return string HTML combo */ - public function selectAdvtargetemailingTemplate($htmlname = 'template_id', $selected = 0, $showempty = 0, $type_element = 'mailing', $morecss = '') - { + public function selectAdvtargetemailingTemplate($htmlname = 'template_id', $selected = 0, $showempty = 0, $type_element = 'mailing', $morecss = '') + { global $conf, $user, $langs; $out = ''; @@ -390,5 +390,5 @@ class FormAdvTargetEmailing extends Form } $this->db->free($resql); return $out; - } + } } diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 704d0892ab5..48c00c697a1 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -68,8 +68,8 @@ class Mailing extends CommonObject public $user_valid; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creat; @@ -81,13 +81,13 @@ class Mailing extends CommonObject public $statuts = array(); - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { $this->db = $db; // List of language codes for status @@ -101,7 +101,7 @@ class Mailing extends CommonObject $this->statut_dest[1] = 'MailingStatusSent'; $this->statut_dest[2] = 'MailingStatusRead'; $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore - } + } /** * Create an EMailing @@ -224,8 +224,8 @@ class Mailing extends CommonObject $this->title = $obj->title; $this->sujet = $obj->sujet; - if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401))) { - $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401); + if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) { + $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5); } else { $this->body = $obj->body; } @@ -427,7 +427,7 @@ class Mailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete targets emailing * @@ -435,7 +435,7 @@ class Mailing extends CommonObject */ public function delete_targets() { - // phpcs:enable + // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " WHERE fk_mailing = ".$this->id; @@ -451,7 +451,7 @@ class Mailing extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Change status of each recipient * @@ -460,7 +460,7 @@ class Mailing extends CommonObject */ public function reset_targets_status($user) { - // phpcs:enable + // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut = 0"; $sql .= " WHERE fk_mailing = ".$this->id; @@ -485,26 +485,26 @@ class Mailing extends CommonObject */ public function countNbOfTargets($mode) { - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " WHERE fk_mailing = ".$this->id; - if ($mode == 'alreadysent') $sql .= " AND statut <> 0"; - elseif ($mode == 'alreadysentok') $sql .= " AND statut > 0"; - elseif ($mode == 'alreadysentko') $sql .= " AND statut = -1"; - else { - $this->error = 'BadValueForParameterMode'; - return -2; - } + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; + $sql .= " WHERE fk_mailing = ".$this->id; + if ($mode == 'alreadysent') $sql .= " AND statut <> 0"; + elseif ($mode == 'alreadysentok') $sql .= " AND statut > 0"; + elseif ($mode == 'alreadysentko') $sql .= " AND statut = -1"; + else { + $this->error = 'BadValueForParameterMode'; + return -2; + } - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) return $obj->nb; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - return 0; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj) return $obj->nb; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + return 0; } @@ -593,7 +593,7 @@ class Mailing extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -603,7 +603,7 @@ class Mailing extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load("mailing"); diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index ddcdaabf14e..8c1e392ed68 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -57,19 +57,19 @@ print '
    '; //if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo //{ - // Recherche emails - print ''; - print ''; - print '
    '; - print ''; - print ''; - print ''; - print ''; - print ''; + // Recherche emails + print ''; + print ''; + print '
    '; + print '
    '.$langs->trans("SearchAMailing").'
    '; - print $langs->trans("Ref").':
    '; - print $langs->trans("Other").':
    '; + print ''; + print ''; + print ''; + print ''; - print "
    '.$langs->trans("SearchAMailing").'
    '; + print $langs->trans("Ref").':
    '; + print $langs->trans("Other").':

    \n"; + print "

    \n"; //} @@ -82,63 +82,63 @@ $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) - { - $modulename = $reg[1]; - if ($modulename == 'example') continue; + while (($file = readdir($handle)) !== false) + { + if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) + { + $modulename = $reg[1]; + if ($modulename == 'example') continue; - // Loading Class - $file = $dir."/".$modulename.".modules.php"; - $classname = "mailing_".$modulename; - require_once $file; - $mailmodule = new $classname($db); + // Loading Class + $file = $dir."/".$modulename.".modules.php"; + $classname = "mailing_".$modulename; + require_once $file; + $mailmodule = new $classname($db); - $qualified = 1; - foreach ($mailmodule->require_module as $key) - { - if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) - { - $qualified = 0; - //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; - break; - } - } + $qualified = 1; + foreach ($mailmodule->require_module as $key) + { + if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) + { + $qualified = 0; + //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; + break; + } + } - // Si le module mailing est qualifi� - if ($qualified) - { - foreach ($mailmodule->getSqlArrayForStats() as $sql) - { - print ''; + // Si le module mailing est qualifi� + if ($qualified) + { + foreach ($mailmodule->getSqlArrayForStats() as $sql) + { + print ''; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); - $i = 0; + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); - print ''.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; - $i++; - } + while ($i < $num) + { + $obj = $db->fetch_object($result); + print ''.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; + $i++; + } - $db->free($result); - } else { - dol_print_error($db); - } - print ''; - } - } - } - } - } - closedir($handle); + $db->free($result); + } else { + dol_print_error($db); + } + print ''; + } + } + } + } + } + closedir($handle); } @@ -160,42 +160,42 @@ $sql .= " ORDER BY m.date_creat DESC"; $sql .= " LIMIT ".$limit; $result = $db->query($sql); if ($result) { - print '
    '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
    '; + print '
    '.$langs->trans("LastMailings", $limit).''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
    '; + print ''; + print ''; + print ''; + print ''; + print ''; - $num = $db->num_rows($result); - if ($num > 0) - { - $i = 0; + $num = $db->num_rows($result); + if ($num > 0) + { + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); $mailstatic = new Mailing($db); $mailstatic->id = $obj->rowid; $mailstatic->ref = $obj->rowid; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - } else { - print ''; - } - print "
    '.$langs->trans("LastMailings", $limit).''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
    '.$mailstatic->getNomUrl(1).''.dol_trunc($obj->title, 38).''.dol_print_date($db->jdate($obj->date_creat), 'day').''.($obj->nbemail ? $obj->nbemail : "0").''.$mailstatic->LibStatut($obj->statut, 5).'
    '.$langs->trans("None").'

    "; - $db->free($result); + print ''; + print ''.$mailstatic->getNomUrl(1).''; + print ''.dol_trunc($obj->title, 38).''; + print ''.dol_print_date($db->jdate($obj->date_creat), 'day').''; + print ''.($obj->nbemail ? $obj->nbemail : "0").''; + print ''.$mailstatic->LibStatut($obj->statut, 5).''; + print ''; + $i++; + } + } else { + print ''.$langs->trans("None").''; + } + print "

    "; + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } @@ -204,12 +204,12 @@ print ''; if ($langs->file_exists("html/spam.html", 0)) { - print "



    ".$langs->trans("Note")."
    "; - print '
    '; - dol_print_file($langs, "html/spam.html", 0); - print '
    '; + print "



    ".$langs->trans("Note")."
    "; + print '
    '; + dol_print_file($langs, "html/spam.html", 0); + print '
    '; - print '
    '; + print '
    '; } $parameters = array('user' => $user); diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php index 070d46f6104..199a5caad8b 100644 --- a/htdocs/comm/mailing/info.php +++ b/htdocs/comm/mailing/info.php @@ -52,7 +52,7 @@ if ($object->fetch($id) >= 0) { $head = emailing_prepare_head($object); - dol_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email'); + print dol_get_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email'); $linkback = ''.$langs->trans("BackToList").''; @@ -81,7 +81,7 @@ if ($object->fetch($id) >= 0) //print ''; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 525064942a6..9da825e262e 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -60,7 +60,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'm.titre'=>'Ref', + 'm.titre'=>'Ref', ); @@ -169,7 +169,7 @@ if ($resql) $newcardbutton = ''; if ($user->rights->mailing->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); } $i = 0; @@ -190,8 +190,8 @@ if ($resql) $moreforfilter = ''; - print '
    '; - print ''."\n"; + print '
    '; + print '
    '."\n"; print ''; print '
    '; diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index cd5d5c9ace9..bd4c16f89ca 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -80,7 +80,7 @@ if ($_socid > 0) print ''; print ''; - dol_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company'); + print dol_get_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company'); print ''; @@ -105,7 +105,7 @@ if ($_socid > 0) print "
    "; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 9caf2c8483c..8613828f632 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -166,7 +166,7 @@ if (empty($reshook)) if ($object->id > 0) { if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY)) { //Get difference between old and new delivery date and change lines according to difference - $date_delivery = dol_mktime(12, 0, 0, + $date_delivery = dol_mktime(12, 0, 0, GETPOST('date_deliverymonth', 'int'), GETPOST('date_deliveryday', 'int'), GETPOST('date_deliveryyear', 'int') @@ -174,7 +174,7 @@ if (empty($reshook)) if (!empty($object->date_livraison) && !empty($date_delivery)) { //Attempt to get the date without possible hour rounding errors - $old_date_delivery = dol_mktime(12, 0, 0, + $old_date_delivery = dol_mktime(12, 0, 0, dol_print_date($object->date_livraison, '%m'), dol_print_date($object->date_livraison, '%d'), dol_print_date($object->date_livraison, '%Y') @@ -184,6 +184,7 @@ if (empty($reshook)) if ($difference != 0) { $object->date_livraison = $date_delivery; + $object->delivery_date = $date_delivery; foreach ($object->lines as $line) { if (isset($line->date_start)) $line->date_start = $line->date_start + $difference; @@ -287,7 +288,7 @@ if (empty($reshook)) dol_print_error($db, $object->error); } elseif ($action == 'setdate_livraison' && $usercancreate) { - $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST['date_livraisonmonth'], $_POST['date_livraisonday'], $_POST['date_livraisonyear'])); + $result = $object->setDeliveryDate($user, dol_mktime(12, 0, 0, $_POST['date_livraisonmonth'], $_POST['date_livraisonday'], $_POST['date_livraisonyear'])); if ($result < 0) dol_print_error($db, $object->error); } // Positionne ref client @@ -372,13 +373,13 @@ if (empty($reshook)) $object->ref_client = GETPOST('ref_client'); $object->datep = $datep; $object->date_livraison = $date_delivery; - $object->availability_id = GETPOST('availability_id'); - $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->fk_delivery_address = GETPOST('fk_address'); + $object->availability_id = GETPOST('availability_id', 'int'); + $object->demand_reason_id = GETPOST('demand_reason_id', 'int'); + $object->fk_delivery_address = GETPOST('fk_address', 'int'); $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); - $object->duree_validite = GETPOST('duree_validite'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->duree_validite = price2num(GETPOST('duree_validite', 'alpha')); + $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); + $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); $object->fk_account = GETPOST('fk_account', 'int'); $object->contact_id = GETPOST('contactid', 'int'); $object->fk_project = GETPOST('projectid', 'int'); @@ -666,82 +667,82 @@ if (empty($reshook)) } } // add lines from objectlinked elseif ($action == 'import_lines_from_object' - && $user->rights->propal->creer - && $object->statut == Propal::STATUS_DRAFT - ) + && $user->rights->propal->creer + && $object->statut == Propal::STATUS_DRAFT + ) { - $fromElement = GETPOST('fromelement'); - $fromElementid = GETPOST('fromelementid'); - $importLines = GETPOST('line_checkbox'); + $fromElement = GETPOST('fromelement'); + $fromElementid = GETPOST('fromelementid'); + $importLines = GETPOST('line_checkbox'); - if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) - { - if ($fromElement == 'commande') - { - dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'OrderLine'; - } elseif ($fromElement == 'propal') - { - dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'PropaleLigne'; - } - $nextRang = count($object->lines) + 1; - $importCount = 0; - $error = 0; - foreach ($importLines as $lineId) - { - $lineId = intval($lineId); - $originLine = new $lineClassName($db); - if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) - { - $originLine->fetch_optionals(); - $desc = $originLine->desc; - $pu_ht = $originLine->subprice; - $qty = $originLine->qty; - $txtva = $originLine->tva_tx; - $txlocaltax1 = $originLine->localtax1_tx; - $txlocaltax2 = $originLine->localtax2_tx; - $fk_product = $originLine->fk_product; - $remise_percent = $originLine->remise_percent; - $date_start = $originLine->date_start; - $date_end = $originLine->date_end; - $ventil = 0; - $info_bits = $originLine->info_bits; - $fk_remise_except = $originLine->fk_remise_except; - $price_base_type = 'HT'; - $pu_ttc = 0; - $type = $originLine->product_type; - $rang = $nextRang++; - $special_code = $originLine->special_code; - $origin = $originLine->element; - $origin_id = $originLine->id; - $fk_parent_line = 0; - $fk_fournprice = $originLine->fk_fournprice; - $pa_ht = $originLine->pa_ht; - $label = $originLine->label; - $array_options = $originLine->array_options; - $situation_percent = 100; - $fk_prev_id = ''; - $fk_unit = $originLine->fk_unit; - $pu_ht_devise = $originLine->multicurrency_subprice; + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + { + if ($fromElement == 'commande') + { + dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'OrderLine'; + } elseif ($fromElement == 'propal') + { + dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'PropaleLigne'; + } + $nextRang = count($object->lines) + 1; + $importCount = 0; + $error = 0; + foreach ($importLines as $lineId) + { + $lineId = intval($lineId); + $originLine = new $lineClassName($db); + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + { + $originLine->fetch_optionals(); + $desc = $originLine->desc; + $pu_ht = $originLine->subprice; + $qty = $originLine->qty; + $txtva = $originLine->tva_tx; + $txlocaltax1 = $originLine->localtax1_tx; + $txlocaltax2 = $originLine->localtax2_tx; + $fk_product = $originLine->fk_product; + $remise_percent = $originLine->remise_percent; + $date_start = $originLine->date_start; + $date_end = $originLine->date_end; + $ventil = 0; + $info_bits = $originLine->info_bits; + $fk_remise_except = $originLine->fk_remise_except; + $price_base_type = 'HT'; + $pu_ttc = 0; + $type = $originLine->product_type; + $rang = $nextRang++; + $special_code = $originLine->special_code; + $origin = $originLine->element; + $origin_id = $originLine->id; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; + $pa_ht = $originLine->pa_ht; + $label = $originLine->label; + $array_options = $originLine->array_options; + $situation_percent = 100; + $fk_prev_id = ''; + $fk_unit = $originLine->fk_unit; + $pu_ht_devise = $originLine->multicurrency_subprice; - $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $date_start, $date_end, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise, $fk_remise_except); + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $date_start, $date_end, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise, $fk_remise_except); - if ($res > 0) { - $importCount++; - } else { - $error++; - } - } else { - $error++; - } - } + if ($res > 0) { + $importCount++; + } else { + $error++; + } + } else { + $error++; + } + } - if ($error) - { - setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); - } - } + if ($error) + { + setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); + } + } } include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -806,7 +807,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'MS'); $remise_percent = GETPOST('remise_percent'.$predef); if (empty($remise_percent)) $remise_percent = 0; @@ -890,8 +891,8 @@ if (empty($reshook)) $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } // If price per customer elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) @@ -1229,7 +1230,10 @@ if (empty($reshook)) } } } - $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise); + + $qty = price2num(GETPOST('qty'), 'MS'); + + $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise); if ($result >= 0) { $db->commit(); @@ -1283,8 +1287,8 @@ if (empty($reshook)) header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } elseif ($action == 'classin' && $usercancreate) { - // Set project - $object->setProject(GETPOST('projectid', 'int')); + // Set project + $object->setProject(GETPOST('projectid', 'int')); } // Delivery time elseif ($action == 'setavailability' && $usercancreate) { $result = $object->set_availability($user, GETPOST('availability_id', 'int')); @@ -1321,7 +1325,7 @@ if (empty($reshook)) if ($ret < 0) $error++; if (!$error) { - $result = $object->insertExtraFields('PROPAL_MODIFY'); + $result = $object->updateExtraField(GETPOST('attribute', 'restricthtml'), 'PROPAL_MODIFY', $user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -1484,7 +1488,7 @@ if ($action == 'create') print ''; } - dol_fiche_head(); + print dol_get_fiche_head(); print ''; @@ -1504,18 +1508,16 @@ if ($action == 'create') print $soc->getNomUrl(1); print ''; print ''; - if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) { - $shipping_method_id = $soc->shipping_method_id; - } } else { print ''; } diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 0f60be3c3a8..842322f7f20 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -19,7 +19,7 @@ */ /** - * \file cashcontrol/class/cashcontrol.class.php + * \file htdocs/compta/cashcontrol/class/cashcontrol.class.php * \ingroup cashdesk|takepos * \brief This file is CRUD class file (Create/Read/Update/Delete) for cash fence table */ @@ -66,8 +66,8 @@ class CashControl extends CommonObject 'cash' =>array('type'=>'price', 'label'=>'Cash', 'enabled'=>1, 'visible'=>1, 'position'=>30), 'cheque' =>array('type'=>'price', 'label'=>'Cheque', 'enabled'=>1, 'visible'=>1, 'position'=>33), 'card' =>array('type'=>'price', 'label'=>'CreditCard', 'enabled'=>1, 'visible'=>1, 'position'=>36), - 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>50, 'css'=>'center'), - 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'css'=>'center'), + 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>50, 'css'=>'center'), + 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'css'=>'center'), 'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>60, 'css'=>'center'), 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>490), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), @@ -76,6 +76,9 @@ class CashControl extends CommonObject 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated')), ); + /** + * @var int Object Id + */ public $id; public $opening; public $status; @@ -94,8 +97,8 @@ class CashControl extends CommonObject public $date_valid; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; /** @@ -286,7 +289,7 @@ class CashControl extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + //if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -311,8 +314,8 @@ class CashControl extends CommonObject */ public function delete(User $user, $notrigger = false) { - return $this->deleteCommon($user, $notrigger); - //return $this->deleteCommon($user, $notrigger, 1); + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); } /** @@ -357,10 +360,10 @@ class CashControl extends CommonObject * Return clicable link of object (with eventually picto) * * @param int $withpicto Add picto into link - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) @@ -381,24 +384,24 @@ class CashControl extends CommonObject if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } $linkclose = ''; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $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 @@ -420,8 +423,10 @@ class CashControl extends CommonObject $hookmanager->initHooks(array('cashfencedao')); $parameters = array('id'=>$this->id, 'getnomurl'=>$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) { $result = $hookmanager->resPrint; - } else { $result .= $hookmanager->resPrint; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; } return $result; diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 02299788794..515067900e3 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2012 Vinícius Nogueira * Copyright (C) 2014 Florian Henry @@ -29,13 +29,16 @@ * \brief List of bank transactions */ +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; -$langs->load("bills"); +$langs->loadLangs(array("bills", "banks")); $id = GETPOST('id', 'int'); @@ -49,13 +52,13 @@ $sortorder = 'ASC'; $sortfield = 'b.datev,b.dateo,b.rowid'; $arrayfields = array( - 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), - 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), - 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), + 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), + 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), + 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), - 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), + 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), ); $syear = $cashcontrol->year_close; @@ -122,13 +125,13 @@ elseif ($syear && $smonth && $sday) $sql .= " AND datef BETWEEN '".$db->idate( else dol_print_error('', 'Year not defined'); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; + print "\n"; print "

    "; - if ($cashcontrol->status == 2) print $langs->trans("CashControl")." ".$cashcontrol->id; + if ($cashcontrol->status != $cashcontrol::STATUS_DRAFT) print $langs->trans("CashControl")." ".$cashcontrol->id; else print $langs->trans("CashControl")." - ".$langs->trans("Draft"); print "
    ".$langs->trans("DateCreationShort").": ".dol_print_date($cashcontrol->date_creation, 'dayhour')."

    "; @@ -138,10 +141,10 @@ if ($resql) print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash")." : ".price($cashcontrol->opening); print ""; - print '
    '; - print '
    '; print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500'); // reload page to retrieve customer informations - if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) + if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { print '"; exit; } - $action = "view"; + $action = "view"; } // Action to delete if ($action == 'confirm_delete' && !empty($permissiontodelete)) { - $object->fetch($id); + $object->fetch($id); - if (!($object->id > 0)) - { - dol_print_error('', 'Error, object must be fetched before being deleted'); - exit; - } + if (!($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } - $result = $object->delete($user); - //var_dump($result); - if ($result > 0) - { - // Delete OK - setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".$backurlforlist); - exit; - } else { - if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } + $result = $object->delete($user); + //var_dump($result); + if ($result > 0) + { + // Delete OK + setEventMessages("RecordDeleted", null, 'mesgs'); + header("Location: ".$backurlforlist); + exit; + } else { + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + } } @@ -306,22 +307,22 @@ if ($action == "create" || $action == "start" || $action == 'close') if ($bankid > 0) { - $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; - $sql .= " WHERE fk_account = ".$bankid; - if ($syear && !$smonth) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; - elseif ($syear && $smonth && !$sday) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; - elseif ($syear && $smonth && $sday) $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; - else dol_print_error('', 'Year not defined'); + $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; + $sql .= " WHERE fk_account = ".$bankid; + if ($syear && !$smonth) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; + elseif ($syear && $smonth && !$sday) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; + else dol_print_error('', 'Year not defined'); - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total; - } else dol_print_error($db); + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total; + } else dol_print_error($db); } else { setEventMessages($langs->trans("SetupOfTerminalNotComplete", $terminaltouse), null, 'errors'); - $error++; + $error++; } } @@ -369,50 +370,50 @@ if ($action == "create" || $action == "start" || $action == 'close') print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'cash-register'); print '
    '; - print ''; + print ''; if ($contextpage == 'takepos') print ''; - if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') - { - print ''; - } elseif ($action == 'close') - { - print ''; + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } elseif ($action == 'close') + { + print ''; print ''; - } else { - print ''; - } + } else { + print ''; + } - print '
    '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print '
    '; + print '
    '.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; $disabled = 0; $prefix = 'close'; - print ''; - print ''; - print ''; + print ''; + print ''; + $array = array(); + $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); + for ($i = 1; $i <= $numterminals; $i++) { + $array[$i] = $i; + } + $selectedposnumber = 0; $showempty = 1; + if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') + { + $selectedposnumber = 1; $showempty = 0; + } + print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); + //print ''; + print ''; // Year print '
    '.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
    '.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; + print '
    '.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; - $array = array(); - $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); - for ($i = 1; $i <= $numterminals; $i++) { - $array[$i] = $i; - } - $selectedposnumber = 0; $showempty = 1; - if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') - { - $selectedposnumber = 1; $showempty = 0; - } - print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); - //print ''; - print ''; $retstring = ''; @@ -576,36 +577,36 @@ if ($action == "create" || $action == "start" || $action == 'close') print ''; } - print ''; + print ''; } } if (empty($action) || $action == "view" || $action == "close") { - $result = $object->fetch($id); + $result = $object->fetch($id); - llxHeader('', $langs->trans("CashControl")); + llxHeader('', $langs->trans("CashControl")); - if ($result <= 0) { - print $langs->trans("ErrorRecordNotFound"); - } else { - $head = array(); - $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; - $head[0][1] = $langs->trans("CashControl"); - $head[0][2] = 'cashcontrol'; + if ($result <= 0) { + print $langs->trans("ErrorRecordNotFound"); + } else { + $head = array(); + $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; + $head[0][1] = $langs->trans("CashControl"); + $head[0][2] = 'cashcontrol'; - dol_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'account'); + print dol_get_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'account'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
    '; - $morehtmlref .= '
    '; + $morehtmlref = '
    '; + $morehtmlref .= '
    '; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); - print '
    '; - print '
    '; + print '
    '; + print '
    '; print '
    '; print ''; @@ -632,36 +633,36 @@ if (empty($action) || $action == "view" || $action == "close") print ''; print '
    '; - print '
    '; + print '
    '; - print '
    '; + print '
    '; print '
    '; - print ''; + print '
    '; - print ''; + print ''; - print '"; - foreach ($arrayofpaymentmode as $key => $val) - { - print '"; - } + print '"; + foreach ($arrayofpaymentmode as $key => $val) + { + print '"; + } print "
    '; - print $langs->trans("DateCreationShort"); - print ''; - print dol_print_date($object->date_creation, 'dayhour'); - print '
    '; + print $langs->trans("DateCreationShort"); + print ''; + print dol_print_date($object->date_creation, 'dayhour'); + print '
    '.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; - 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 "
    '.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; + 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 "
    \n"; - print '
    '; - print '
    '; - print '
    '; + print '
    '; + print '
    '; + print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); - if ($action != 'close') { + if ($action != 'close') { print '
    '; print ''; @@ -678,22 +679,22 @@ if (empty($action) || $action == "view" || $action == "close") print '
    '; if ($contextpage != 'takepos') print '
    '; - } else { - print '
    '; - print ''; + } else { + print ''; + print ''; if ($contextpage == 'takepos') print ''; - if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') - { - print ''; - } elseif ($action == 'close') - { - print ''; - print ''; - } else { - print ''; - } + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } elseif ($action == 'close') + { + print ''; + print ''; + } else { + print ''; + } - /* + /* print '
    '; print ''; print ''; @@ -744,127 +745,127 @@ if (empty($action) || $action == "view" || $action == "close") print ''; */ - // Table to see/enter balance - if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') - { - $posmodule = $object->posmodule; - $terminalid = $object->posnumber; + // Table to see/enter balance + if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') + { + $posmodule = $object->posmodule; + $terminalid = $object->posnumber; - print '
    '; + print '
    '; - print '
    '; - print '
    '; + print '
    '; + print '
    '; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - print ''; - print ''; + print ''; + print ''; + print ''; + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + print ''; + print ''; - print ''; - // Initial amount - print ''; - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; - print ''; - // Initial amount - print ''; - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; - print ''; - print ''; - // Initial amount - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; + print ''; + print ''; + // Initial amount + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; - print '
    '.$langs->trans("InitialBankBalance"); - //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); - print '
    '.$langs->trans("InitialBankBalance"); + //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); + print '
    '; - print $langs->trans("AmountAtEndOfPeriod"); - print '
    '; + print $langs->trans("AmountAtEndOfPeriod"); + print '
    '.$langs->trans("Cash"); - //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); - print '
    '.$langs->trans($val); - //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); - print '
    '.$langs->trans("Cash"); + //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); + print '
    '.$langs->trans($val); + //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); + print '
    '.$langs->trans("NbOfInvoices").''; - print ''; - print $theoricalnbofinvoiceforterminal[$terminalid][$key]; - print '
    '.$langs->trans("NbOfInvoices").''; + print ''; + print $theoricalnbofinvoiceforterminal[$terminalid][$key]; + print '
    '.$langs->trans("TheoricalAmount").''; - print price($initialbalanceforterminal[$terminalid]['cash']).'
    '; - print '
    '; - if ($key == 'cash') { - $deltaforcash = ($object->opening - $initialbalanceforterminal[$terminalid]['cash']); - print price($theoricalamountforterminal[$terminalid][$key] + $deltaforcash).'
    '; - } else { - print price($theoricalamountforterminal[$terminalid][$key]).'
    '; - } - print '
    '.$langs->trans("TheoricalAmount").''; + print price($initialbalanceforterminal[$terminalid]['cash']).'
    '; + print '
    '; + if ($key == 'cash') { + $deltaforcash = ($object->opening - $initialbalanceforterminal[$terminalid]['cash']); + print price($theoricalamountforterminal[$terminalid][$key] + $deltaforcash).'
    '; + } else { + print price($theoricalamountforterminal[$terminalid][$key]).'
    '; + } + print '
    '.$langs->trans("RealAmount").''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($action == 'start') print ''; - elseif ($action == 'close') print ''; - print '
    '.$langs->trans("RealAmount").''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($action == 'start') print ''; + elseif ($action == 'close') print ''; + print '
    '; - print '
    '; - } + print '
    '; + print '
    '; + } - print ''; - } - } + print ''; + } + } } // End of page diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 2adf3a01a83..fdc3e57bdba 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -343,7 +343,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort $topicmail = "SendCashControlRef"; $modelmail = "cashcontrol"; $objecttmp = new CashControl($db); -$trackid = 'xxxx'.$object->id; +$trackid = 'cashfence'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) @@ -390,7 +390,7 @@ foreach ($object->fields as $key => $val) if (!empty($arrayfields['t.'.$key]['checked'])) { print '
    '; - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); else print ''; print '
    '."\n"; + print '
    '; + print '
    '."\n"; - $param = ''; + $param = ''; // Fields title print ''; @@ -159,26 +162,24 @@ if ($resql) $sign = 1; $cash = $bank = $cheque = $other = 0; - $totalarray = array(); - $cachebankaccount = array(); - $amountpertype = array(); - while ($i < $num) - { - $objp = $db->fetch_object($resql); + $totalarray = array(); + $cachebankaccount = array(); + $amountpertype = array(); + while ($i < $num) { + $objp = $db->fetch_object($resql); - if (empty($cachebankaccount[$objp->bankid])) - { - $bankaccounttmp = new Account($db); - $bankaccounttmp->fetch($objp->bankid); - $cachebankaccount[$objp->bankid] = $bankaccounttmp; - $bankaccount = $bankaccounttmp; - } else { - $bankaccount = $cachebankaccount[$objp->bankid]; - } + if (empty($cachebankaccount[$objp->bankid])) { + $bankaccounttmp = new Account($db); + $bankaccounttmp->fetch($objp->bankid); + $cachebankaccount[$objp->bankid] = $bankaccounttmp; + $bankaccount = $bankaccounttmp; + } else { + $bankaccount = $cachebankaccount[$objp->bankid]; + } - $invoicetmp->fetch($objp->facid); + $invoicetmp->fetch($objp->facid); - /*if ($first == "yes") + /*if ($first == "yes") { print ''; print ''; @@ -190,19 +191,19 @@ if ($resql) print ''; // Ref - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; - // Date ope - print '\n"; - if (!$i) $totalarray['nbfield']++; + // Date ope + print '\n"; + if (!$i) $totalarray['nbfield']++; - // Bank account - print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; - // Type - print '\n"; - if (!$i) $totalarray['nbfield']++; + // Type + print '\n"; + if (!$i) $totalarray['nbfield']++; - // Debit - print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebfield'; + // Debit + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebfield'; - // Credit - print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredfield'; + $totalarray['val']['totalcredfield'] += $objp->amount; + $amountpertype[$objp->code] -= $objp->amount; + } + print "\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredfield'; print ""; @@ -305,7 +304,7 @@ if ($resql) print ""; - print ''; + print ''; $db->free($resql); } else { diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index dae7ca358ac..3588dced3f4 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -51,7 +51,7 @@ $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); $mode = GETPOST("mode", 'alpha'); $year = GETPOST("year", 'int'); $filtre = GETPOST("filtre", 'alpha'); -if (!$year && $mode != 'sconly') { $year = date("Y", time()); } +if (!$year) { $year = date("Y", time()); } $search_account = GETPOST('search_account', 'int'); @@ -80,12 +80,10 @@ $accountstatic = new Account($db); llxHeader('', $langs->trans("SpecialExpensesArea")); $title = $langs->trans("SpecialExpensesArea"); -if ($mode == 'sconly') $title = $langs->trans("SocialContributionsPayments"); $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; -if ($mode == 'sconly') $param = '&mode=sconly'; if ($sortfield) $param .= '&sortfield='.$sortfield; if ($sortorder) $param .= '&sortorder='.$sortorder; @@ -101,30 +99,18 @@ print ''; print ''; print ''; -$nav = ''; -if ($mode != 'sconly') -{ - $nav = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 1); -} else { - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 0); -} +$nav = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 1); if ($year) $param .= '&year='.$year; -if ($mode != 'sconly') -{ - print ''.$langs->trans("DescTaxAndDividendsArea").'
    '; - print "
    "; -} +print ''.$langs->trans("DescTaxAndDividendsArea").'
    '; +print "
    "; if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // Social contributions only - if ($mode != 'sconly') - { - print load_fiche_titre($langs->trans("SocialContributionsPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); - } + print load_fiche_titre($langs->trans("SocialContributionsPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); print '
    '.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").'
    '; - print $invoicetmp->getNomUrl(1); - print ''; + print $invoicetmp->getNomUrl(1); + print ''; - print ''.dol_print_date($db->jdate($objp->do), "day").""; - print "'; + print ''.dol_print_date($db->jdate($objp->do), "day").""; + print "'; + // Bank account + print ''; print $bankaccount->getNomUrl(1); if ($cashcontrol->posmodule == "takepos") { $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber; @@ -220,38 +221,36 @@ if ($resql) else $other += $objp->amount; } print "'; - print $objp->code; - if (empty($amountpertype[$objp->code])) $amountpertype[$objp->code] = 0; - print "'; + print $objp->code; + if (empty($amountpertype[$objp->code])) $amountpertype[$objp->code] = 0; + print "'; - if ($objp->amount < 0) - { - print price($objp->amount * -1); - $totalarray['val']['totaldebfield'] += $objp->amount; - $amountpertype[$objp->code] += $objp->amount; - } - print "'; + if ($objp->amount < 0) { + print price($objp->amount * -1); + $totalarray['val']['totaldebfield'] += $objp->amount; + $amountpertype[$objp->code] += $objp->amount; + } + print "'; - if ($objp->amount > 0) - { + // Credit + print ''; + if ($objp->amount > 0) { print price($objp->amount); - $totalarray['val']['totalcredfield'] += $objp->amount; - $amountpertype[$objp->code] -= $objp->amount; - } - print "
    '; print ''; @@ -135,7 +121,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; @@ -200,27 +186,27 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print '\n"; // Date payment print ''; - // Type payment - print ''; + // Type payment + print ''; // Account - if (!empty($conf->banque->enabled)) - { - print ''; - } + if (!empty($conf->banque->enabled)) + { + print ''; + } // Paid print ''; - print ''; // A total here has no sense - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) print ''; - print '"; + print ''; + print ''; // A total here has no sense + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) print ''; + print '"; print ""; } else { dol_print_error($db); @@ -249,113 +235,110 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) // VAT if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { - if (!$mode || $mode != 'sconly') + print "
    "; + + $tva = new Tva($db); + + print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); + + $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.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."tva as pv"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id"; + $sql .= " WHERE pv.entity IN (".getEntity("tax").")"; + if ($year > 0) { - print "
    "; + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + } + if (preg_match('/^pv\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); - $tva = new Tva($db); - - print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); - - $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.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."tva as pv"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id"; - $sql .= " WHERE pv.entity IN (".getEntity("tax").")"; - if ($year > 0) + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print '
    '.$payment_sc_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; - if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - print $obj->num_payment.''; + if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + print $obj->num_payment.''; - if ($obj->fk_bank > 0) - { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->number = $obj->bnumber; - $accountstatic->accountancy_number = $obj->account_number; - $accountstatic->accountancy_journal = $obj->accountancy_journal; - $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else print ' '; - print ''; + if ($obj->fk_bank > 0) + { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; + print $accountstatic->getNomUrl(1); + } else print ' '; + print ''; if ($obj->totalpaye) print price($obj->totalpaye); @@ -232,13 +218,13 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $totalpaye = $totalpaye + $obj->totalpaye; $i++; } - print '
    '.$langs->trans("Total").'   '.price($totalpaye)."
    '.$langs->trans("Total").'   '.price($totalpaye)."
    '; + print ''; + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "pv.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); + if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print "\n"; + $var = 1; + while ($i < $num) { - // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, - // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + + print ''; + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; + print '\n"; + + // Date + print '\n"; + + // Type payment + print ''; + + // Account + if (!empty($conf->banque->enabled)) + { + print ''; + } + + // Paid + print '"; + print "\n"; + + $i++; } - if (preg_match('/^pv\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '"; + print ""; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; - $total = 0; - print '
    '.dol_print_date($db->jdate($obj->dm), 'day').'".$obj->label."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm), 'day')."'; + if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + print $obj->num_payment.''; + if ($obj->fk_bank > 0) + { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; + print $accountstatic->getNomUrl(1); + } else print ' '; + print ''.price($obj->amount)."
    '.$langs->trans("Total").''.price($total).'    '.price($total)."
    '; - print ''; - print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "pv.label", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); - print "\n"; - $var = 1; - while ($i < $num) - { - $obj = $db->fetch_object($result); - - $total = $total + $obj->amount; - - - print ''; - print ''."\n"; - - print "\n"; - - print '"; - - // Ref payment - $tva_static->id = $obj->rowid; - $tva_static->ref = $obj->rowid; - print '\n"; - - // Date - print '\n"; - - // Type payment - print ''; - - // Account - if (!empty($conf->banque->enabled)) - { - print ''; - } - - // Paid - print '"; - print "\n"; - - $i++; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '"; - print ""; - - print "
    '.dol_print_date($db->jdate($obj->dm), 'day').'".$obj->label."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm), 'day')."'; - if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - print $obj->num_payment.''; - if ($obj->fk_bank > 0) - { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->number = $obj->bnumber; - $accountstatic->accountancy_number = $obj->account_number; - $accountstatic->accountancy_journal = $obj->accountancy_journal; - $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else print ' '; - print ''.price($obj->amount)."
    '.$langs->trans("Total").''.price($total).'    '.price($total)."
    "; - $db->free($result); - } else { - dol_print_error($db); - } + print "
    "; + $db->free($result); + } else { + dol_print_error($db); } } @@ -379,73 +362,77 @@ if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") while ($j < $numlt) { - if (!$mode || $mode != 'sconly') + print "
    "; + + $tva = new Tva($db); + + print load_fiche_titre($langs->transcountry(($j == 1 ? "LT1Payments" : "LT2Payments"), $mysoc->country_code).($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); + + + $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp"; + $sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j; + if ($year > 0) { - print "
    "; + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + } + if (preg_match('/^pv/', $sortfield)) $sql .= $db->order($sortfield, $sortorder); - $tva = new Tva($db); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print ''; + print ''; + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "pv.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datep", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print "\n"; - print load_fiche_titre($langs->transcountry(($j == 1 ? "LT1Payments" : "LT2Payments"), $mysoc->country_code).($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); - - - $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp"; - $sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv"; - $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j; - if ($year > 0) + while ($i < $num) { - // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, - // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; - } - if (preg_match('/^pv/', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + $obj = $db->fetch_object($result); - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; - $total = 0; - print '
    '; - print ''; - print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "pv.label", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datep", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + $total = $total + $obj->amount; + + print ''; + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; + print '\n"; + + print '\n"; + print '"; print "\n"; - while ($i < $num) - { - $obj = $db->fetch_object($result); - - $total = $total + $obj->amount; - - print ''; - print ''."\n"; - - print "\n"; - - // Ref payment - $tva_static->id = $obj->rowid; - $tva_static->ref = $obj->rowid; - print '\n"; - - print '\n"; - print '"; - print "\n"; - - $i++; - } - print ''; - print '"; - print ""; - - print "
    '.dol_print_date($db->jdate($obj->dm), 'day').'".$obj->label."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dp), 'day')."'.price($obj->amount)."
    '.dol_print_date($db->jdate($obj->dm), 'day').'".$obj->label."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dp), 'day')."'.price($obj->amount)."
    '.$langs->trans("Total").''.price($total)."
    "; - $db->free($result); - } else { - dol_print_error($db); + $i++; } + print ''.$langs->trans("Total").''; + print ''.price($total).""; + print ' '; + print ' '; + print ''.price($total).""; + print ""; + + print ""; + $db->free($result); + } else { + dol_print_error($db); } + $j++; } @@ -454,8 +441,6 @@ while ($j < $numlt) /* if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) { - if (!$mode || $mode != 'sconly') - { $sal = new PaymentSalary($db); print "
    "; @@ -557,7 +542,6 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) } else { dol_print_error($db); } - } } */ diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index fcd7c542eb2..00b5c3dc025 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -291,7 +291,7 @@ if ($action == 'create') { $head = trip_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip'); + print dol_get_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip'); if ($action == 'edit' && $user->rights->deplacement->creer) { diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 69baf710b95..1a1fd42d21b 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -59,22 +59,22 @@ class Deplacement extends CommonObject public $ismultientitymanaged = 0; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * Date (dated) - * - * @var integer - */ + /** + * Date (dated) + * + * @var integer + */ public $dated; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** @@ -82,20 +82,20 @@ class Deplacement extends CommonObject */ public $fk_user; - /** - * @var string km value formatted - */ - public $km; + /** + * @var string km value formatted + */ + public $km; - /** - * @var int Thirdparty id - */ + /** + * @var int Thirdparty id + */ public $socid; - /** - * @var int Status 0=draft, 1=validated, 2=Refunded - */ - public $statut; + /** + * @var int Status 0=draft, 1=validated, 2=Refunded + */ + public $statut; public $extraparams = array(); public $statuts = array(); @@ -116,7 +116,7 @@ class Deplacement extends CommonObject */ const STATUS_REFUNDED = 2; - /** + /** * Constructor * * @param DoliDB $db Database handler @@ -125,8 +125,8 @@ class Deplacement extends CommonObject { $this->db = $db; - $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); - $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); + $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); + $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); } /** @@ -152,9 +152,9 @@ class Deplacement extends CommonObject return -1; } - $now = dol_now(); + $now = dol_now(); - $this->db->begin(); + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement ("; $sql .= "datec"; @@ -185,14 +185,14 @@ class Deplacement extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."deplacement"); - // Call trigger - $result = $this->call_trigger('DEPLACEMENT_CREATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('DEPLACEMENT_CREATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers $result = $this->update($user); if ($result > 0) @@ -226,12 +226,12 @@ class Deplacement extends CommonObject // Check parameters if (!is_numeric($this->km)) $this->km = 0; - if (empty($this->date)) - { - $this->error = 'ErrorBadParameter'; - return -1; - } - if (empty($this->type) || $this->type < 0) + if (empty($this->date)) + { + $this->error = 'ErrorBadParameter'; + return -1; + } + if (empty($this->type) || $this->type < 0) { $this->error = 'ErrorBadParameter'; return -1; @@ -270,7 +270,7 @@ class Deplacement extends CommonObject } } - /** + /** * Load an object from database * * @param int $id Id of record to load @@ -312,7 +312,7 @@ class Deplacement extends CommonObject } } - /** + /** * Delete record * * @param int $id Id of record to delete @@ -349,7 +349,7 @@ class Deplacement extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -359,7 +359,7 @@ class Deplacement extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; if ($mode == 0) @@ -402,15 +402,15 @@ class Deplacement extends CommonObject global $langs; $result = ''; - $label = $langs->trans("Show").': '.$this->ref; + $label = $langs->trans("Show").': '.$this->ref; - $link = ''; + $link = ''; $linkend = ''; $picto = 'trip'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $link.$this->ref.$linkend; return $result; @@ -425,31 +425,31 @@ class Deplacement extends CommonObject */ public function listOfTypes($active = 1) { - global $langs; + global $langs; - $ret = array(); + $ret = array(); - $sql = "SELECT id, code, label"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees"; - $sql .= " WHERE active = ".$active; + $sql = "SELECT id, code, label"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees"; + $sql .= " WHERE active = ".$active; - dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label); - $i++; - } - } else { - dol_print_error($this->db); - } + dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label); + $i++; + } + } else { + dol_print_error($this->db); + } - return $ret; + return $ret; } /** diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index 953ee78a3d6..d6ad82a4cbe 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -30,24 +30,24 @@ include_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php' */ class DeplacementStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - public $socid; - public $userid; + public $socid; + public $userid; - public $from; - public $field; - public $where; + public $from; + public $field; + public $where; /** * Constructor * * @param DoliDB $db Database handler * @param int $socid Id third party - * @param mixed $userid Id user for filter or array of user ids + * @param mixed $userid Id user for filter or array of user ids * @return void */ public function __construct($db, $socid = 0, $userid = 0) @@ -55,8 +55,8 @@ class DeplacementStats extends Stats global $conf; $this->db = $db; - $this->socid = $socid; - $this->userid = $userid; + $this->socid = $socid; + $this->userid = $userid; $object = new Deplacement($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element; @@ -69,7 +69,7 @@ class DeplacementStats extends Stats $this->where .= " AND fk_soc = ".$this->socid; } if (is_array($this->userid) && count($this->userid) > 0) $this->where .= ' AND fk_user IN ('.join(',', $this->userid).')'; - elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid; + elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid; } @@ -93,7 +93,7 @@ class DeplacementStats extends Stats * Renvoie le nombre de facture par mois pour une annee donnee * * @param string $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array of values */ public function getNbByMonth($year, $format = 0) @@ -103,7 +103,7 @@ class DeplacementStats extends Stats $sql .= " WHERE YEAR(dated) = ".$year; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
    '; @@ -115,7 +115,7 @@ class DeplacementStats extends Stats * Renvoie le montant de facture par mois pour une annee donnee * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array of values */ public function getAmountByMonth($year, $format = 0) @@ -145,7 +145,7 @@ class DeplacementStats extends Stats $sql .= " WHERE date_format(dated,'%Y') = '".$this->db->escape($year)."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -155,14 +155,14 @@ class DeplacementStats extends Stats * * @return array Array of values */ - public function getAllByYear() - { - $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql .= " FROM ".$this->from; - $sql .= " WHERE ".$this->where; - $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + public function getAllByYear() + { + $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql .= " FROM ".$this->from; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 47b1709ff60..86d0dd383f1 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -89,7 +89,7 @@ if ($object->id) $head = trip_prepare_head($object); - dol_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip'); + print dol_get_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip'); // Build file list @@ -101,9 +101,9 @@ if ($object->id) } - print ''; + print '
    '; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print '"; - print ''; - print ''; - print '
    '.$langs->trans("Ref").''; @@ -113,16 +113,16 @@ if ($object->id) // Societe //print "
    ".$langs->trans("Company")."".$object->client->getNomUrl(1)."
    '.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
    '.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
    '; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; + print ''; - print '
    '; + print ''; - $modulepart = 'deplacement'; - $permission = $user->rights->deplacement->creer; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $modulepart = 'deplacement'; + $permission = $user->rights->deplacement->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index 0cea847f9ce..bcebeb128d0 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -74,20 +74,20 @@ $sql .= " ORDER BY d.type"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); - $somme[$objp->type] = $objp->km; - $nb[$objp->type] = $objp->nb; - $totalnb += $objp->nb; - $i++; - } - $db->free($result); + $somme[$objp->type] = $objp->km; + $nb[$objp->type] = $objp->nb; + $totalnb += $objp->nb; + $i++; + } + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } @@ -106,24 +106,24 @@ print "\n"; $listoftype = $tripandexpense_static->listOfTypes(); foreach ($listoftype as $code => $label) { - $dataseries[] = array($label, (isset($nb[$code]) ? (int) $nb[$code] : 0)); + $dataseries[] = array($label, (isset($nb[$code]) ? (int) $nb[$code] : 0)); } if ($conf->use_javascript_ajax) { - print ''; + print ''; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($totalnb ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($totalnb ? 0 : 1); - print ''; + print ''; } print ''; @@ -156,46 +156,46 @@ $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { - $var = false; - $num = $db->num_rows($result); + $var = false; + $num = $db->num_rows($result); - $i = 0; + $i = 0; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($num) - { - $total_ttc = $totalam = $total = 0; + print '
    '.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).''.$langs->trans("FeesKilometersOrAmout").''.$langs->trans("DateModificationShort").' 
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($num) + { + $total_ttc = $totalam = $total = 0; - $deplacementstatic = new Deplacement($db); - $userstatic = new User($db); - while ($i < $num && $i < $max) - { - $obj = $db->fetch_object($result); - $deplacementstatic->ref = $obj->rowid; - $deplacementstatic->id = $obj->rowid; - $userstatic->id = $obj->uid; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $deplacementstatic = new Deplacement($db); + $userstatic = new User($db); + while ($i < $num && $i < $max) + { + $obj = $db->fetch_object($result); + $deplacementstatic->ref = $obj->rowid; + $deplacementstatic->id = $obj->rowid; + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $i++; - } - } else { - print ''; - } - print '
    '.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).''.$langs->trans("FeesKilometersOrAmout").''.$langs->trans("DateModificationShort").' 
    '.$deplacementstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$obj->km.''.dol_print_date($db->jdate($obj->dm), 'day').''.$deplacementstatic->LibStatut($obj->fk_statut, 3).'
    '.$deplacementstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$obj->km.''.dol_print_date($db->jdate($obj->dm), 'day').''.$deplacementstatic->LibStatut($obj->fk_statut, 3).'
    '.$langs->trans("None").'

    '; + $i++; + } + } else { + print ''.$langs->trans("None").''; + } + print '
    '; } else dol_print_error($db); diff --git a/htdocs/compta/deplacement/info.php b/htdocs/compta/deplacement/info.php index a63494451cf..586eac52ee7 100644 --- a/htdocs/compta/deplacement/info.php +++ b/htdocs/compta/deplacement/info.php @@ -50,13 +50,13 @@ if ($id) $head = trip_prepare_head($object); - dol_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip'); + print dol_get_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip'); - print '
    '; - dol_print_object_info($object); - print '
    '; + print '
    '; + dol_print_object_info($object); + print '
    '; - print ''; + print ''; } // End of page diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 78c1f32556d..df18b09e2b4 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -99,11 +99,11 @@ if ($socid) $sql .= " AND s.rowid = ".$socid; if ($search_ref) $sql .= " AND d.rowid=".$search_ref; if ($search_name) { - $sql .= natural_search('u.lastname', $search_name); + $sql .= natural_search('u.lastname', $search_name); } if ($search_company) { - $sql .= natural_search('s.nom', $search_company); + $sql .= natural_search('s.nom', $search_company); } $sql .= dolSqlDateFilter("d.dated", $day, $month, $year); @@ -114,90 +114,90 @@ $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - print_barre_liste($langs->trans("ListOfFees"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("ListOfFees"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num); - $i = 0; - print '
    '."\n"; - print ''; - print ""; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "d.type", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.dated", "", "&socid=$socid", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Person", $_SERVER["PHP_SELF"], "u.lastname", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("FeesKilometersOrAmout", $_SERVER["PHP_SELF"], "d.km", "", "&socid=$socid", 'class="right"', $sortfield, $sortorder); - print_liste_field_titre(''); - print "\n"; + $i = 0; + print ''."\n"; + print '
    '; + print ""; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "d.type", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.dated", "", "&socid=$socid", 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Person", $_SERVER["PHP_SELF"], "u.lastname", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("FeesKilometersOrAmout", $_SERVER["PHP_SELF"], "d.km", "", "&socid=$socid", 'class="right"', $sortfield, $sortorder); + print_liste_field_titre(''); + print "\n"; - // Filters lines - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + // Filters lines + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($resql); + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); - $soc = new Societe($db); - if ($obj->socid) $soc->fetch($obj->socid); + $soc = new Societe($db); + if ($obj->socid) $soc->fetch($obj->socid); - print ''; - // Id - print ''; - // Type - print ''; - // Date - print ''; - // User - print ''; + print ''; + // Id + print ''; + // Type + print ''; + // Date + print ''; + // User + print ''; - if ($obj->socid) print ''; - else print ''; + if ($obj->socid) print ''; + else print ''; - print ''; + print ''; - $tripandexpense_static->statut = $obj->fk_statut; - print ''; - print "\n"; + $tripandexpense_static->statut = $obj->fk_statut; + print ''; + print "\n"; - $i++; - } + $i++; + } - print "
    '; - print ''; - print ''; - print ' '; - print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); - print ''; - print ''; - print ''; - print ''; - print ''; - // print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
    '; + print ''; + print ''; + print ' '; + print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); + print ''; + print ''; + print ''; + print ''; + print ''; + // print ''; + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
    '.img_object($langs->trans("ShowTrip"), "trip").' '.$obj->rowid.''.$langs->trans($obj->type).''.dol_print_date($db->jdate($obj->dd), 'day').''; - $userstatic->id = $obj->fk_user; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - print $userstatic->getNomUrl(1); - print '
    '.img_object($langs->trans("ShowTrip"), "trip").' '.$obj->rowid.''.$langs->trans($obj->type).''.dol_print_date($db->jdate($obj->dd), 'day').''; + $userstatic->id = $obj->fk_user; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + print $userstatic->getNomUrl(1); + print ''.$soc->getNomUrl(1).' '.$soc->getNomUrl(1).' '.$obj->km.''.$obj->km.''.$tripandexpense_static->getLibStatut(5).'
    '.$tripandexpense_static->getLibStatut(5).'
    "; - print "
    \n"; - $db->free($resql); + print ""; + print "\n"; + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } // End of page diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 7707cb40786..389c8d9408f 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -164,38 +164,38 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; } else { - $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { - $px3->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode = 'depth'; - $px3->SetTitle($langs->trans("AmountAverage")); + $px3->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode = 'depth'; + $px3->SetTitle($langs->trans("AmountAverage")); - $px3->draw($filename_avg, $fileurl_avg); + $px3->draw($filename_avg, $fileurl_avg); } @@ -203,7 +203,7 @@ if (!$mesg) $data = $stats->getAllByYear(); $arrayyears = array(); foreach ($data as $val) { - $arrayyears[$val['year']] = $val['year']; + $arrayyears[$val['year']] = $val['year']; } if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -217,7 +217,7 @@ $h++; complete_head_from_modules($conf, $langs, null, $head, $h, 'trip_stats'); -dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); +print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); print '
    '; @@ -293,11 +293,11 @@ print '
    '; // Show graphs print '
    '; if ($mesg) { print $mesg; } else { - print $px1->show(); + print $px1->show(); print "
    \n"; print $px2->show(); - print "
    \n"; - print $px3->show(); + print "
    \n"; + print $px3->show(); } print '
    '; @@ -306,7 +306,7 @@ print '
    '; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index df5cb39f9e4..0e971954d56 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -69,19 +69,19 @@ print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Invoices"), -1, 'invoice'); +print dol_get_fiche_head($head, 'attributes', $langs->trans("Invoices"), -1, 'invoice'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
    '; - print "".$langs->trans("NewAttribute").""; - print "
    "; + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; } @@ -94,9 +94,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
    '; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -109,9 +109,9 @@ if ($action == 'edit' && !empty($attrname)) $langs->load("members"); print "
    "; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index a8d073958ad..dbc395e5d65 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -70,19 +70,19 @@ print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'attributesrec', $langs->trans("Invoices"), -1, 'invoice'); +print dol_get_fiche_head($head, 'attributesrec', $langs->trans("Invoices"), -1, 'invoice'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
    '; - print "".$langs->trans("NewAttribute").""; - print "
    "; + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
    '; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -110,9 +110,9 @@ if ($action == 'edit' && !empty($attrname)) $langs->load("members"); print "
    "; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index ebe2a437a92..c07eb3ac2aa 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -70,19 +70,19 @@ print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), -1, 'invoice'); +print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), -1, 'invoice'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
    '; - print "".$langs->trans("NewAttribute").""; - print "
    "; + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
    '; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -107,10 +107,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
    "; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index a09b0380f59..772a3aa680c 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -70,19 +70,19 @@ print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); $head = invoice_admin_prepare_head(); -dol_fiche_head($head, 'attributeslinesrec', $langs->trans("Invoices"), -1, 'invoice'); +print dol_get_fiche_head($head, 'attributeslinesrec', $langs->trans("Invoices"), -1, 'invoice'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
    '; - print "".$langs->trans("NewAttribute").""; - print "
    "; + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
    '; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -107,10 +107,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
    "; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 3ab212a62bd..0197c7e4f70 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -191,15 +191,15 @@ if (empty($reshook)) $object->titre = GETPOST('title', 'nohtml'); // deprecated $object->title = GETPOST('title', 'nohtml'); $object->note_private = GETPOST('note_private', 'restricthtml'); - $object->note_public = GETPOST('note_public', 'restricthtml'); - $object->model_pdf = GETPOST('modelpdf', 'alpha'); + $object->note_public = GETPOST('note_public', 'restricthtml'); + $object->model_pdf = GETPOST('modelpdf', 'alpha'); $object->usenewprice = GETPOST('usenewprice', 'alpha'); $object->frequency = $frequency; $object->unit_frequency = GETPOST('unit_frequency', 'alpha'); $object->nb_gen_max = $nb_gen_max; $object->auto_validate = GETPOST('auto_validate', 'int'); - $object->generate_pdf = GETPOST('generate_pdf', 'int'); + $object->generate_pdf = GETPOST('generate_pdf', 'int'); $object->fk_project = $projectid; $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); @@ -315,7 +315,7 @@ if (empty($reshook)) elseif ($action == 'setauto_validate' && $user->rights->facture->creer) { $object->setAutoValidate(GETPOST('auto_validate', 'int')); - } // Set generate pdf + } // Set generate pdf elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) { $object->setGeneratepdf(GETPOST('generate_pdf', 'int')); @@ -945,7 +945,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_head(null, '', '', 0); + print dol_get_fiche_head(null, '', '', 0); $rowspan = 4; if (!empty($conf->projet->enabled)) $rowspan++; @@ -957,7 +957,7 @@ if ($action == 'create') // Title print ''.$langs->trans("Title").''; - print ''; + print ''; print ''; // Third party @@ -1047,23 +1047,23 @@ if ($action == 'create') print ""; } - // Model pdf - print "".$langs->trans('Model').""; - include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $list = ModelePDFFactures::liste_modeles($db); - print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); - print ""; + // Model pdf + print "".$langs->trans('Model').""; + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; + $list = ModelePDFFactures::liste_modeles($db); + print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); + print ""; print ""; - dol_fiche_end(); + print dol_get_fiche_end(); // Autogeneration $title = $langs->trans("Recurrence"); print load_fiche_titre(' '.$title, '', ''); - dol_fiche_head(null, '', '', 0); + print dol_get_fiche_head(null, '', '', 0); print ''; @@ -1102,7 +1102,7 @@ if ($action == 'create') print "
    "; - dol_fiche_end(); + print dol_get_fiche_end(); $title = $langs->trans("ProductsAndServices"); @@ -1176,7 +1176,7 @@ if ($action == 'create') $head = invoice_rec_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div + print dol_get_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div // Recurring invoice content @@ -1327,7 +1327,7 @@ if ($action == 'create') print ''; if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''; - } + } print ''; print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { @@ -1409,30 +1409,30 @@ if ($action == 'create') print ""; print ''; - // Model pdf - print ''; - print ''; - print '
    '; - print $langs->trans('Model'); - print ''; - if (($action != 'editmodelpdf') && $user->rights->facture->creer && $object->statut == FactureRec::STATUS_DRAFT) - print 'id.'">'.img_edit($langs->trans('SetModel'), 1).'
    '; - print ''; - if ($action == 'editmodelpdf') - { - include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $list = array(); - $models = ModelePDFFactures::liste_modeles($db); - foreach ($models as $k => $model) { - $list[] = str_replace(':', '|', $k).':'.$model; - } - $select = 'select;'.implode(',', $list); - print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->rights->facture->creer, $select); - } else { - print $object->model_pdf; - } - print ""; - print ''; + // Model pdf + print ''; + print ''; + print '
    '; + print $langs->trans('Model'); + print ''; + if (($action != 'editmodelpdf') && $user->rights->facture->creer && $object->statut == FactureRec::STATUS_DRAFT) + print 'id.'">'.img_edit($langs->trans('SetModel'), 1).'
    '; + print ''; + if ($action == 'editmodelpdf') + { + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; + $list = array(); + $models = ModelePDFFactures::liste_modeles($db); + foreach ($models as $k => $model) { + $list[] = str_replace(':', '|', $k).':'.$model; + } + $select = 'select;'.implode(',', $list); + print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->rights->facture->creer, $select); + } else { + print $object->model_pdf; + } + print ""; + print ''; // Other attributes $cols = 2; @@ -1641,7 +1641,7 @@ if ($action == 'create') print "\n"; - dol_fiche_end(); + print dol_get_fiche_end(); /** diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8a2b5b150e4..ec89b662de0 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -175,19 +175,19 @@ if (empty($reshook)) // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. - $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); - $objectutil->socid = $socid; - $result = $objectutil->createFromClone($user, $id); - if ($result > 0) { - header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); - exit(); - } else { - $langs->load("errors"); - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } + $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); + $objectutil->socid = $socid; + $result = $objectutil->createFromClone($user, $id); + if ($result > 0) { + header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); + exit(); + } else { + $langs->load("errors"); + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } } // Change status of invoice elseif ($action == 'reopen' && $usercancreate) { $result = $object->fetch($id); @@ -333,14 +333,9 @@ if (empty($reshook)) } } } - } elseif ($action == 'set_thirdparty' && $usercancreate) - { - $object->fetch($id); - $object->setValueFrom('fk_soc', $socid, '', null, 'int', '', $user, 'BILL_MODIFY'); + } - header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); - exit(); - } elseif ($action == 'classin' && $usercancreate) + elseif ($action == 'classin' && $usercancreate) { $object->fetch($id); $object->setProject($_POST['projectid']); @@ -352,29 +347,29 @@ if (empty($reshook)) dol_print_error($db, $object->error); } elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) { - $object->fetch($id); - $object->retained_warranty_fk_cond_reglement = 0; // To clean property - $result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int')); - if ($result < 0) dol_print_error($db, $object->error); + $object->fetch($id); + $object->retained_warranty_fk_cond_reglement = 0; // To clean property + $result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int')); + if ($result < 0) dol_print_error($db, $object->error); - $old_rw_date_lim_reglement = $object->retained_warranty_date_limit; - $new_rw_date_lim_reglement = $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); - if ($new_rw_date_lim_reglement > $old_rw_date_lim_reglement) $object->retained_warranty_date_limit = $new_rw_date_lim_reglement; - if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date; - $result = $object->update($user); - if ($result < 0) dol_print_error($db, $object->error); + $old_rw_date_lim_reglement = $object->retained_warranty_date_limit; + $new_rw_date_lim_reglement = $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + if ($new_rw_date_lim_reglement > $old_rw_date_lim_reglement) $object->retained_warranty_date_limit = $new_rw_date_lim_reglement; + if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date; + $result = $object->update($user); + if ($result < 0) dol_print_error($db, $object->error); } elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) { - $object->fetch($id); - $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); - if ($result < 0) - dol_print_error($db, $object->error); + $object->fetch($id); + $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); + if ($result < 0) + dol_print_error($db, $object->error); } elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) { - $object->fetch($id); - $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); - if ($result < 0) - dol_print_error($db, $object->error); + $object->fetch($id); + $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); + if ($result < 0) + dol_print_error($db, $object->error); } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); @@ -414,16 +409,35 @@ if (empty($reshook)) $object->fetch($id); $object->cond_reglement_code = 0; // To clean property $object->cond_reglement_id = 0; // To clean property - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) dol_print_error($db, $object->error); - $old_date_lim_reglement = $object->date_lim_reglement; - $new_date_lim_reglement = $object->calculate_date_lim_reglement(); - if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; - if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; - $result = $object->update($user); - if ($result < 0) { - dol_print_error($db, $object->error); + $error = 0; + + $db->begin(); + + if (!$error) { + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if (!$error) { + $old_date_lim_reglement = $object->date_lim_reglement; + $new_date_lim_reglement = $object->calculate_date_lim_reglement(); + if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; + if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; + $result = $object->update($user); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if ($error) { + $db->rollback(); + } else { + $db->commit(); } } elseif ($action == 'setpaymentterm' && $usercancreate) { @@ -645,6 +659,7 @@ if (empty($reshook)) $outputlangs->load('products'); } $model = $object->model_pdf; + $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -856,16 +871,16 @@ if (empty($reshook)) // Total credit note and deposit $total_creditnote_and_deposit = 0; - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; - $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; - $sql .= " WHERE fk_facture = ".$object->id; - $resql = $db->query($sql); - if (!empty($resql)) { - while ($obj = $db->fetch_object($resql)) { - $total_creditnote_and_deposit += $obj->amount_ttc; - } - } else dol_print_error($db); + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_facture_source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_facture = ".$object->id; + $resql = $db->query($sql); + if (!empty($resql)) { + while ($obj = $db->fetch_object($resql)) { + $total_creditnote_and_deposit += $obj->amount_ttc; + } + } else dol_print_error($db); $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; @@ -952,6 +967,7 @@ if (empty($reshook)) elseif ($action == 'add' && $usercancreate) { if ($socid > 0) $object->socid = GETPOST('socid', 'int'); + $selectedLines = GETPOST('toselect', 'array'); $db->begin(); @@ -1066,12 +1082,12 @@ if (empty($reshook)) $facture_source = new Facture($db); // fetch origin object if ($facture_source->fetch($object->fk_facture_source) > 0) { - if ($facture_source->type == Facture::TYPE_SITUATION) - { - $object->situation_counter = $facture_source->situation_counter; - $object->situation_cycle_ref = $facture_source->situation_cycle_ref; - $facture_source->fetchPreviousNextSituationInvoice(); - } + if ($facture_source->type == Facture::TYPE_SITUATION) + { + $object->situation_counter = $facture_source->situation_counter; + $object->situation_cycle_ref = $facture_source->situation_cycle_ref; + $facture_source->fetchPreviousNextSituationInvoice(); + } } $id = $object->create($user); @@ -1102,84 +1118,84 @@ if (empty($reshook)) if ($facture_source->type == Facture::TYPE_SITUATION) { - $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id - $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from + $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id + $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from - if (!empty($facture_source->tab_previous_situation_invoice)) - { - // search the last standard invoice in cycle and the possible credit note between this last and facture_source - // TODO Move this out of loop of $facture_source->lines - $tab_jumped_credit_notes = array(); - $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; - $searchPreviousInvoice = true; - while ($searchPreviousInvoice) - { - if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) - { - $searchPreviousInvoice = false; // find, exit; - break; - } else { - if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { - $tab_jumped_credit_notes[$lineIndex] = $facture_source->tab_previous_situation_invoice[$lineIndex]->id; - } - $lineIndex--; // go to previous invoice in cycle - } - } + if (!empty($facture_source->tab_previous_situation_invoice)) + { + // search the last standard invoice in cycle and the possible credit note between this last and facture_source + // TODO Move this out of loop of $facture_source->lines + $tab_jumped_credit_notes = array(); + $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while ($searchPreviousInvoice) + { + if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + { + $searchPreviousInvoice = false; // find, exit; + break; + } else { + if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { + $tab_jumped_credit_notes[$lineIndex] = $facture_source->tab_previous_situation_invoice[$lineIndex]->id; + } + $lineIndex--; // go to previous invoice in cycle + } + } - $maxPrevSituationPercent = 0; - foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) - { - if ($prevLine->id == $source_fk_prev_id) - { - $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); + $maxPrevSituationPercent = 0; + foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + { + if ($prevLine->id == $source_fk_prev_id) + { + $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); - //$line->subprice = $line->subprice - $prevLine->subprice; - $line->total_ht = $line->total_ht - $prevLine->total_ht; - $line->total_tva = $line->total_tva - $prevLine->total_tva; - $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; - $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; - $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; + //$line->subprice = $line->subprice - $prevLine->subprice; + $line->total_ht = $line->total_ht - $prevLine->total_ht; + $line->total_tva = $line->total_tva - $prevLine->total_tva; + $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; + $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; + $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; - $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; - } - } + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; + } + } - // prorata - $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; + // prorata + $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; - //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
    '; + //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
    '; - // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) - $maxPrevSituationPercent = 0; - foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { - foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) - { - if ($prevLine->fk_prev_id == $source_fk_prev_id) - { - $maxPrevSituationPercent = $prevLine->situation_percent; + // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) + $maxPrevSituationPercent = 0; + foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { + foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) + { + if ($prevLine->fk_prev_id == $source_fk_prev_id) + { + $maxPrevSituationPercent = $prevLine->situation_percent; - $line->total_ht -= $prevLine->total_ht; - $line->total_tva -= $prevLine->total_tva; - $line->total_ttc -= $prevLine->total_ttc; - $line->total_localtax1 -= $prevLine->total_localtax1; - $line->total_localtax2 -= $prevLine->total_localtax2; + $line->total_ht -= $prevLine->total_ht; + $line->total_tva -= $prevLine->total_tva; + $line->total_ttc -= $prevLine->total_ttc; + $line->total_localtax1 -= $prevLine->total_localtax1; + $line->total_localtax2 -= $prevLine->total_localtax2; - $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; - } - } - } + $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; + } + } + } - // prorata - $line->situation_percent += $maxPrevSituationPercent; + // prorata + $line->situation_percent += $maxPrevSituationPercent; - //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
    '; - } + //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
    '; + } } $line->fk_facture = $object->id; @@ -1262,7 +1278,7 @@ if (empty($reshook)) $object->note_public = trim(GETPOST('note_public', 'restricthtml')); $object->note_private = trim(GETPOST('note_private', 'restricthtml')); $object->ref_client = GETPOST('ref_client'); - $object->model_pdf = GETPOST('model'); + $object->model_pdf = GETPOST('model'); $object->fk_project = GETPOST('projectid', 'int'); $object->cond_reglement_id = (GETPOST('type') == 3 ? 1 : GETPOST('cond_reglement_id')); $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); @@ -1341,11 +1357,11 @@ if (empty($reshook)) $object->retained_warranty_fk_cond_reglement = 0; } - $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); - if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { - $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); - } - $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); + if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { + $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); + } + $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); $object->fetch_thirdparty(); @@ -1552,8 +1568,11 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); + for ($i = 0; $i < $num; $i++) { + if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + // Don't add lines with qty 0 when coming from a shipment including all order lines if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; // Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines) @@ -1624,7 +1643,7 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); - $result = $object->addline( + $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, @@ -1714,7 +1733,7 @@ if (empty($reshook)) if (empty($datefacture)) { $error++; $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")); - setEventMessages($mesg, null, 'errors'); + setEventMessages($mesg, null, 'errors'); } $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); @@ -1722,8 +1741,8 @@ if (empty($reshook)) if (!($_POST['situations'] > 0)) { $error++; $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceSituation")); - setEventMessages($mesg, null, 'errors'); - $action = 'create'; + setEventMessages($mesg, null, 'errors'); + $action = 'create'; } if (!$error) { @@ -1741,23 +1760,23 @@ if (empty($reshook)) // retained warranty if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { - $retained_warranty = GETPOST('retained_warranty', 'int'); - if (price2num($retained_warranty) > 0) - { - $object->retained_warranty = price2num($retained_warranty); - } + $retained_warranty = GETPOST('retained_warranty', 'int'); + if (price2num($retained_warranty) > 0) + { + $object->retained_warranty = price2num($retained_warranty); + } - if (GETPOST('retained_warranty_fk_cond_reglement', 'int') > 0) - { - $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - } + if (GETPOST('retained_warranty_fk_cond_reglement', 'int') > 0) + { + $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + } - $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); - if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { - $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); - } - $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); - } + $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); + if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { + $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); + } + $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + } foreach ($object->lines as $i => &$line) { @@ -1781,16 +1800,16 @@ if (empty($reshook)) // Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée if ($line->fk_remise_except) { - $discount = new DiscountAbsolute($line->db); - $result = $discount->fetch($line->fk_remise_except); - if ($result > 0) - { - // Check if discount not already affected to another invoice - if ($discount->fk_facture_line > 0) - { - $line->fk_remise_except = 0; - } - } + $discount = new DiscountAbsolute($line->db); + $result = $discount->fetch($line->fk_remise_except); + if ($result > 0) + { + // Check if discount not already affected to another invoice + if ($discount->fk_facture_line > 0) + { + $line->fk_remise_except = 0; + } + } } } } @@ -2240,20 +2259,20 @@ if (empty($reshook)) if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref > 0) { - // in case of situation credit note - if (GETPOST('progress') >= 0) - { - $mesg = $langs->trans("CantBeNullOrPositive"); - setEventMessages($mesg, null, 'warnings'); - $error++; - $result = -1; - } elseif (GETPOST('progress') < $line->situation_percent) // TODO : use a modified $line->get_prev_progress($object->id) result - { - $mesg = $langs->trans("CantBeLessThanMinPercent"); - setEventMessages($mesg, null, 'warnings'); - $error++; - $result = -1; - } + // in case of situation credit note + if (GETPOST('progress') >= 0) + { + $mesg = $langs->trans("CantBeNullOrPositive"); + setEventMessages($mesg, null, 'warnings'); + $error++; + $result = -1; + } elseif (GETPOST('progress') < $line->situation_percent) // TODO : use a modified $line->get_prev_progress($object->id) result + { + $mesg = $langs->trans("CantBeLessThanMinPercent"); + setEventMessages($mesg, null, 'warnings'); + $error++; + $result = -1; + } } elseif (GETPOST('progress') < $percent) { $mesg = '
    '.$langs->trans("CantBeLessThanMinPercent").'
    '; @@ -2399,13 +2418,13 @@ if (empty($reshook)) if (!$object->fetch($id) > 0) dol_print_error($db); if (GETPOST('all_progress') != "") { - $all_progress = GETPOST('all_progress', 'int'); + $all_progress = GETPOST('all_progress', 'int'); foreach ($object->lines as $line) { $percent = $line->get_prev_progress($object->id); if (floatval($all_progress) < floatval($percent)) { - $mesg = $langs->trans("Line").' '.$i.' : '.$langs->trans("CantBeLessThanMinPercent"); - setEventMessages($mesg, null, 'warnings'); + $mesg = $langs->trans("Line").' '.$i.' : '.$langs->trans("CantBeLessThanMinPercent"); + setEventMessages($mesg, null, 'warnings'); $result = -1; } else $object->update_percent($line, $_POST['all_progress']); } @@ -2416,192 +2435,192 @@ if (empty($reshook)) } // Outing situation invoice from cycle elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $usercancreate) { - $object->fetch($id, '', '', '', true); + $object->fetch($id, '', '', '', true); - if ($object->statut == Facture::STATUS_VALIDATED - && $object->type == Facture::TYPE_SITUATION - && $usercancreate - && !$objectidnext - && $object->is_last_in_cycle() - && $usercanunvalidate - ) - { - $outingError = 0; - $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle - if ($newCycle > 1) - { - // Search credit notes - $lastCycle = $object->situation_cycle_ref; - $lastSituationCounter = $object->situation_counter; - $linkedCreditNotesList = array(); + if ($object->statut == Facture::STATUS_VALIDATED + && $object->type == Facture::TYPE_SITUATION + && $usercancreate + && !$objectidnext + && $object->is_last_in_cycle() + && $usercanunvalidate + ) + { + $outingError = 0; + $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle + if ($newCycle > 1) + { + // Search credit notes + $lastCycle = $object->situation_cycle_ref; + $lastSituationCounter = $object->situation_counter; + $linkedCreditNotesList = array(); - if (count($object->tab_next_situation_invoice) > 0) { - foreach ($object->tab_next_situation_invoice as $next_invoice) { - if ($next_invoice->type == Facture::TYPE_CREDIT_NOTE - && $next_invoice->situation_counter == $object->situation_counter - && $next_invoice->fk_facture_source == $object->id - ) - { - $linkedCreditNotesList[] = $next_invoice->id; - } - } - } + if (count($object->tab_next_situation_invoice) > 0) { + foreach ($object->tab_next_situation_invoice as $next_invoice) { + if ($next_invoice->type == Facture::TYPE_CREDIT_NOTE + && $next_invoice->situation_counter == $object->situation_counter + && $next_invoice->fk_facture_source == $object->id + ) + { + $linkedCreditNotesList[] = $next_invoice->id; + } + } + } - $object->situation_cycle_ref = $newCycle; - $object->situation_counter = 1; - $object->situation_final = 0; - if ($object->update($user) > 0) - { - $errors = 0; - if (count($linkedCreditNotesList) > 0) - { - // now, credit note must follow - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; - $sql .= ' SET situation_cycle_ref='.$newCycle; - $sql .= ' , situation_final=0'; - $sql .= ' , situation_counter='.$object->situation_counter; - $sql .= ' WHERE rowid IN ('.implode(',', $linkedCreditNotesList).')'; + $object->situation_cycle_ref = $newCycle; + $object->situation_counter = 1; + $object->situation_final = 0; + if ($object->update($user) > 0) + { + $errors = 0; + if (count($linkedCreditNotesList) > 0) + { + // now, credit note must follow + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; + $sql .= ' SET situation_cycle_ref='.$newCycle; + $sql .= ' , situation_final=0'; + $sql .= ' , situation_counter='.$object->situation_counter; + $sql .= ' WHERE rowid IN ('.implode(',', $linkedCreditNotesList).')'; - $resql = $db->query($sql); - if (!$resql) $errors++; + $resql = $db->query($sql); + if (!$resql) $errors++; - // Change each progression persent on each lines - foreach ($object->lines as $line) - { - // no traitement for special product - if ($line->product_type == 9) continue; + // Change each progression persent on each lines + foreach ($object->lines as $line) + { + // no traitement for special product + if ($line->product_type == 9) continue; - if (!empty($object->tab_previous_situation_invoice)) - { - // search the last invoice in cycle - $lineIndex = count($object->tab_previous_situation_invoice) - 1; - $searchPreviousInvoice = true; - while ($searchPreviousInvoice) - { - if ($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) - { - $searchPreviousInvoice = false; // find, exit; - break; - } else { - $lineIndex--; // go to previous invoice in cycle - } - } + if (!empty($object->tab_previous_situation_invoice)) + { + // search the last invoice in cycle + $lineIndex = count($object->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while ($searchPreviousInvoice) + { + if ($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + { + $searchPreviousInvoice = false; // find, exit; + break; + } else { + $lineIndex--; // go to previous invoice in cycle + } + } - $maxPrevSituationPercent = 0; - foreach ($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) - { - if ($prevLine->id == $line->fk_prev_id) - { - $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); - } - } + $maxPrevSituationPercent = 0; + foreach ($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + { + if ($prevLine->id == $line->fk_prev_id) + { + $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); + } + } - $line->situation_percent = $line->situation_percent - $maxPrevSituationPercent; + $line->situation_percent = $line->situation_percent - $maxPrevSituationPercent; - if ($line->update() < 0) $errors++; - } - } - } + if ($line->update() < 0) $errors++; + } + } + } - if (!$errors) - { - setEventMessages($langs->trans('Updated'), '', 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - } else { - setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); - } - } else { - setEventMessages($langs->trans('ErrorOutingSituationInvoiceOnUpdate'), array(), 'errors'); - } - } else { - setEventMessages($langs->trans('ErrorFindNextSituationInvoice'), array(), 'errors'); - } - } + if (!$errors) + { + setEventMessages($langs->trans('Updated'), '', 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + } else { + setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); + } + } else { + setEventMessages($langs->trans('ErrorOutingSituationInvoiceOnUpdate'), array(), 'errors'); + } + } else { + setEventMessages($langs->trans('ErrorFindNextSituationInvoice'), array(), 'errors'); + } + } } // add lines from objectlinked elseif ($action == 'import_lines_from_object' - && $usercancreate - && $object->statut == Facture::STATUS_DRAFT - && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) + && $usercancreate + && $object->statut == Facture::STATUS_DRAFT + && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) { - $fromElement = GETPOST('fromelement'); - $fromElementid = GETPOST('fromelementid'); - $importLines = GETPOST('line_checkbox'); + $fromElement = GETPOST('fromelement'); + $fromElementid = GETPOST('fromelementid'); + $importLines = GETPOST('line_checkbox'); - if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) - { - if ($fromElement == 'commande') - { - dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'OrderLine'; - } elseif ($fromElement == 'propal') - { - dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'PropaleLigne'; - } - $nextRang = count($object->lines) + 1; - $importCount = 0; - $error = 0; - foreach ($importLines as $lineId) - { - $lineId = intval($lineId); - $originLine = new $lineClassName($db); - if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) - { - $originLine->fetch_optionals(); - $desc = $originLine->desc; - $pu_ht = $originLine->subprice; - $qty = $originLine->qty; - $txtva = $originLine->tva_tx; - $txlocaltax1 = $originLine->localtax1_tx; - $txlocaltax2 = $originLine->localtax2_tx; - $fk_product = $originLine->fk_product; - $remise_percent = $originLine->remise_percent; - $date_start = $originLine->date_start; - $date_end = $originLine->date_end; - $ventil = 0; - $info_bits = $originLine->info_bits; - $fk_remise_except = $originLine->fk_remise_except; - $price_base_type = 'HT'; - $pu_ttc = 0; - $type = $originLine->product_type; - $rang = $nextRang++; - $special_code = $originLine->special_code; - $origin = $originLine->element; - $origin_id = $originLine->id; - $fk_parent_line = 0; - $fk_fournprice = $originLine->fk_fournprice; - $pa_ht = $originLine->pa_ht; - $label = $originLine->label; - $array_options = $originLine->array_options; - if ($object->type == Facture::TYPE_SITUATION) { - $situation_percent = 0; - } else { - $situation_percent = 100; - } - $fk_prev_id = ''; - $fk_unit = $originLine->fk_unit; - $pu_ht_devise = $originLine->multicurrency_subprice; + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + { + if ($fromElement == 'commande') + { + dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'OrderLine'; + } elseif ($fromElement == 'propal') + { + dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'PropaleLigne'; + } + $nextRang = count($object->lines) + 1; + $importCount = 0; + $error = 0; + foreach ($importLines as $lineId) + { + $lineId = intval($lineId); + $originLine = new $lineClassName($db); + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + { + $originLine->fetch_optionals(); + $desc = $originLine->desc; + $pu_ht = $originLine->subprice; + $qty = $originLine->qty; + $txtva = $originLine->tva_tx; + $txlocaltax1 = $originLine->localtax1_tx; + $txlocaltax2 = $originLine->localtax2_tx; + $fk_product = $originLine->fk_product; + $remise_percent = $originLine->remise_percent; + $date_start = $originLine->date_start; + $date_end = $originLine->date_end; + $ventil = 0; + $info_bits = $originLine->info_bits; + $fk_remise_except = $originLine->fk_remise_except; + $price_base_type = 'HT'; + $pu_ttc = 0; + $type = $originLine->product_type; + $rang = $nextRang++; + $special_code = $originLine->special_code; + $origin = $originLine->element; + $origin_id = $originLine->id; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; + $pa_ht = $originLine->pa_ht; + $label = $originLine->label; + $array_options = $originLine->array_options; + if ($object->type == Facture::TYPE_SITUATION) { + $situation_percent = 0; + } else { + $situation_percent = 100; + } + $fk_prev_id = ''; + $fk_unit = $originLine->fk_unit; + $pu_ht_devise = $originLine->multicurrency_subprice; - $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit, $pu_ht_devise); + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit, $pu_ht_devise); - if ($res > 0) { - $importCount++; - } else { - $error++; - } - } else { - $error++; - } - } + if ($res > 0) { + $importCount++; + } else { + $error++; + } + } else { + $error++; + } + } - if ($error) - { - setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); - } - } + if ($error) + { + setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); + } + } } // Actions when printing a doc from card @@ -2862,24 +2881,26 @@ if ($action == 'create') $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates")); if (empty($conf->global->INVOICE_DISABLE_AUTOMATIC_RECURRING_INVOICE)) { - $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); + $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); } print info_admin($text, 0, 0, 0).'
    '; } - print '
    '; + print ''; print ''; print ''; if ($soc->id > 0) print ''."\n"; print ''; print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; if (!empty($currency_tx)) print ''; - dol_fiche_head(''); + print dol_get_fiche_head(''); print ''; @@ -2918,15 +2939,24 @@ if ($action == 'create') print ''; print '"; @@ -3595,7 +3625,7 @@ if ($action == 'create') print "
    '.$langs->trans('Customer').''; print $form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); - // Option to reload page to retrieve customer informations. Note, this clear other input - if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) + // Option to reload page to retrieve customer informations. + if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { print ''; } @@ -3455,10 +3485,10 @@ if ($action == 'create') $liste = ModelePDFFactures::liste_modeles($db); if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) { // Hidden conf - $paramkey = 'FACTURE_ADDON_PDF_'.$object->type; - $curent = !empty($conf->global->$paramkey) ? $conf->global->$paramkey : $conf->global->FACTURE_ADDON_PDF; + $paramkey = 'FACTURE_ADDON_PDF_'.$object->type; + $curent = !empty($conf->global->$paramkey) ? $conf->global->$paramkey : $conf->global->FACTURE_ADDON_PDF; } else { - $curent = $conf->global->FACTURE_ADDON_PDF; + $curent = $conf->global->FACTURE_ADDON_PDF; } print $form->selectarray('model', $liste, $curent); print "
    \n"; - dol_fiche_end(); + print dol_get_fiche_end(); // Button "Create Draft" print '
    '; @@ -3604,8 +3634,6 @@ if ($action == 'create') print ''; print '
    '; - print "
    \n"; - // Show origin lines if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { print '
    '; @@ -3615,12 +3643,12 @@ if ($action == 'create') print ''; - $objectsrc->printOriginLinesList(); + $objectsrc->printOriginLinesList('', $selectedLines); print '
    '; } - print '
    '; + print ''; } elseif ($id > 0 || !empty($ref)) { /* @@ -3687,7 +3715,7 @@ if ($action == 'create') $head = facture_prepare_head($object); - dol_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer'), -1, 'bill'); + print dol_get_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer'), -1, 'bill'); $formconfirm = ''; @@ -3740,18 +3768,18 @@ if ($action == 'create') // Confirmation to remove invoice from cycle if ($action == 'situationout') { - $text = $langs->trans('ConfirmRemoveSituationFromCycle', $object->ref); - $label = $langs->trans("ConfirmOuting"); - $formquestion = array(); - // remove situation from cycle - if ($object->statut == Facture::STATUS_VALIDATED - && $usercancreate - && !$objectidnext - && $object->is_last_in_cycle() - && $usercanunvalidate - ) - { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $label, $text, 'confirm_situationout', $formquestion, "yes", 1); + $text = $langs->trans('ConfirmRemoveSituationFromCycle', $object->ref); + $label = $langs->trans("ConfirmOuting"); + $formquestion = array(); + // remove situation from cycle + if ($object->statut == Facture::STATUS_VALIDATED + && $usercancreate + && !$objectidnext + && $object->is_last_in_cycle() + && $usercanunvalidate + ) + { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $label, $text, 'confirm_situationout', $formquestion, "yes", 1); } } @@ -3952,7 +3980,7 @@ if ($action == 'create') // Create an array for form $formquestion = array( array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1)), - array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()) + array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()) ); // Ask confirmatio to clone $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250); @@ -4303,7 +4331,7 @@ if ($action == 'create') if (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { - $displayWarranty = true; + $displayWarranty = true; if (!in_array($object->type, $retainedWarrantyInvoiceAvailableType) && empty($object->retained_warranty)) { $displayWarranty = false; } @@ -4315,90 +4343,90 @@ if ($action == 'create') print $langs->trans('RetainedWarranty'); print ''; if ($action != 'editretainedwarranty' && $user->rights->facture->creer) { - print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).''; + print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).''; } - print ''; - print ''; - if ($action == 'editretainedwarranty') - { - print '
    '; - print ''; - print ''; - print ''; - print ''; - print '
    '; - } else { - print price($object->retained_warranty).'%'; - } - print ''; + print ''; + print ''; + if ($action == 'editretainedwarranty') + { + print '
    '; + print ''; + print ''; + print ''; + print ''; + print '
    '; + } else { + print price($object->retained_warranty).'%'; + } + print ''; - // Retained warranty payment term - print ''; - print ''; - if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { - print ''; - } + // Retained warranty payment term + print '
    '; - print $langs->trans('PaymentConditionsShortRetainedWarranty'); - print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
    '; + print ''; + if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { + print ''; + } - print '
    '; + print $langs->trans('PaymentConditionsShortRetainedWarranty'); + print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
    '; - print '
    '; - $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); - if ($object->date > $defaultDate) { - $defaultDate = $object->date; - } + print '
    '; + print ''; + $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); + if ($object->date > $defaultDate) { + $defaultDate = $object->date; + } - if ($action == 'editretainedwarrantypaymentterms') - { - //date('Y-m-d',$object->date_lim_reglement) - print '
    '; - print ''; - print ''; - $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; - $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; - $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); - print ''; - print '
    '; - } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->retained_warranty_fk_cond_reglement, 'none'); - if (!$displayWarranty) { - print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" '); - } - } - print ''; + if ($action == 'editretainedwarrantypaymentterms') + { + //date('Y-m-d',$object->date_lim_reglement) + print '
    '; + print ''; + print ''; + $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; + $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); + print ''; + print '
    '; + } else { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->retained_warranty_fk_cond_reglement, 'none'); + if (!$displayWarranty) { + print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" '); + } + } + print ''; - // Retained Warranty payment date limit - print ''; - print ''; - if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer) { - print ''; - } + // Retained Warranty payment date limit + print '
    '; - print $langs->trans('RetainedWarrantyDateLimit'); - print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).'
    '; + print ''; + if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer) { + print ''; + } - print '
    '; + print $langs->trans('RetainedWarrantyDateLimit'); + print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).'
    '; - print '
    '; - $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); - if ($object->date > $defaultDate) { - $defaultDate = $object->date; - } + print '
    '; + print ''; + $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); + if ($object->date > $defaultDate) { + $defaultDate = $object->date; + } - if ($action == 'editretainedwarrantydatelimit') - { - //date('Y-m-d',$object->date_lim_reglement) - print '
    '; - print ''; - print ''; - print ''; - print ''; - print '
    '; - } else { - print dol_print_date($object->retained_warranty_date_limit, 'day'); - } - print ''; - } + if ($action == 'editretainedwarrantydatelimit') + { + //date('Y-m-d',$object->date_lim_reglement) + print '
    '; + print ''; + print ''; + print ''; + print ''; + print '
    '; + } else { + print dol_print_date($object->retained_warranty_date_limit, 'day'); + } + print ''; + } } @@ -4417,7 +4445,7 @@ if ($action == 'create') $sign = 1; if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && $object->type == $object::TYPE_CREDIT_NOTE) { - $sign = -1; // We invert sign for output + $sign = -1; // We invert sign for output } if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) @@ -4540,84 +4568,84 @@ if ($action == 'create') // List of previous situation invoices if (($object->situation_cycle_ref > 0) && !empty($conf->global->INVOICE_USE_SITUATION)) { - print ''; + print '
    '; - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; - $total_prev_ht = $total_prev_ttc = 0; - $total_global_ht = $total_global_ttc = 0; + $total_prev_ht = $total_prev_ttc = 0; + $total_global_ht = $total_global_ttc = 0; - if (count($object->tab_previous_situation_invoice) > 0) { - // List of previous invoices + if (count($object->tab_previous_situation_invoice) > 0) { + // List of previous invoices - $current_situation_counter = array(); - foreach ($object->tab_previous_situation_invoice as $prev_invoice) { - $tmptotalpaidforthisinvoice = $prev_invoice->getSommePaiement(); - $total_prev_ht += $prev_invoice->total_ht; - $total_prev_ttc += $prev_invoice->total_ttc; - $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ?-1 : 1) * $prev_invoice->situation_counter; - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - } - } + $current_situation_counter = array(); + foreach ($object->tab_previous_situation_invoice as $prev_invoice) { + $tmptotalpaidforthisinvoice = $prev_invoice->getSommePaiement(); + $total_prev_ht += $prev_invoice->total_ht; + $total_prev_ttc += $prev_invoice->total_ttc; + $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ?-1 : 1) * $prev_invoice->situation_counter; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + } + } - $total_global_ht += $total_prev_ht; - $total_global_ttc += $total_prev_ttc; - $total_global_ht += $object->total_ht; - $total_global_ttc += $object->total_ttc; - $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE) ?-1 : 1) * $object->situation_counter; - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; + $total_global_ht += $total_prev_ht; + $total_global_ttc += $total_prev_ttc; + $total_global_ht += $object->total_ht; + $total_global_ttc += $object->total_ttc; + $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE) ?-1 : 1) * $object->situation_counter; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; - if (count($object->tab_next_situation_invoice) > 0) { - // List of next invoices - /*print ''; + if (count($object->tab_next_situation_invoice) > 0) { + // List of next invoices + /*print ''; print ''; print ''; print ''; @@ -4627,37 +4655,37 @@ if ($action == 'create') print ''; print '';*/ - $total_next_ht = $total_next_ttc = 0; + $total_next_ht = $total_next_ttc = 0; - foreach ($object->tab_next_situation_invoice as $next_invoice) { - $totalpaye = $next_invoice->getSommePaiement(); - $total_next_ht += $next_invoice->total_ht; - $total_next_ttc += $next_invoice->total_ttc; + foreach ($object->tab_next_situation_invoice as $next_invoice) { + $totalpaye = $next_invoice->getSommePaiement(); + $total_next_ht += $next_invoice->total_ht; + $total_next_ttc += $next_invoice->total_ttc; - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - } + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + } - $total_global_ht += $total_next_ht; - $total_global_ttc += $total_next_ttc; + $total_global_ht += $total_next_ht; + $total_global_ttc += $total_next_ttc; - print ''; - print ''; - if (!empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - print ''; - } + print ''; + print ''; + if (!empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + print ''; + } - print '
    '.$langs->trans('ListOfSituationInvoices').''.$langs->trans('Situation').''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').' 
    '.$langs->trans('ListOfSituationInvoices').''.$langs->trans('Situation').''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').' 
    '.$prev_invoice->getNomUrl(1).''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$prev_invoice->situation_counter.''.price($prev_invoice->total_ht).''.price($prev_invoice->total_ttc).''.$prev_invoice->getLibStatut(3, $tmptotalpaidforthisinvoice).'
    '.$prev_invoice->getNomUrl(1).''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$prev_invoice->situation_counter.''.price($prev_invoice->total_ht).''.price($prev_invoice->total_ttc).''.$prev_invoice->getLibStatut(3, $tmptotalpaidforthisinvoice).'
    '.$object->getNomUrl(1).''.(($object->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$object->situation_counter.''.price($object->total_ht).''.price($object->total_ttc).''.$object->getLibStatut(3, $object->getSommePaiement()).'
    '.$object->getNomUrl(1).''.(($object->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$object->situation_counter.''.price($object->total_ht).''.price($object->total_ttc).''.$object->getLibStatut(3, $object->getSommePaiement()).'
    '.$langs->trans('CurrentSituationTotal').''; - $i = 0; - foreach ($current_situation_counter as $sit) - { - $curSign = $sit > 0 ? '+' : '-'; - $curType = $sit > 0 ? $langs->trans('situationInvoiceShortcode_S') : $langs->trans('situationInvoiceShortcode_AS'); - if ($i > 0) print ' '.$curSign.' '; - print $curType.abs($sit); - $i++; - } - print ''.price($total_global_ht).''.price($total_global_ttc).' 
    '.$langs->trans('CurrentSituationTotal').''; + $i = 0; + foreach ($current_situation_counter as $sit) + { + $curSign = $sit > 0 ? '+' : '-'; + $curType = $sit > 0 ? $langs->trans('situationInvoiceShortcode_S') : $langs->trans('situationInvoiceShortcode_AS'); + if ($i > 0) print ' '.$curSign.' '; + print $curType.abs($sit); + $i++; + } + print ''.price($total_global_ht).''.price($total_global_ttc).' 
    ' . $langs->trans('ListOfNextSituationInvoices') . ' 
    '.$next_invoice->getNomUrl(1).''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$next_invoice->situation_counter.''.price($next_invoice->total_ht).''.price($next_invoice->total_ttc).''.$next_invoice->getLibStatut(3, $totalpaye).'
    '.$next_invoice->getNomUrl(1).''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$next_invoice->situation_counter.''.price($next_invoice->total_ht).''.price($next_invoice->total_ttc).''.$next_invoice->getLibStatut(3, $totalpaye).'
    '.price($total_global_ht).''.price($total_global_ttc).' 
    '.price($total_global_ht).''.price($total_global_ttc).' 
    '; + print ''; } $sign = 1; @@ -4846,31 +4874,31 @@ if ($action == 'create') print ''; print $langs->trans('RemainderToPay'); if ($resteapayeraffiche < 0) - print ' ('.$langs->trans('ExcessReceived').')'; + print ' ('.$langs->trans('ExcessReceived').')'; print ' :'; print ''.price($resteapayeraffiche).''; print ' '; // Retained warranty : usualy use on construction industry if (!empty($object->situation_final) && !empty($object->retained_warranty) && $displayWarranty) { - // Billed - retained warranty - if ($object->type == Facture::TYPE_SITUATION) - { - $retainedWarranty = $total_global_ttc * $object->retained_warranty / 100; - } else { - // Because one day retained warranty could be used on standard invoices - $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; - } + // Billed - retained warranty + if ($object->type == Facture::TYPE_SITUATION) + { + $retainedWarranty = $total_global_ttc * $object->retained_warranty / 100; + } else { + // Because one day retained warranty could be used on standard invoices + $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; + } - $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty; + $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty; - print ''.$langs->trans("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')).' :'.price($billedWithRetainedWarranty).' '; + print ''.$langs->trans("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')).' :'.price($billedWithRetainedWarranty).' '; - // retained warranty - print ''; - print $langs->trans("RetainedWarranty").' ('.$object->retained_warranty.'%)'; - print !empty($object->retained_warranty_date_limit) ? ' '.$langs->trans("ToPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; - print ' :'.price($retainedWarranty).' '; + // retained warranty + print ''; + print $langs->trans("RetainedWarranty").' ('.$object->retained_warranty.'%)'; + print !empty($object->retained_warranty_date_limit) ? ' '.$langs->trans("ToPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; + print ' :'.price($retainedWarranty).' '; } } else // Credit note { @@ -4933,7 +4961,7 @@ if ($action == 'create') { if ($object->situation_cycle_ref && $object->statut == 0) { - print ''."\n"; + print ''."\n"; print '
    '; print '
    '; @@ -4957,7 +4985,7 @@ if ($action == 'create') print ''; // Adds a line numbering column if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ' '; + print ' '; } print ' '; print '%'; @@ -4994,7 +5022,7 @@ if ($action == 'create') // Form to add new line if ($object->statut == 0 && $usercancreate && $action != 'valid' && $action != 'editline') { - if ($action != 'editline' && $action != 'selectlines') + if ($action != 'editline' && $action != 'selectlines') { // Add free products/services $object->formAddObjectLine(1, $mysoc, $soc); @@ -5009,7 +5037,7 @@ if ($action == 'create') print "
    \n"; - dol_fiche_end(); + print dol_get_fiche_end(); // Actions buttons @@ -5060,7 +5088,7 @@ if ($action == 'create') && ($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) // A paid invoice (partially or completely) { - if ($object->close_code != 'replaced' || (!$objectidnext)) // Not replaced by another invoice or replaced but the replacement invoice has been deleted + if ($object->close_code != 'replaced' || (!$objectidnext)) // Not replaced by another invoice or replaced but the replacement invoice has been deleted { print ''.$langs->trans('ReOpen').''; } else { @@ -5113,9 +5141,9 @@ if ($action == 'create') // POS Ticket if (!empty($conf->takepos->enabled) && $object->module_source == 'takepos') { - $langs->load("cashdesk"); - $receipt_url = DOL_URL_ROOT."/takepos/receipt.php"; - print ''.$langs->trans('POSTicket').''; + $langs->load("cashdesk"); + $receipt_url = DOL_URL_ROOT."/takepos/receipt.php"; + print ''.$langs->trans('POSTicket').''; } // Create payment @@ -5203,19 +5231,19 @@ 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 - && $usercancreate - && !$objectidnext - && $object->is_last_in_cycle() - && $conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE - ) + && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0 + && $usercancreate + && !$objectidnext + && $object->is_last_in_cycle() + && $conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE + ) { if ($usercanunvalidate) - { - print ''.$langs->trans("CreateCreditNote").''; - } else { - print ''.$langs->trans("CreateCreditNote").''; - } + { + print ''.$langs->trans("CreateCreditNote").''; + } else { + print ''.$langs->trans("CreateCreditNote").''; + } } // Clone @@ -5235,20 +5263,20 @@ if ($action == 'create') // Remove situation from cycle if ($object->statut > Facture::STATUS_DRAFT - && $object->type == Facture::TYPE_SITUATION - && $usercancreate - && !$objectidnext - && $object->situation_counter > 1 - && $object->is_last_in_cycle() + && $object->type == Facture::TYPE_SITUATION + && $usercancreate + && !$objectidnext + && $object->situation_counter > 1 + && $object->is_last_in_cycle() && $usercanunvalidate - ) + ) { - if (($object->total_ttc - $totalcreditnotes) == 0) - { - print ''.$langs->trans("RemoveSituationFromCycle").''; - } else { - print ''.$langs->trans("RemoveSituationFromCycle").''; - } + if (($object->total_ttc - $totalcreditnotes) == 0) + { + print ''.$langs->trans("RemoveSituationFromCycle").''; + } else { + print ''.$langs->trans("RemoveSituationFromCycle").''; + } } // Create next situation invoice @@ -5319,10 +5347,10 @@ if ($action == 'create') $compatibleImportElementsList = false; if ($usercancreate - && $object->statut == Facture::STATUS_DRAFT - && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) + && $object->statut == Facture::STATUS_DRAFT + && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) { - $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements + $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 0ab4974ce7f..19a5c8c287b 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -482,1163 +482,1202 @@ class Invoices extends DolibarrApi * @url DELETE {id}/contact/{contactid}/{type} * * @return array - * - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 + * + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ - public function deleteContact($id, $contactid, $type) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } + public function deleteContact($id, $contactid, $type) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } - $result = $this->invoice->fetch($id); + $result = $this->invoice->fetch($id); if (!$result) { throw new RestException(404, 'Invoice not found'); } - if (!DolibarrApi::_checkAccessToResource('invoice', $this->invoice->id)) { + if (!DolibarrApi::_checkAccessToResource('invoice', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $contacts = $this->invoice->liste_contact(); + $contacts = $this->invoice->liste_contact(); foreach ($contacts as $contact) { if ($contact['id'] == $contactid && $contact['code'] == $type) { - $result = $this->invoice->delete_contact($contact['rowid']); + $result = $this->invoice->delete_contact($contact['rowid']); - if (!$result) { - throw new RestException(500, 'Error when deleted the contact'); - } - } + if (!$result) { + throw new RestException(500, 'Error when deleted the contact'); + } + } } - return $this->_cleanObjectDatas($this->invoice); - } + return $this->_cleanObjectDatas($this->invoice); + } - /** - * Deletes a line of a given invoice - * - * @param int $id Id of invoice - * @param int $lineid Id of the line to delete - * - * @url DELETE {id}/lines/{lineid} - * - * @return array - * - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 - */ - public function deleteLine($id, $lineid) - { + /** + * Deletes a line of a given invoice + * + * @param int $id Id of invoice + * @param int $lineid Id of the line to delete + * + * @url DELETE {id}/lines/{lineid} + * + * @return array + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 + */ + public function deleteLine($id, $lineid) + { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - if (empty($lineid)) { - throw new RestException(400, 'Line ID is mandatory'); - } + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + if (empty($lineid)) { + throw new RestException(400, 'Line ID is mandatory'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - // TODO Check the lineid $lineid is a line of ojbect + // TODO Check the lineid $lineid is a line of ojbect - $updateRes = $this->invoice->deleteline($lineid); - if ($updateRes > 0) { - return $this->get($id); - } else { - throw new RestException(405, $this->invoice->error); - } - } + $updateRes = $this->invoice->deleteline($lineid); + if ($updateRes > 0) { + return $this->get($id); + } else { + throw new RestException(405, $this->invoice->error); + } + } - /** - * Update invoice - * - * @param int $id Id of invoice to update - * @param array $request_data Datas - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + /** + * Update invoice + * + * @param int $id Id of invoice to update + * @param array $request_data Datas + * @return int + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - $this->invoice->$field = $value; - } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + $this->invoice->$field = $value; + } - // update bank account - if (!empty($this->invoice->fk_account)) - { - if ($this->invoice->setBankAccount($this->invoice->fk_account) == 0) { - throw new RestException(400, $this->invoice->error); - } - } + // update bank account + if (!empty($this->invoice->fk_account)) + { + if ($this->invoice->setBankAccount($this->invoice->fk_account) == 0) { + throw new RestException(400, $this->invoice->error); + } + } - if ($this->invoice->update(DolibarrApiAccess::$user)) - return $this->get($id); + if ($this->invoice->update(DolibarrApiAccess::$user)) + return $this->get($id); - return false; - } + return false; + } - /** - * Delete invoice - * - * @param int $id Invoice ID - * @return array - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->facture->supprimer) { + /** + * Delete invoice + * + * @param int $id Invoice ID + * @return array + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->facture->supprimer) { throw new RestException(401); } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->delete(DolibarrApiAccess::$user); - if ($result < 0) - { - throw new RestException(500); - } + if ($result < 0) + { + throw new RestException(500); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Invoice deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Invoice deleted' + ) + ); + } - /** - * Add a line to a given invoice - * - * Exemple of POST query : - * { - * "desc": "Desc", "subprice": "1.00000000", "qty": "1", "tva_tx": "20.000", "localtax1_tx": "0.000", "localtax2_tx": "0.000", - * "fk_product": "1", "remise_percent": "0", "date_start": "", "date_end": "", "fk_code_ventilation": 0, "info_bits": "0", - * "fk_remise_except": null, "product_type": "1", "rang": "-1", "special_code": "0", "fk_parent_line": null, "fk_fournprice": null, - * "pa_ht": "0.00000000", "label": "", "array_options": [], "situation_percent": "100", "fk_prev_id": null, "fk_unit": null - * } - * - * @param int $id Id of invoice - * @param array $request_data InvoiceLine data - * - * @url POST {id}/lines - * - * @return int - * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 400 - */ - public function postLine($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } + /** + * Add a line to a given invoice + * + * Exemple of POST query : + * { + * "desc": "Desc", "subprice": "1.00000000", "qty": "1", "tva_tx": "20.000", "localtax1_tx": "0.000", "localtax2_tx": "0.000", + * "fk_product": "1", "remise_percent": "0", "date_start": "", "date_end": "", "fk_code_ventilation": 0, "info_bits": "0", + * "fk_remise_except": null, "product_type": "1", "rang": "-1", "special_code": "0", "fk_parent_line": null, "fk_fournprice": null, + * "pa_ht": "0.00000000", "label": "", "array_options": [], "situation_percent": "100", "fk_prev_id": null, "fk_unit": null + * } + * + * @param int $id Id of invoice + * @param array $request_data InvoiceLine data + * + * @url POST {id}/lines + * + * @return int + * + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 400 + */ + public function postLine($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $request_data = (object) $request_data; + $request_data = (object) $request_data; - // 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) { - $request_data->fk_parent_line = 0; - } + // 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) { + $request_data->fk_parent_line = 0; + } - // calculate pa_ht - $marginInfos = getMarginInfos($request_data->subprice, $request_data->remise_percent, $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->fk_fournprice, $request_data->pa_ht); - $pa_ht = $marginInfos[0]; + // calculate pa_ht + $marginInfos = getMarginInfos($request_data->subprice, $request_data->remise_percent, $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->fk_fournprice, $request_data->pa_ht); + $pa_ht = $marginInfos[0]; - $updateRes = $this->invoice->addline( - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - $request_data->fk_product, - $request_data->remise_percent, - $request_data->date_start, - $request_data->date_end, - $request_data->fk_code_ventilation, - $request_data->info_bits, - $request_data->fk_remise_except, - 'HT', - 0, - $request_data->product_type, - $request_data->rang, - $request_data->special_code, - $request_data->origin, - $request_data->origin_id, - $request_data->fk_parent_line, - empty($request_data->fk_fournprice) ?null:$request_data->fk_fournprice, - $pa_ht, - $request_data->label, - $request_data->array_options, - $request_data->situation_percent, - $request_data->fk_prev_id, - $request_data->fk_unit, - 0, - $request_data->ref_ext - ); + $updateRes = $this->invoice->addline( + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->fk_product, + $request_data->remise_percent, + $request_data->date_start, + $request_data->date_end, + $request_data->fk_code_ventilation, + $request_data->info_bits, + $request_data->fk_remise_except, + 'HT', + 0, + $request_data->product_type, + $request_data->rang, + $request_data->special_code, + $request_data->origin, + $request_data->origin_id, + $request_data->fk_parent_line, + empty($request_data->fk_fournprice) ?null:$request_data->fk_fournprice, + $pa_ht, + $request_data->label, + $request_data->array_options, + $request_data->situation_percent, + $request_data->fk_prev_id, + $request_data->fk_unit, + 0, + $request_data->ref_ext + ); - if ($updateRes < 0) { - throw new RestException(400, 'Unable to insert the new line. Check your inputs. '.$this->invoice->error); - } + if ($updateRes < 0) { + throw new RestException(400, 'Unable to insert the new line. Check your inputs. '.$this->invoice->error); + } - return $updateRes; - } + return $updateRes; + } - /** - * Adds a contact to an invoice - * - * @param int $id Order ID - * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link - * @param string $type_contact Type of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING - * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) - * @param int $notrigger Disable all triggers - * - * @url POST {id}/contacts - * - * @return array - * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 - * - */ - public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + /** + * Adds a contact to an invoice + * + * @param int $id Order ID + * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link + * @param string $type_contact Type of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING + * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) + * @param int $notrigger Disable all triggers + * + * @url POST {id}/contacts + * + * @return array + * + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 + * + */ + public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->invoice->add_contact($fk_socpeople, $type_contact, $source, $notrigger); - if ($result < 0) { - throw new RestException(500, 'Error : '.$this->invoice->error); - } + $result = $this->invoice->add_contact($fk_socpeople, $type_contact, $source, $notrigger); + if ($result < 0) { + throw new RestException(500, 'Error : '.$this->invoice->error); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->invoice); - } + return $this->_cleanObjectDatas($this->invoice); + } - /** - * Sets an invoice as draft - * - * @param int $id Order ID - * @param int $idwarehouse Warehouse ID - * - * @url POST {id}/settodraft - * - * @return array - * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 - * - */ - public function settodraft($id, $idwarehouse = -1) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + /** + * Sets an invoice as draft + * + * @param int $id Order ID + * @param int $idwarehouse Warehouse ID + * + * @url POST {id}/settodraft + * + * @return array + * + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 + * + */ + public function settodraft($id, $idwarehouse = -1) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->invoice->setDraft(DolibarrApiAccess::$user, $idwarehouse); - if ($result == 0) { - throw new RestException(304, 'Nothing done.'); - } - if ($result < 0) { - throw new RestException(500, 'Error : '.$this->invoice->error); - } + $result = $this->invoice->setDraft(DolibarrApiAccess::$user, $idwarehouse); + if ($result == 0) { + throw new RestException(304, 'Nothing done.'); + } + if ($result < 0) { + throw new RestException(500, 'Error : '.$this->invoice->error); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->invoice); - } + return $this->_cleanObjectDatas($this->invoice); + } - /** - * Validate an invoice - * + /** + * Validate an invoice + * * If you get a bad value for param notrigger check that ou provide this in body - * { - * "idwarehouse": 0, - * "notrigger": 0 - * } - * - * @param int $id Invoice ID - * @param int $idwarehouse Warehouse ID - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * - * @url POST {id}/validate - * - * @return array - */ - public function validate($id, $idwarehouse = 0, $notrigger = 0) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + * { + * "idwarehouse": 0, + * "notrigger": 0 + * } + * + * @param int $id Invoice ID + * @param int $idwarehouse Warehouse ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * + * @url POST {id}/validate + * + * @return array + */ + public function validate($id, $idwarehouse = 0, $notrigger = 0) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); - } + $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->invoice); - } + return $this->_cleanObjectDatas($this->invoice); + } - /** - * Sets an invoice as paid - * - * @param int $id Order ID - * @param string $close_code Code filled if we classify to 'Paid completely' when payment is not complete (for escompte for example) - * @param string $close_note Comment defined if we classify to 'Paid' when payment is not complete (for escompte for example) - * - * @url POST {id}/settopaid - * - * @return array An invoice object - * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 - */ - public function settopaid($id, $close_code = '', $close_note = '') - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + /** + * Sets an invoice as paid + * + * @param int $id Order ID + * @param string $close_code Code filled if we classify to 'Paid completely' when payment is not complete (for escompte for example) + * @param string $close_note Comment defined if we classify to 'Paid' when payment is not complete (for escompte for example) + * + * @url POST {id}/settopaid + * + * @return array An invoice object + * + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 + */ + public function settopaid($id, $close_code = '', $close_note = '') + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->invoice->set_paid(DolibarrApiAccess::$user, $close_code, $close_note); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error : '.$this->invoice->error); - } + $result = $this->invoice->set_paid(DolibarrApiAccess::$user, $close_code, $close_note); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error : '.$this->invoice->error); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->invoice); - } + return $this->_cleanObjectDatas($this->invoice); + } - /** - * Sets an invoice as unpaid - * - * @param int $id Order ID - * - * @url POST {id}/settounpaid - * - * @return array An invoice object - * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 - */ - public function settounpaid($id) - { - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + /** + * Sets an invoice as unpaid + * + * @param int $id Order ID + * + * @url POST {id}/settounpaid + * + * @return array An invoice object + * + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 + */ + public function settounpaid($id) + { + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->invoice->set_unpaid(DolibarrApiAccess::$user); - if ($result == 0) { - throw new RestException(304, 'Nothing done'); - } - if ($result < 0) { - throw new RestException(500, 'Error : '.$this->invoice->error); - } + $result = $this->invoice->set_unpaid(DolibarrApiAccess::$user); + if ($result == 0) { + throw new RestException(304, 'Nothing done'); + } + if ($result < 0) { + throw new RestException(500, 'Error : '.$this->invoice->error); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->invoice); - } + return $this->_cleanObjectDatas($this->invoice); + } - /** - * Create a discount (credit available) for a credit note or a deposit. - * - * @param int $id Invoice ID - * @url POST {id}/markAsCreditAvailable - * - * @return array An invoice object - * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 - */ - public function markAsCreditAvailable($id) - { + /** + * Get discount from invoice + * + * @param int $id Id of invoice + * + * @url GET {id}/discount + * + * @return mixed + */ + public function getDiscount($id) + { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->facture->lire) { + throw new RestException(401); + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if ($this->invoice->paye) { - throw new RestException(500, 'Alreay payed'); - } + $discountcheck = new DiscountAbsolute($this->db); + $result = $discountcheck->fetch(0, $this->invoice->id); - $this->invoice->fetch($id); - $this->invoice->fetch_thirdparty(); + if ($result == 0) { + throw new RestException(404, 'Discount not found'); + } + if ($result < 0) { + throw new RestException(500, $discountcheck->error); + } - // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) - $discountcheck = new DiscountAbsolute($this->db); - $result = $discountcheck->fetch(0, $this->invoice->id); + return parent::_cleanObjectDatas($discountcheck); + } - $canconvert = 0; - if ($this->invoice->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) - if (($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_STANDARD) && $this->invoice->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) - if ($canconvert) - { - $this->db->begin(); - - $amount_ht = $amount_tva = $amount_ttc = array(); - $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array(); - - // Loop on each vat rate - $i = 0; - foreach ($this->invoice->lines as $line) - { - if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 - { // no need to create discount if amount is null - $amount_ht[$line->tva_tx] += $line->total_ht; - $amount_tva[$line->tva_tx] += $line->total_tva; - $amount_ttc[$line->tva_tx] += $line->total_ttc; - $multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht; - $multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva; - $multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc; - $i++; - } - } - - // Insert one discount by VAT rate category - $discount = new DiscountAbsolute($this->db); - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { - $discount->description = '(CREDIT_NOTE)'; - } elseif ($this->invoice->type == Facture::TYPE_DEPOSIT) { - $discount->description = '(DEPOSIT)'; - } elseif ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION) { - $discount->description = '(EXCESS RECEIVED)'; - } else { - throw new RestException(500, 'Cant convert to reduc an Invoice of this type'); - } - - $discount->fk_soc = $this->invoice->socid; - $discount->fk_facture_source = $this->invoice->id; - - $error = 0; - - if ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION) - { - // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT - - // Total payments - $sql = 'SELECT SUM(pf.amount) as total_payments'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql .= ' WHERE pf.fk_facture = '.$this->invoice->id; - $sql .= ' AND pf.fk_paiement = p.rowid'; - $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; - $resql = $this->db->query($sql); - if (!$resql) dol_print_error($this->db); - - $res = $this->db->fetch_object($resql); - $total_payments = $res->total_payments; - - // Total credit note and deposit - $total_creditnote_and_deposit = 0; - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; - $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; - $sql .= " WHERE fk_facture = ".$this->invoice->id; - $resql = $this->db->query($sql); - if (!empty($resql)) { - while ($obj = $this->db->fetch_object($resql)) $total_creditnote_and_deposit += $obj->amount_ttc; - } else dol_print_error($this->db); - - $discount->amount_ht = $discount->amount_ttc = $total_payments + $total_creditnote_and_deposit - $this->invoice->total_ttc; - $discount->amount_tva = 0; - $discount->tva_tx = 0; - - $result = $discount->create(DolibarrApiAccess::$user); - if ($result < 0) - { - $error++; - } - } - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_DEPOSIT) - { - foreach ($amount_ht as $tva_tx => $xxx) - { - $discount->amount_ht = abs($amount_ht[$tva_tx]); - $discount->amount_tva = abs($amount_tva[$tva_tx]); - $discount->amount_ttc = abs($amount_ttc[$tva_tx]); - $discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]); - $discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]); - $discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]); - $discount->tva_tx = abs($tva_tx); - - $result = $discount->create(DolibarrApiAccess::$user); - if ($result < 0) - { - $error++; - break; - } - } - } - - if (empty($error)) - { - if ($this->invoice->type != Facture::TYPE_DEPOSIT) { - // Classe facture - $result = $this->invoice->set_paid(DolibarrApiAccess::$user); - if ($result >= 0) - { - $this->db->commit(); - } else { - $this->db->rollback(); - throw new RestException(500, 'Could not set paid'); - } - } else { - $this->db->commit(); - } - } else { - $this->db->rollback(); - throw new RestException(500, 'Discount creation error'); - } - } - - return $this->_cleanObjectDatas($this->invoice); - } - - /** - * Add a discount line into an invoice (as an invoice line) using an existing absolute discount - * - * Note that this consume the discount. - * - * @param int $id Id of invoice - * @param int $discountid Id of discount - * - * @url POST {id}/usediscount/{discountid} - * - * @return int + /** + * Create a discount (credit available) for a credit note or a deposit. * - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 - */ - public function useDiscount($id, $discountid) - { - - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - if (empty($id)) { - throw new RestException(400, 'Invoice ID is mandatory'); - } - if (empty($discountid)) { - throw new RestException(400, 'Discount ID is mandatory'); - } - - if (!DolibarrApi::_checkAccessToResource('facture', $id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } - - $result = $this->invoice->insert_discount($discountid); - if ($result < 0) { - throw new RestException(405, $this->invoice->error); - } - - return $result; - } - - /** - * Add an available credit note discount to payments of an existing invoice. - * - * Note that this consume the credit note. - * - * @param int $id Id of invoice - * @param int $discountid Id of a discount coming from a credit note - * - * @url POST {id}/usecreditnote/{discountid} - * - * @return int - * - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 - */ - public function useCreditNote($id, $discountid) - { - - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - if (empty($id)) { - throw new RestException(400, 'Invoice ID is mandatory'); - } - if (empty($discountid)) { - throw new RestException(400, 'Credit ID is mandatory'); - } - - if (!DolibarrApi::_checkAccessToResource('facture', $id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $discount = new DiscountAbsolute($this->db); - $result = $discount->fetch($discountid); - if (!$result) { - throw new RestException(404, 'Credit not found'); - } - - $result = $discount->link_to_invoice(0, $id); - if ($result < 0) { - throw new RestException(405, $discount->error); - } - - return $result; - } - - /** - * Get list of payments of a given invoice - * - * @param int $id Id of invoice - * - * @url GET {id}/payments - * - * @return array + * @param int $id Invoice ID + * @url POST {id}/markAsCreditAvailable * - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 - */ - public function getPayments($id) - { - - if (!DolibarrApiAccess::$user->rights->facture->lire) { - throw new RestException(401); - } - if (empty($id)) { - throw new RestException(400, 'Invoice ID is mandatory'); - } - - if (!DolibarrApi::_checkAccessToResource('facture', $id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } - - $result = $this->invoice->getListOfPayments(); - if ($result < 0) { - throw new RestException(405, $this->invoice->error); - } - - return $result; - } - - - /** - * Add payment line to a specific invoice with the remain to pay as amount. - * - * @param int $id Id of invoice - * @param string $datepaye {@from body} Payment date {@type timestamp} - * @param int $paymentid {@from body} Payment mode Id {@min 1} - * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} - * @param int $accountid {@from body} Account Id {@min 1} - * @param string $num_payment {@from body} Payment number (optional) - * @param string $comment {@from body} Note private (optional) - * @param string $chqemetteur {@from body} Payment issuer (mandatory if paymentcode = 'CHQ') - * @param string $chqbank {@from body} Issuer bank name (optional) - * - * @url POST {id}/payments - * - * @return int Payment ID + * @return array An invoice object * - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - */ - public function addPayment($id, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') - { - global $conf; + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 + */ + public function markAsCreditAvailable($id) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(403); - } - if (empty($id)) { - throw new RestException(400, 'Invoice ID is mandatory'); - } + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - if (!DolibarrApi::_checkAccessToResource('facture', $id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!empty($conf->banque->enabled)) { - if (empty($accountid)) { - throw new RestException(400, 'Account ID is mandatory'); - } - } + if ($this->invoice->paye) { + throw new RestException(500, 'Alreay payed'); + } - if (empty($paymentid)) { - throw new RestException(400, 'Payment ID or Payment Code is mandatory'); - } + $this->invoice->fetch($id); + $this->invoice->fetch_thirdparty(); + + // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) + $discountcheck = new DiscountAbsolute($this->db); + $result = $discountcheck->fetch(0, $this->invoice->id); + + $canconvert = 0; + if ($this->invoice->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) + if (($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_STANDARD) && $this->invoice->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + if ($canconvert) + { + $this->db->begin(); + + $amount_ht = $amount_tva = $amount_ttc = array(); + $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array(); + + // Loop on each vat rate + $i = 0; + foreach ($this->invoice->lines as $line) + { + if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 + { // no need to create discount if amount is null + $amount_ht[$line->tva_tx] += $line->total_ht; + $amount_tva[$line->tva_tx] += $line->total_tva; + $amount_ttc[$line->tva_tx] += $line->total_ttc; + $multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht; + $multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva; + $multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc; + $i++; + } + } + + // Insert one discount by VAT rate category + $discount = new DiscountAbsolute($this->db); + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $discount->description = '(CREDIT_NOTE)'; + } elseif ($this->invoice->type == Facture::TYPE_DEPOSIT) { + $discount->description = '(DEPOSIT)'; + } elseif ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION) { + $discount->description = '(EXCESS RECEIVED)'; + } else { + throw new RestException(500, 'Cant convert to reduc an Invoice of this type'); + } + + $discount->fk_soc = $this->invoice->socid; + $discount->fk_facture_source = $this->invoice->id; + + $error = 0; + + if ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION) + { + // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT + + // Total payments + $sql = 'SELECT SUM(pf.amount) as total_payments'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql .= ' WHERE pf.fk_facture = '.$this->invoice->id; + $sql .= ' AND pf.fk_paiement = p.rowid'; + $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; + $resql = $this->db->query($sql); + if (!$resql) dol_print_error($this->db); + + $res = $this->db->fetch_object($resql); + $total_payments = $res->total_payments; + + // Total credit note and deposit + $total_creditnote_and_deposit = 0; + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_facture_source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_facture = ".$this->invoice->id; + $resql = $this->db->query($sql); + if (!empty($resql)) { + while ($obj = $this->db->fetch_object($resql)) $total_creditnote_and_deposit += $obj->amount_ttc; + } else dol_print_error($this->db); + + $discount->amount_ht = $discount->amount_ttc = $total_payments + $total_creditnote_and_deposit - $this->invoice->total_ttc; + $discount->amount_tva = 0; + $discount->tva_tx = 0; + + $result = $discount->create(DolibarrApiAccess::$user); + if ($result < 0) + { + $error++; + } + } + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_DEPOSIT) + { + foreach ($amount_ht as $tva_tx => $xxx) + { + $discount->amount_ht = abs($amount_ht[$tva_tx]); + $discount->amount_tva = abs($amount_tva[$tva_tx]); + $discount->amount_ttc = abs($amount_ttc[$tva_tx]); + $discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]); + $discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]); + $discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]); + $discount->tva_tx = abs($tva_tx); + + $result = $discount->create(DolibarrApiAccess::$user); + if ($result < 0) + { + $error++; + break; + } + } + } + + if (empty($error)) + { + if ($this->invoice->type != Facture::TYPE_DEPOSIT) { + // Classe facture + $result = $this->invoice->set_paid(DolibarrApiAccess::$user); + if ($result >= 0) + { + $this->db->commit(); + } else { + $this->db->rollback(); + throw new RestException(500, 'Could not set paid'); + } + } else { + $this->db->commit(); + } + } else { + $this->db->rollback(); + throw new RestException(500, 'Discount creation error'); + } + } + + return $this->_cleanObjectDatas($this->invoice); + } + + /** + * Add a discount line into an invoice (as an invoice line) using an existing absolute discount + * + * Note that this consume the discount. + * + * @param int $id Id of invoice + * @param int $discountid Id of discount + * + * @url POST {id}/usediscount/{discountid} + * + * @return int + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 + */ + public function useDiscount($id, $discountid) + { + + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + if (empty($id)) { + throw new RestException(400, 'Invoice ID is mandatory'); + } + if (empty($discountid)) { + throw new RestException(400, 'Discount ID is mandatory'); + } + + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } + + $result = $this->invoice->insert_discount($discountid); + if ($result < 0) { + throw new RestException(405, $this->invoice->error); + } + + return $result; + } + + /** + * Add an available credit note discount to payments of an existing invoice. + * + * Note that this consume the credit note. + * + * @param int $id Id of invoice + * @param int $discountid Id of a discount coming from a credit note + * + * @url POST {id}/usecreditnote/{discountid} + * + * @return int + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 + */ + public function useCreditNote($id, $discountid) + { + + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + if (empty($id)) { + throw new RestException(400, 'Invoice ID is mandatory'); + } + if (empty($discountid)) { + throw new RestException(400, 'Credit ID is mandatory'); + } + + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $discount = new DiscountAbsolute($this->db); + $result = $discount->fetch($discountid); + if (!$result) { + throw new RestException(404, 'Credit not found'); + } + + $result = $discount->link_to_invoice(0, $id); + if ($result < 0) { + throw new RestException(405, $discount->error); + } + + return $result; + } + + /** + * Get list of payments of a given invoice + * + * @param int $id Id of invoice + * + * @url GET {id}/payments + * + * @return array + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 + */ + public function getPayments($id) + { + + if (!DolibarrApiAccess::$user->rights->facture->lire) { + throw new RestException(401); + } + if (empty($id)) { + throw new RestException(400, 'Invoice ID is mandatory'); + } + + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } + + $result = $this->invoice->getListOfPayments(); + if ($result < 0) { + throw new RestException(405, $this->invoice->error); + } + + return $result; + } - $result = $this->invoice->fetch($id); - if (!$result) { - throw new RestException(404, 'Invoice not found'); - } + /** + * Add payment line to a specific invoice with the remain to pay as amount. + * + * @param int $id Id of invoice + * @param string $datepaye {@from body} Payment date {@type timestamp} + * @param int $paymentid {@from body} Payment mode Id {@min 1} + * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} + * @param int $accountid {@from body} Account Id {@min 1} + * @param string $num_payment {@from body} Payment number (optional) + * @param string $comment {@from body} Note private (optional) + * @param string $chqemetteur {@from body} Payment issuer (mandatory if paymentcode = 'CHQ') + * @param string $chqbank {@from body} Issuer bank name (optional) + * + * @url POST {id}/payments + * + * @return int Payment ID + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + */ + public function addPayment($id, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') + { + global $conf; - // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement(); - $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); - $totaldeposits = $this->invoice->getSumDepositsUsed(); - $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - $this->db->begin(); + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(403); + } + if (empty($id)) { + throw new RestException(400, 'Invoice ID is mandatory'); + } - $amounts = array(); - $multicurrency_amounts = array(); + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - // Clean parameters amount if payment is for a credit note - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { - $resteapayer = price2num($resteapayer, 'MT'); - $amounts[$id] = -$resteapayer; - // Multicurrency - $newvalue = price2num($this->invoice->multicurrency_total_ttc, 'MT'); - $multicurrency_amounts[$id] = -$newvalue; - } else { - $resteapayer = price2num($resteapayer, 'MT'); - $amounts[$id] = $resteapayer; - // Multicurrency - $newvalue = price2num($this->invoice->multicurrency_total_ttc, 'MT'); - $multicurrency_amounts[$id] = $newvalue; - } + if (!empty($conf->banque->enabled)) { + if (empty($accountid)) { + throw new RestException(400, 'Account ID is mandatory'); + } + } + + if (empty($paymentid)) { + throw new RestException(400, 'Payment ID or Payment Code is mandatory'); + } - // Creation of payment line - $paymentobj = new Paiement($this->db); - $paymentobj->datepaye = $datepaye; - $paymentobj->amounts = $amounts; // Array with all payments dispatching with invoice id - $paymentobj->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paymentobj->paiementid = $paymentid; - $paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); - $paymentobj->num_payment = $num_payment; - $paymentobj->note_private = $comment; + $result = $this->invoice->fetch($id); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } - $payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices - if ($payment_id < 0) - { - $this->db->rollback(); - throw new RestException(400, 'Payment error : '.$paymentobj->error); - } + // Calculate amount to pay + $totalpaye = $this->invoice->getSommePaiement(); + $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); + $totaldeposits = $this->invoice->getSumDepositsUsed(); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - if (!empty($conf->banque->enabled)) { - $label = '(CustomerInvoicePayment)'; + $this->db->begin(); - if ($paymentobj->paiementcode == 'CHQ' && empty($chqemetteur)) { - throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paymentobj->paiementcode); - } - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note - $result = $paymentobj->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); - if ($result < 0) - { - $this->db->rollback(); - throw new RestException(400, 'Add payment to bank error : '.$paymentobj->error); - } - } + $amounts = array(); + $multicurrency_amounts = array(); - $this->db->commit(); + // Clean parameters amount if payment is for a credit note + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $resteapayer = price2num($resteapayer, 'MT'); + $amounts[$id] = -$resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc, 'MT'); + $multicurrency_amounts[$id] = -$newvalue; + } else { + $resteapayer = price2num($resteapayer, 'MT'); + $amounts[$id] = $resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc, 'MT'); + $multicurrency_amounts[$id] = $newvalue; + } - return $payment_id; - } - /** - * Add a payment to pay partially or completely one or several invoices. - * Warning: Take care that all invoices are owned by the same customer. - * Example of value for parameter arrayofamounts: {"1": {"amount": "99.99", "multicurrency_amount": ""}, "2": {"amount": "", "multicurrency_amount": "10"}} - * - * @param array $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice - * @param string $datepaye {@from body} Payment date {@type timestamp} - * @param int $paymentid {@from body} Payment mode Id {@min 1} - * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} - * @param int $accountid {@from body} Account Id {@min 1} - * @param string $num_payment {@from body} Payment number (optional) - * @param string $comment {@from body} Note private (optional) - * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') - * @param string $chqbank {@from body} Issuer bank name (optional) - * @param string $ref_ext {@from body} External reference (optional) - * @param bool $accepthigherpayment {@from body} Accept higher payments that it remains to be paid (optional) - * - * @url POST /paymentsdistributed - * - * @return int Payment ID - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 403 - * @throws RestException 404 - */ - public function addPaymentDistributed($arrayofamounts, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '', $ref_ext = '', $accepthigherpayment = false) - { - global $conf; + // Creation of payment line + $paymentobj = new Paiement($this->db); + $paymentobj->datepaye = $datepaye; + $paymentobj->amounts = $amounts; // Array with all payments dispatching with invoice id + $paymentobj->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paymentobj->paiementid = $paymentid; + $paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); + $paymentobj->num_payment = $num_payment; + $paymentobj->note_private = $comment; - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + $payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices + if ($payment_id < 0) + { + $this->db->rollback(); + throw new RestException(400, 'Payment error : '.$paymentobj->error); + } - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(403); - } - foreach ($arrayofamounts as $id => $amount) { - if (empty($id)) { - throw new RestException(400, 'Invoice ID is mandatory. Fill the invoice id and amount into arrayofamounts parameter. For example: {"1": "99.99", "2": "10"}'); - } - if (!DolibarrApi::_checkAccessToResource('facture', $id)) { - throw new RestException(403, 'Access not allowed on invoice ID '.$id.' for login '.DolibarrApiAccess::$user->login); - } - } + if (!empty($conf->banque->enabled)) { + $label = '(CustomerInvoicePayment)'; - if (!empty($conf->banque->enabled)) { - if (empty($accountid)) { - throw new RestException(400, 'Account ID is mandatory'); - } - } - if (empty($paymentid)) { - throw new RestException(400, 'Payment ID or Payment Code is mandatory'); - } + if ($paymentobj->paiementcode == 'CHQ' && empty($chqemetteur)) { + throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paymentobj->paiementcode); + } + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result = $paymentobj->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); + if ($result < 0) + { + $this->db->rollback(); + throw new RestException(400, 'Add payment to bank error : '.$paymentobj->error); + } + } - $this->db->begin(); + $this->db->commit(); - $amounts = array(); - $multicurrency_amounts = array(); + return $payment_id; + } - // Loop on each invoice to pay - foreach ($arrayofamounts as $id => $amountarray) - { - $result = $this->invoice->fetch($id); - if (!$result) { - $this->db->rollback(); - throw new RestException(404, 'Invoice ID '.$id.' not found'); - } + /** + * Add a payment to pay partially or completely one or several invoices. + * Warning: Take care that all invoices are owned by the same customer. + * Example of value for parameter arrayofamounts: {"1": {"amount": "99.99", "multicurrency_amount": ""}, "2": {"amount": "", "multicurrency_amount": "10"}} + * + * @param array $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice + * @param string $datepaye {@from body} Payment date {@type timestamp} + * @param int $paymentid {@from body} Payment mode Id {@min 1} + * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} + * @param int $accountid {@from body} Account Id {@min 1} + * @param string $num_payment {@from body} Payment number (optional) + * @param string $comment {@from body} Note private (optional) + * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') + * @param string $chqbank {@from body} Issuer bank name (optional) + * @param string $ref_ext {@from body} External reference (optional) + * @param bool $accepthigherpayment {@from body} Accept higher payments that it remains to be paid (optional) + * + * @url POST /paymentsdistributed + * + * @return int Payment ID + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 + */ + public function addPaymentDistributed($arrayofamounts, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '', $ref_ext = '', $accepthigherpayment = false) + { + global $conf; - if (($amountarray["amount"] == "remain" || $amountarray["amount"] > 0) && ($amountarray["multicurrency_amount"] == "remain" || $amountarray["multicurrency_amount"] > 0)) { - $this->db->rollback(); - throw new RestException(400, 'Payment in both currency '.$id.' ( amount: '.$amountarray["amount"].', multicurrency_amount: '.$amountarray["multicurrency_amount"].')'); - } + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - $is_multicurrency = 0; - $total_ttc = $this->invoice->total_ttc; + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(403); + } + foreach ($arrayofamounts as $id => $amount) { + if (empty($id)) { + throw new RestException(400, 'Invoice ID is mandatory. Fill the invoice id and amount into arrayofamounts parameter. For example: {"1": "99.99", "2": "10"}'); + } + if (!DolibarrApi::_checkAccessToResource('facture', $id)) { + throw new RestException(403, 'Access not allowed on invoice ID '.$id.' for login '.DolibarrApiAccess::$user->login); + } + } - if ($amountarray["multicurrency_amount"] > 0 || $amountarray["multicurrency_amount"] == "remain") { - $is_multicurrency = 1; - $total_ttc = $this->invoice->multicurrency_total_ttc; - } + if (!empty($conf->banque->enabled)) { + if (empty($accountid)) { + throw new RestException(400, 'Account ID is mandatory'); + } + } + if (empty($paymentid)) { + throw new RestException(400, 'Payment ID or Payment Code is mandatory'); + } - // Calculate amount to pay - $totalpaye = $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'); + $this->db->begin(); - if (!$is_multicurrency && $amountarray["amount"] != 'remain') - { - $amount = price2num($amountarray["amount"], 'MT'); - } + $amounts = array(); + $multicurrency_amounts = array(); - if ($is_multicurrency && $amountarray["multicurrency_amount"] != 'remain') - { - $amount = price2num($amountarray["multicurrency_amount"], 'MT'); - } + // Loop on each invoice to pay + foreach ($arrayofamounts as $id => $amountarray) + { + $result = $this->invoice->fetch($id); + if (!$result) { + $this->db->rollback(); + throw new RestException(404, 'Invoice ID '.$id.' not found'); + } + + if (($amountarray["amount"] == "remain" || $amountarray["amount"] > 0) && ($amountarray["multicurrency_amount"] == "remain" || $amountarray["multicurrency_amount"] > 0)) { + $this->db->rollback(); + throw new RestException(400, 'Payment in both currency '.$id.' ( amount: '.$amountarray["amount"].', multicurrency_amount: '.$amountarray["multicurrency_amount"].')'); + } + + $is_multicurrency = 0; + $total_ttc = $this->invoice->total_ttc; + + if ($amountarray["multicurrency_amount"] > 0 || $amountarray["multicurrency_amount"] == "remain") { + $is_multicurrency = 1; + $total_ttc = $this->invoice->multicurrency_total_ttc; + } + + // Calculate amount to pay + $totalpaye = $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'); + + if (!$is_multicurrency && $amountarray["amount"] != 'remain') + { + $amount = price2num($amountarray["amount"], 'MT'); + } + + if ($is_multicurrency && $amountarray["multicurrency_amount"] != 'remain') + { + $amount = price2num($amountarray["multicurrency_amount"], 'MT'); + } if ($amount > $remainstopay && !$accepthigherpayment) { $this->db->rollback(); - throw new RestException(400, 'Payment amount on invoice ID '.$id.' ('.$amount.') is higher than remain to pay ('.$remainstopay.')'); + throw new RestException(400, 'Payment amount on invoice ID '.$id.' ('.$amount.') is higher than remain to pay ('.$remainstopay.')'); } - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { - $amount = -$amount; - } + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $amount = -$amount; + } - if ($is_multicurrency) { - $amounts[$id] = null; - // Multicurrency - $multicurrency_amounts[$id] = $amount; - } else { - $amounts[$id] = $amount; - // Multicurrency - $multicurrency_amounts[$id] = null; - } - } + if ($is_multicurrency) { + $amounts[$id] = null; + // Multicurrency + $multicurrency_amounts[$id] = $amount; + } else { + $amounts[$id] = $amount; + // Multicurrency + $multicurrency_amounts[$id] = null; + } + } - // Creation of payment line - $paymentobj = new Paiement($this->db); - $paymentobj->datepaye = $datepaye; - $paymentobj->amounts = $amounts; // Array with all payments dispatching with invoice id - $paymentobj->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paymentobj->paiementid = $paymentid; - $paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); - $paymentobj->num_payment = $num_payment; - $paymentobj->note_private = $comment; - $paymentobj->ref_ext = $ref_ext; - $payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices - if ($payment_id < 0) - { - $this->db->rollback(); - throw new RestException(400, 'Payment error : '.$paymentobj->error); - } - if (!empty($conf->banque->enabled)) { - $label = '(CustomerInvoicePayment)'; - if ($paymentobj->paiementcode == 'CHQ' && empty($chqemetteur)) { - throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paymentobj->paiementcode); - } - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note - $result = $paymentobj->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); - if ($result < 0) - { - $this->db->rollback(); - throw new RestException(400, 'Add payment to bank error : '.$paymentobj->error); - } - } + // Creation of payment line + $paymentobj = new Paiement($this->db); + $paymentobj->datepaye = $datepaye; + $paymentobj->amounts = $amounts; // Array with all payments dispatching with invoice id + $paymentobj->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paymentobj->paiementid = $paymentid; + $paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); + $paymentobj->num_payment = $num_payment; + $paymentobj->note_private = $comment; + $paymentobj->ref_ext = $ref_ext; + $payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices + if ($payment_id < 0) + { + $this->db->rollback(); + throw new RestException(400, 'Payment error : '.$paymentobj->error); + } + if (!empty($conf->banque->enabled)) { + $label = '(CustomerInvoicePayment)'; + if ($paymentobj->paiementcode == 'CHQ' && empty($chqemetteur)) { + throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paymentobj->paiementcode); + } + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result = $paymentobj->addPaymentToBank(DolibarrApiAccess::$user, 'payment', $label, $accountid, $chqemetteur, $chqbank); + if ($result < 0) + { + $this->db->rollback(); + throw new RestException(400, 'Add payment to bank error : '.$paymentobj->error); + } + } - $this->db->commit(); + $this->db->commit(); - return $payment_id; - } + return $payment_id; + } - /** - * Update a payment - * - * @param int $id Id of payment - * @param string $num_payment Payment number - * - * @url PUT payments/{id} - * - * @return array + /** + * Update a payment + * + * @param int $id Id of payment + * @param string $num_payment Payment number + * + * @url PUT payments/{id} + * + * @return array * @throws RestException 400 Bad parameters * @throws RestException 401 Not allowed * @throws RestException 404 Not found - */ - public function putPayment($id, $num_payment = '') - { - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + */ + public function putPayment($id, $num_payment = '') + { + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - if (!DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - if (empty($id)) { - throw new RestException(400, 'Payment ID is mandatory'); - } + if (!DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + if (empty($id)) { + throw new RestException(400, 'Payment ID is mandatory'); + } - $paymentobj = new Paiement($this->db); - $result = $paymentobj->fetch($id); + $paymentobj = new Paiement($this->db); + $result = $paymentobj->fetch($id); - if (!$result) { - throw new RestException(404, 'Payment not found'); - } + if (!$result) { + throw new RestException(404, 'Payment not found'); + } - if (!empty($num_payment)) { - $result = $paymentobj->update_num($num_payment); - if ($result < 0) { - throw new RestException(500, 'Error when updating the payment num'); - } - } + if (!empty($num_payment)) { + $result = $paymentobj->update_num($num_payment); + if ($result < 0) { + throw new RestException(500, 'Error when updating the payment num'); + } + } - return [ - 'success' => [ - 'code' => 200, - 'message' => 'Payment updated' - ] - ]; - } + return [ + 'success' => [ + 'code' => 200, + 'message' => 'Payment updated' + ] + ]; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param object $object Object to clean - * @return array Array of cleaned object properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - unset($object->note); - unset($object->address); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); + unset($object->note); + unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); - return $object; - } + return $object; + } - /** - * Validate fields before create or update object - * - * @param array|null $data Datas to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $invoice = array(); - foreach (Invoices::$FIELDS as $field) { - if (!isset($data[$field])) { - throw new RestException(400, "$field field missing"); - } - $invoice[$field] = $data[$field]; - } - return $invoice; - } + /** + * Validate fields before create or update object + * + * @param array|null $data Datas to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $invoice = array(); + foreach (Invoices::$FIELDS as $field) { + if (!isset($data[$field])) { + throw new RestException(400, "$field field missing"); + } + $invoice[$field] = $data[$field]; + } + return $invoice; + } } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index d1a6abcdec3..e4187a4e906 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -97,7 +97,7 @@ class FactureRec extends CommonInvoice */ public $frequency; - /** + /** * @var string Unit frequency */ public $unit_frequency; @@ -317,46 +317,46 @@ class FactureRec extends CommonInvoice $tva_tx = $facsrc->lines[$i]->tva_tx; if (!empty($facsrc->lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; - $result_insert = $this->addline( - $facsrc->lines[$i]->desc, - $facsrc->lines[$i]->subprice, - $facsrc->lines[$i]->qty, + $result_insert = $this->addline( + $facsrc->lines[$i]->desc, + $facsrc->lines[$i]->subprice, + $facsrc->lines[$i]->qty, $tva_tx, - $facsrc->lines[$i]->localtax1_tx, - $facsrc->lines[$i]->localtax2_tx, - $facsrc->lines[$i]->fk_product, - $facsrc->lines[$i]->remise_percent, - 'HT', + $facsrc->lines[$i]->localtax1_tx, + $facsrc->lines[$i]->localtax2_tx, + $facsrc->lines[$i]->fk_product, + $facsrc->lines[$i]->remise_percent, + 'HT', $facsrc->lines[$i]->info_bits, - '', - 0, - $facsrc->lines[$i]->product_type, - $facsrc->lines[$i]->rang, - $facsrc->lines[$i]->special_code, - $facsrc->lines[$i]->label, + '', + 0, + $facsrc->lines[$i]->product_type, + $facsrc->lines[$i]->rang, + $facsrc->lines[$i]->special_code, + $facsrc->lines[$i]->label, $facsrc->lines[$i]->fk_unit, $facsrc->lines[$i]->multicurrency_subprice - ); + ); if ($result_insert < 0) { $error++; } else { - $objectline = new FactureLigneRec($this->db); - if ($objectline->fetch($result_insert)) - { - // Extrafields - if (method_exists($facsrc->lines[$i], 'fetch_optionals')) { - $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->rowid); - $objectline->array_options = $facsrc->lines[$i]->array_options; - } + $objectline = new FactureLigneRec($this->db); + if ($objectline->fetch($result_insert)) + { + // Extrafields + if (method_exists($facsrc->lines[$i], 'fetch_optionals')) { + $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->rowid); + $objectline->array_options = $facsrc->lines[$i]->array_options; + } - $result = $objectline->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + $result = $objectline->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } } } @@ -370,27 +370,27 @@ class FactureRec extends CommonInvoice { foreach ($this->linked_objects as $origin => $tmp_origin_id) { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - { - $origin_id = $tmp_origin_id; - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach ($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + { + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } } } @@ -422,7 +422,7 @@ class FactureRec extends CommonInvoice return $this->id; } } else { - $this->error = $this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -442,46 +442,46 @@ class FactureRec extends CommonInvoice */ public function update(User $user, $notrigger = 0) { - global $conf; + global $conf; - $error = 0; + $error = 0; - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; - $sql .= " fk_soc = ".$this->fk_soc; - // TODO Add missing fields - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; + $sql .= " fk_soc = ".$this->fk_soc; + // TODO Add missing fields + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('BILLREC_UPDATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } - // End call triggers - } - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -2; - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('BILLREC_UPDATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + } + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } } /** @@ -498,13 +498,13 @@ class FactureRec extends CommonInvoice $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; $sql .= ', f.date_lim_reglement as dlr'; $sql .= ', f.note_private, f.note_public, f.fk_user_author'; - $sql .= ', f.modelpdf'; + $sql .= ', f.modelpdf as model_pdf'; $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project'; $sql .= ', f.fk_account'; $sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; - $sql .= ', f.generate_pdf'; - $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; - $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= ', f.generate_pdf'; + $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; //$sql.= ', el.fk_source'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f'; @@ -562,7 +562,8 @@ class FactureRec extends CommonInvoice $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->user_author = $obj->fk_user_author; - $this->modelpdf = $obj->modelpdf; + $this->modelpdf = $obj->model_pdf; // deprecatd + $this->model_pdf = $obj->model_pdf; $this->rang = $obj->rang; $this->special_code = $obj->special_code; $this->frequency = $obj->frequency; @@ -585,7 +586,7 @@ class FactureRec extends CommonInvoice if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; - // Retreive all extrafield + // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); @@ -618,24 +619,24 @@ class FactureRec extends CommonInvoice */ public function getLinesArray() { - return $this->fetch_lines(); + return $this->fetch_lines(); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get lines of template invoices into this->lines * * @return int 1 if OK, < 0 if KO - */ + */ public function fetch_lines() { global $extrafields; - // phpcs:enable + // phpcs:enable $this->lines = array(); - // Retreive all extrafield for line + // Retrieve all extrafield for line // fetch optionals attributes and labels if (!is_object($extrafields)) { @@ -710,7 +711,7 @@ class FactureRec extends CommonInvoice $line->rang = $objp->rang; $line->special_code = $objp->special_code; $line->fk_unit = $objp->fk_unit; - $line->fk_contract_line = $objp->fk_contract_line; + $line->fk_contract_line = $objp->fk_contract_line; // Ne plus utiliser $line->price = $objp->price; @@ -750,17 +751,17 @@ class FactureRec extends CommonInvoice */ public function delete(User $user, $notrigger = 0, $idwarehouse = -1) { - $rowid = $this->id; + $rowid = $this->id; - dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); + dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); - $error = 0; + $error = 0; $this->db->begin(); $main = MAIN_DB_PREFIX.'facturedet_rec'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)"; - dol_syslog($sqlef); + $ef = $main."_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)"; + dol_syslog($sqlef); $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; dol_syslog($sql); if ($this->db->query($sqlef) && $this->db->query($sql)) @@ -773,8 +774,8 @@ class FactureRec extends CommonInvoice $res = $this->deleteObjectLinked(); if ($res < 0) $error = -3; // Delete extrafields - $res = $this->deleteExtraFields(); - if ($res < 0) $error = -4; + $res = $this->deleteExtraFields(); + if ($res < 0) $error = -4; } else { $this->error = $this->db->lasterror(); $error = -1; @@ -786,11 +787,11 @@ class FactureRec extends CommonInvoice if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - $this->db->rollback(); - return $error; + $this->db->rollback(); + return $error; } } @@ -798,33 +799,33 @@ class FactureRec extends CommonInvoice /** * Add a line to invoice * - * @param string $desc Description de la ligne - * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) - * @param double $qty Quantite - * @param double $txtva Taux de tva force, sinon -1 + * @param string $desc Description de la ligne + * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) + * @param double $qty Quantite + * @param double $txtva Taux de tva force, sinon -1 * @param double $txlocaltax1 Local tax 1 rate (deprecated) * @param double $txlocaltax2 Local tax 2 rate (deprecated) - * @param int $fk_product Product/Service ID predefined - * @param double $remise_percent Percentage discount of the line - * @param string $price_base_type HT or TTC - * @param int $info_bits VAT npr or not ? - * @param int $fk_remise_except Id remise - * @param double $pu_ttc Prix unitaire TTC (> 0 even for credit note) - * @param int $type Type of line (0=product, 1=service) - * @param int $rang Position of line - * @param int $special_code Special code - * @param string $label Label of the line - * @param string $fk_unit Unit + * @param int $fk_product Product/Service ID predefined + * @param double $remise_percent Percentage discount of the line + * @param string $price_base_type HT or TTC + * @param int $info_bits VAT npr or not ? + * @param int $fk_remise_except Id remise + * @param double $pu_ttc Prix unitaire TTC (> 0 even for credit note) + * @param int $type Type of line (0=product, 1=service) + * @param int $rang Position of line + * @param int $special_code Special code + * @param string $label Label of the line + * @param string $fk_unit Unit * @param double $pu_ht_devise Unit price in currency * @param int $date_start_fill 1=Flag to fill start date when generating invoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @param int $fk_fournprice Supplier price id (to calculate margin) or '' * @param int $pa_ht Buying price of line (to calculate margin) or '' - * @return int <0 if KO, Id of line if OK + * @return int <0 if KO, Id of line if OK */ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0) { - global $mysoc; + global $mysoc; $facid = $this->id; @@ -1008,131 +1009,131 @@ class FactureRec extends CommonInvoice */ public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0) { - global $mysoc; + global $mysoc; - $facid = $this->id; + $facid = $this->id; - dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); - include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - // Clean parameters - if (empty($remise_percent)) $remise_percent = 0; + // Clean parameters + if (empty($remise_percent)) $remise_percent = 0; - // Check parameters - if ($type < 0) return -1; + // Check parameters + if ($type < 0) return -1; - if ($this->brouillon) - { - // Clean parameters - $remise_percent = price2num($remise_percent); - $qty = price2num($qty); - if (empty($info_bits)) $info_bits = 0; - $pu_ht = price2num($pu_ht); - $pu_ttc = price2num($pu_ttc); - $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); - $txlocaltax2 = price2num($txlocaltax2); - if (empty($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2)) $txlocaltax2 = 0; + if ($this->brouillon) + { + // Clean parameters + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + if (empty($info_bits)) $info_bits = 0; + $pu_ht = price2num($pu_ht); + $pu_ttc = price2num($pu_ttc); + $pu_ht_devise = price2num($pu_ht_devise); + $txtva = price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; - if ($price_base_type == 'HT') - { - $pu = $pu_ht; - } else { - $pu = $pu_ttc; - } + if ($price_base_type == 'HT') + { + $pu = $pu_ht; + } else { + $pu = $pu_ttc; + } - // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); - // Clean vat code - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + // Clean vat code + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); - $total_ht = $tabprice[0]; - $total_tva = $tabprice[1]; - $total_ttc = $tabprice[2]; - $total_localtax1 = $tabprice[9]; - $total_localtax2 = $tabprice[10]; - $pu_ht = $tabprice[3]; - $pu_tva = $tabprice[4]; - $pu_ttc = $tabprice[5]; + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; + $pu_ht = $tabprice[3]; + $pu_tva = $tabprice[4]; + $pu_ttc = $tabprice[5]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; - $multicurrency_total_tva = $tabprice[17]; - $multicurrency_total_ttc = $tabprice[18]; - $pu_ht_devise = $tabprice[19]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + $pu_ht_devise = $tabprice[19]; - $product_type = $type; - if ($fk_product) - { - $product = new Product($this->db); - $result = $product->fetch($fk_product); - $product_type = $product->type; - } + $product_type = $type; + if ($fk_product) + { + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; + } - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; - $sql .= "fk_facture = ".((int) $facid); - $sql .= ", label=".(!empty($label) ? "'".$this->db->escape($label)."'" : "null"); - $sql .= ", description='".$this->db->escape($desc)."'"; - $sql .= ", price=".price2num($pu_ht); - $sql .= ", qty=".price2num($qty); - $sql .= ", tva_tx=".price2num($txtva); - $sql .= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; - $sql .= ", localtax1_tx=".$txlocaltax1; - $sql .= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; - $sql .= ", localtax2_tx=".$txlocaltax2; - $sql .= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; - $sql .= ", fk_product=".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null"); - $sql .= ", product_type=".$product_type; - $sql .= ", remise_percent='".price2num($remise_percent)."'"; - $sql .= ", subprice='".price2num($pu_ht)."'"; - $sql .= ", total_ht='".price2num($total_ht)."'"; - $sql .= ", total_tva='".price2num($total_tva)."'"; - $sql .= ", total_localtax1='".price2num($total_localtax1)."'"; - $sql .= ", total_localtax2='".price2num($total_localtax2)."'"; - $sql .= ", total_ttc='".price2num($total_ttc)."'"; - $sql .= ", date_start_fill=".((int) $date_start_fill); - $sql .= ", date_end_fill=".((int) $date_end_fill); - $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null'); - $sql .= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0); - $sql .= ", info_bits=".$info_bits; - $sql .= ", rang=".$rang; - $sql .= ", special_code=".$special_code; - $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); - $sql .= ', multicurrency_subprice = '.$pu_ht_devise; - $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht; - $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva; - $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; - $sql .= " WHERE rowid = ".$rowid; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; + $sql .= "fk_facture = ".((int) $facid); + $sql .= ", label=".(!empty($label) ? "'".$this->db->escape($label)."'" : "null"); + $sql .= ", description='".$this->db->escape($desc)."'"; + $sql .= ", price=".price2num($pu_ht); + $sql .= ", qty=".price2num($qty); + $sql .= ", tva_tx=".price2num($txtva); + $sql .= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; + $sql .= ", localtax1_tx=".$txlocaltax1; + $sql .= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; + $sql .= ", localtax2_tx=".$txlocaltax2; + $sql .= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; + $sql .= ", fk_product=".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null"); + $sql .= ", product_type=".$product_type; + $sql .= ", remise_percent='".price2num($remise_percent)."'"; + $sql .= ", subprice='".price2num($pu_ht)."'"; + $sql .= ", total_ht='".price2num($total_ht)."'"; + $sql .= ", total_tva='".price2num($total_tva)."'"; + $sql .= ", total_localtax1='".price2num($total_localtax1)."'"; + $sql .= ", total_localtax2='".price2num($total_localtax2)."'"; + $sql .= ", total_ttc='".price2num($total_ttc)."'"; + $sql .= ", date_start_fill=".((int) $date_start_fill); + $sql .= ", date_end_fill=".((int) $date_end_fill); + $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null'); + $sql .= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0); + $sql .= ", info_bits=".$info_bits; + $sql .= ", rang=".$rang; + $sql .= ", special_code=".$special_code; + $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); + $sql .= ', multicurrency_subprice = '.$pu_ht_devise; + $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht; + $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva; + $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; + $sql .= " WHERE rowid = ".$rowid; - dol_syslog(get_class($this)."::updateline", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->id = $facid; - $this->update_price(); - return 1; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->id = $facid; + $this->update_price(); + return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } } @@ -1328,8 +1329,8 @@ class FactureRec extends CommonInvoice * @param int $max Maxlength of ref * @param int $short 1=Return just URL * @param string $moretitle Add more text to title tooltip - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) @@ -1356,17 +1357,17 @@ class FactureRec extends CommonInvoice } } - $url = DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$this->id; + $url = DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$this->id; - if ($short) return $url; + if ($short) return $url; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } $linkstart = ''; $linkend = ''; @@ -1391,7 +1392,7 @@ class FactureRec extends CommonInvoice return $this->LibStatut($this->frequency ? 1 : 0, $this->suspended, $mode, $alreadypaid, empty($this->type) ? 0 : $this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1404,7 +1405,7 @@ class FactureRec extends CommonInvoice */ public function LibStatut($recur, $status, $mode = 0, $alreadypaid = -1, $type = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load('bills'); @@ -1553,7 +1554,7 @@ class FactureRec extends CommonInvoice $arraynow = dol_getdate($now); $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - // Load array of products prodids + // Load array of products prodids $num_prods = 0; $prodids = array(); @@ -1690,190 +1691,190 @@ class FactureRec extends CommonInvoice } /** - * Update frequency and unit - * - * @param int $frequency value of frequency - * @param string $unit unit of frequency (d, m, y) - * @return int <0 if KO, >0 if OK - */ - public function setFrequencyAndUnit($frequency, $unit) - { - if (!$this->table_element) { - dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); - return -1; - } - - if (!empty($frequency) && empty($unit)) { - dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined", LOG_ERR); - return -2; - } - - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); - if (!empty($unit)) { - $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; + * Update frequency and unit + * + * @param int $frequency value of frequency + * @param string $unit unit of frequency (d, m, y) + * @return int <0 if KO, >0 if OK + */ + public function setFrequencyAndUnit($frequency, $unit) + { + if (!$this->table_element) { + dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); + return -1; } - $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); - if ($this->db->query($sql)) { - $this->frequency = $frequency; - if (!empty($unit)) $this->unit_frequency = $unit; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + if (!empty($frequency) && empty($unit)) { + dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined", LOG_ERR); + return -2; + } + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); + if (!empty($unit)) { + $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; + } + $sql .= ' WHERE rowid = '.$this->id; + + dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); + if ($this->db->query($sql)) { + $this->frequency = $frequency; + if (!empty($unit)) $this->unit_frequency = $unit; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } /** - * Update the next date of execution - * - * @param datetime $date date of execution - * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done - * @return int <0 if KO, >0 if OK - */ - public function setNextDate($date, $increment_nb_gen_done = 0) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); - return -1; - } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); - if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1'; - $sql .= ' WHERE rowid = '.$this->id; + * Update the next date of execution + * + * @param datetime $date date of execution + * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done + * @return int <0 if KO, >0 if OK + */ + public function setNextDate($date, $increment_nb_gen_done = 0) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); + return -1; + } + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); + if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1'; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->date_when = $date; - if ($increment_nb_gen_done > 0) $this->nb_gen_done++; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->date_when = $date; + if ($increment_nb_gen_done > 0) $this->nb_gen_done++; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } /** - * Update the maximum period - * - * @param int $nb number of maximum period - * @return int <0 if KO, >0 if OK - */ - public function setMaxPeriod($nb) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + * Update the maximum period + * + * @param int $nb number of maximum period + * @return int <0 if KO, >0 if OK + */ + public function setMaxPeriod($nb) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - if (empty($nb)) $nb = 0; + if (empty($nb)) $nb = 0; - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET nb_gen_max = '.$nb; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET nb_gen_max = '.$nb; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->nb_gen_max = $nb; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->nb_gen_max = $nb; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } /** - * Update the auto validate flag of invoice - * - * @param int $validate 0 to create in draft, 1 to create and validate invoice - * @return int <0 if KO, >0 if OK - */ - public function setAutoValidate($validate) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + * Update the auto validate flag of invoice + * + * @param int $validate 0 to create in draft, 1 to create and validate invoice + * @return int <0 if KO, >0 if OK + */ + public function setAutoValidate($validate) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET auto_validate = '.$validate; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET auto_validate = '.$validate; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->auto_validate = $validate; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->auto_validate = $validate; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Update the auto generate documents - * - * @param int $validate 0 no document, 1 to generate document - * @return int <0 if KO, >0 if OK - */ - public function setGeneratePdf($validate) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + /** + * Update the auto generate documents + * + * @param int $validate 0 no document, 1 to generate document + * @return int <0 if KO, >0 if OK + */ + public function setGeneratePdf($validate) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET generate_pdf = '.$validate; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET generate_pdf = '.$validate; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->generate_pdf = $validate; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->generate_pdf = $validate; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Update the model for documents - * - * @param string $model model of document generator - * @return int <0 if KO, >0 if OK - */ - public function setModelPdf($model) - { - if (!$this->table_element) - { - dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); - return -1; - } + /** + * Update the model for documents + * + * @param string $model model of document generator + * @return int <0 if KO, >0 if OK + */ + public function setModelPdf($model) + { + if (!$this->table_element) + { + dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); + return -1; + } - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET modelpdf = "'.$model.'"'; - $sql .= ' WHERE rowid = '.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET modelpdf = "'.$model.'"'; + $sql .= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); - if ($this->db->query($sql)) - { - $this->modelpdf = $model; - return 1; - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); + if ($this->db->query($sql)) + { + $this->modelpdf = $model; + return 1; + } else { + dol_print_error($this->db); + return -1; + } + } } @@ -1894,210 +1895,208 @@ class FactureLigneRec extends CommonInvoiceLine */ public $table_element = 'facturedet_rec'; - public $date_start_fill; - public $date_end_fill; - /** - * Delete line in database - * - * @param User $user Object user - * @param int $notrigger Disable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - $error = 0; + /** + * Delete line in database + * + * @param User $user Object user + * @param int $notrigger Disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + $error = 0; - $this->db->begin(); + $this->db->begin(); - if (!$error) { - if (!$notrigger) { - // Call triggers - $result = $this->call_trigger('LINEBILLREC_DELETE', $user); - if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } + if (!$error) { + if (!$notrigger) { + // Call triggers + $result = $this->call_trigger('LINEBILLREC_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } if (!$error) - { - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - } - } - - if (!$error) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; - - $res = $this->db->query($sql); - if ($res === false) { - $error++; - $this->errors[] = $this->db->lasterror(); - } - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return 1; + { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + } } - } + + if (!$error) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + + $res = $this->db->query($sql); + if ($res === false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } - /** - * Get line of template invoice - * - * @param int $rowid Id of invoice - * @return int 1 if OK, < 0 if KO - */ - public function fetch($rowid) - { - $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; - $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; - $sql .= ' l.rang, l.special_code,'; - $sql .= ' l.fk_unit, l.fk_contract_line,'; - $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql .= ' WHERE l.rowid = '.$rowid; - $sql .= ' ORDER BY l.rang'; + /** + * Get line of template invoice + * + * @param int $rowid Id of invoice + * @return int 1 if OK, < 0 if KO + */ + public function fetch($rowid) + { + $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; + $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + $sql .= ' l.rang, l.special_code,'; + $sql .= ' l.fk_unit, l.fk_contract_line,'; + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql .= ' WHERE l.rowid = '.$rowid; + $sql .= ' ORDER BY l.rang'; - dol_syslog('FactureRec::fetch', LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $objp = $this->db->fetch_object($result); + dol_syslog('FactureRec::fetch', LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); - $this->id = $objp->rowid; - $this->label = $objp->custom_label; // Label line - $this->desc = $objp->description; // Description line - $this->description = $objp->description; // Description line - $this->product_type = $objp->product_type; // Type of line - $this->ref = $objp->product_ref; // Ref product - $this->product_ref = $objp->product_ref; // Ref product - $this->libelle = $objp->product_label; // deprecated - $this->product_label = $objp->product_label; // Label product - $this->product_desc = $objp->product_desc; // Description product - $this->fk_product_type = $objp->fk_product_type; // Type of product - $this->qty = $objp->qty; - $this->price = $objp->price; - $this->subprice = $objp->subprice; - $this->fk_facture = $objp->fk_facture; - $this->vat_src_code = $objp->vat_src_code; - $this->tva_tx = $objp->tva_tx; - $this->localtax1_tx = $objp->localtax1_tx; - $this->localtax2_tx = $objp->localtax2_tx; - $this->localtax1_type = $objp->localtax1_type; - $this->localtax2_type = $objp->localtax2_type; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; - $this->fk_product = $objp->fk_product; - $this->date_start_fill = $objp->date_start_fill; - $this->date_end_fill = $objp->date_end_fill; - $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_ttc = $objp->total_ttc; - $this->code_ventilation = $objp->fk_code_ventilation; - $this->rang = $objp->rang; - $this->special_code = $objp->special_code; - $this->fk_unit = $objp->fk_unit; - $this->fk_contract_line = $objp->fk_contract_line; + $this->id = $objp->rowid; + $this->label = $objp->custom_label; // Label line + $this->desc = $objp->description; // Description line + $this->description = $objp->description; // Description line + $this->product_type = $objp->product_type; // Type of line + $this->ref = $objp->product_ref; // Ref product + $this->product_ref = $objp->product_ref; // Ref product + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; // Label product + $this->product_desc = $objp->product_desc; // Description product + $this->fk_product_type = $objp->fk_product_type; // Type of product + $this->qty = $objp->qty; + $this->price = $objp->price; + $this->subprice = $objp->subprice; + $this->fk_facture = $objp->fk_facture; + $this->vat_src_code = $objp->vat_src_code; + $this->tva_tx = $objp->tva_tx; + $this->localtax1_tx = $objp->localtax1_tx; + $this->localtax2_tx = $objp->localtax2_tx; + $this->localtax1_type = $objp->localtax1_type; + $this->localtax2_type = $objp->localtax2_type; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->date_start_fill = $objp->date_start_fill; + $this->date_end_fill = $objp->date_end_fill; + $this->info_bits = $objp->info_bits; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; + $this->code_ventilation = $objp->fk_code_ventilation; + $this->rang = $objp->rang; + $this->special_code = $objp->special_code; + $this->fk_unit = $objp->fk_unit; + $this->fk_contract_line = $objp->fk_contract_line; - $this->db->free($result); - return 1; - } else { - $this->error = $this->db->lasterror(); - return -3; - } - } + $this->db->free($result); + return 1; + } else { + $this->error = $this->db->lasterror(); + return -3; + } + } - /** - * Update a line to invoice_rec. - * - * @param User $user User - * @param int $notrigger No trigger - * @return int <0 if KO, Id of line if OK - */ - public function update(User $user, $notrigger = 0) - { - global $conf; + /** + * Update a line to invoice_rec. + * + * @param User $user User + * @param int $notrigger No trigger + * @return int <0 if KO, Id of line if OK + */ + public function update(User $user, $notrigger = 0) + { + global $conf; - $error = 0; + $error = 0; - include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET"; - $sql .= " fk_facture = ".$this->fk_facture; - $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); - $sql .= ", description='".$this->db->escape($this->desc)."'"; - $sql .= ", price=".price2num($this->price); - $sql .= ", qty=".price2num($this->qty); - $sql .= ", tva_tx=".price2num($this->tva_tx); - $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; - $sql .= ", localtax1_tx=".price2num($this->localtax1_tx); - $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql .= ", localtax2_tx=".price2num($this->localtax2_tx); - $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; - $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null"); - $sql .= ", product_type=".$this->product_type; - $sql .= ", remise_percent='".price2num($this->remise_percent)."'"; - $sql .= ", subprice='".price2num($this->subprice)."'"; - $sql .= ", info_bits='".price2num($this->info_bits)."'"; - $sql .= ", date_start_fill=".(int) $this->date_start_fill; - $sql .= ", date_end_fill=".(int) $this->date_end_fill; - if (empty($this->skip_update_total)) { - $sql .= ", total_ht=".price2num($this->total_ht); - $sql .= ", total_tva=".price2num($this->total_tva); - $sql .= ", total_localtax1=".price2num($this->total_localtax1); - $sql .= ", total_localtax2=".price2num($this->total_localtax2); - $sql .= ", total_ttc=".price2num($this->total_ttc); - } - $sql .= ", rang=".$this->rang; - $sql .= ", special_code=".$this->special_code; - $sql .= ", fk_unit=".($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null"); - $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null"); - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET"; + $sql .= " fk_facture = ".$this->fk_facture; + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", description='".$this->db->escape($this->desc)."'"; + $sql .= ", price=".price2num($this->price); + $sql .= ", qty=".price2num($this->qty); + $sql .= ", tva_tx=".price2num($this->tva_tx); + $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; + $sql .= ", localtax1_tx=".price2num($this->localtax1_tx); + $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql .= ", localtax2_tx=".price2num($this->localtax2_tx); + $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null"); + $sql .= ", product_type=".$this->product_type; + $sql .= ", remise_percent='".price2num($this->remise_percent)."'"; + $sql .= ", subprice='".price2num($this->subprice)."'"; + $sql .= ", info_bits='".price2num($this->info_bits)."'"; + $sql .= ", date_start_fill=".(int) $this->date_start_fill; + $sql .= ", date_end_fill=".(int) $this->date_end_fill; + if (empty($this->skip_update_total)) { + $sql .= ", total_ht=".price2num($this->total_ht); + $sql .= ", total_tva=".price2num($this->total_tva); + $sql .= ", total_localtax1=".price2num($this->total_localtax1); + $sql .= ", total_localtax2=".price2num($this->total_localtax2); + $sql .= ", total_ttc=".price2num($this->total_ttc); + } + $sql .= ", rang=".$this->rang; + $sql .= ", special_code=".$this->special_code; + $sql .= ", fk_unit=".($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null"); + $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null"); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::updateline", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } - // End call triggers - } - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -2; - } - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + } + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0c6b438b376..9c78fa6acb9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -95,6 +95,9 @@ class Facture extends CommonInvoice */ protected $table_ref_field = 'ref'; + /** + * @var int thirdparty ID + */ public $socid; public $author; @@ -111,6 +114,18 @@ class Facture extends CommonInvoice public $date; // Date invoice public $datem; + + /** + * @var int Date expected for delivery + * @deprecated + */ + public $date_livraison; // deprecated; Use delivery_date instead. + + public $delivery_date; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) + + /** + * @var string customer ref + */ public $ref_client; /** @@ -137,8 +152,12 @@ class Facture extends CommonInvoice public $close_code; //! Commentaire si mis a paye sans paiement complet public $close_note; - //! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) + + /** + * 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) + */ public $paye; + //! key of module source when invoice generated from a dedicated module ('cashdesk', 'takepos', ...) public $module_source; //! key of pos source ('0', '1', ...) @@ -169,7 +188,6 @@ class Facture extends CommonInvoice public $line; public $extraparams = array(); - public $specimen; public $fac_rec; @@ -617,7 +635,7 @@ class Facture extends CommonInvoice $sql .= ", ".($this->remise_absolue > 0 ? $this->remise_absolue : 'NULL'); $sql .= ", ".($this->remise_percent > 0 ? $this->remise_percent : 'NULL'); $sql .= ", '".$this->db->idate($this->date)."'"; - $sql .= ", ".(strval($this->date_pointoftax) != '' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null'); + $sql .= ", ".(empty($this->date_pointoftax) ? "null" : "'".$this->db->idate($this->date_pointoftax)."'"); $sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); $sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); $sql .= ", ".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null"); @@ -631,7 +649,8 @@ class Facture extends CommonInvoice $sql .= ", ".($this->fk_project ? $this->fk_project : "null"); $sql .= ", ".$this->cond_reglement_id; $sql .= ", ".$this->mode_reglement_id; - $sql .= ", '".$this->db->idate($this->date_lim_reglement)."', '".$this->db->escape($this->modelpdf)."'"; + $sql .= ", '".$this->db->idate($this->date_lim_reglement)."'"; + $sql .= ", ".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null"); $sql .= ", ".($this->situation_cycle_ref ? "'".$this->db->escape($this->situation_cycle_ref)."'" : "null"); $sql .= ", ".($this->situation_counter ? "'".$this->db->escape($this->situation_counter)."'" : "null"); $sql .= ", ".($this->situation_final ? $this->situation_final : 0); @@ -745,7 +764,7 @@ class Facture extends CommonInvoice $newinvoiceline->origin_id = $this->lines[$i]->id; // Auto set date of service ? - if ($this->lines[$i]->date_start_fill == 1 && $originaldatewhen) // $originaldatewhen is defined when generating from recurring invoice only + if ($this->lines[$i]->date_start_fill == 1 && $originaldatewhen) // $originaldatewhen is defined when generating from recurring invoice only { $newinvoiceline->date_start = $originaldatewhen; } @@ -1026,7 +1045,7 @@ class Facture extends CommonInvoice // Charge facture source $facture = new Facture($this->db); - // Retreive all extrafield + // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); @@ -1046,7 +1065,8 @@ class Facture extends CommonInvoice $facture->note_public = $this->note_public; $facture->note_private = $this->note_private; $facture->ref_client = $this->ref_client; - $facture->modelpdf = $this->modelpdf; + $facture->modelpdf = $this->modelpdf; // deprecated + $facture->model_pdf = $this->modelpdf; $facture->fk_project = $this->fk_project; $facture->cond_reglement_id = $this->cond_reglement_id; $facture->mode_reglement_id = $this->mode_reglement_id; @@ -1319,6 +1339,7 @@ class Facture extends CommonInvoice $this->availability_id = $object->availability_id; $this->demand_reason_id = $object->demand_reason_id; $this->date_livraison = $object->date_livraison; + $this->delivery_date = $object->date_livraison; $this->fk_delivery_address = $object->fk_delivery_address; // deprecated $this->contact_id = $object->contact_id; $this->ref_client = $object->ref_client; @@ -1411,11 +1432,14 @@ class Facture extends CommonInvoice $label = ''; if ($user->rights->facture->lire) { - $label = img_picto('', $this->picto).' '.$langs->trans("Invoice").''; - if ($this->type == self::TYPE_REPLACEMENT) $label = ''.$langs->transnoentitiesnoconv("ReplacementInvoice").''; - if ($this->type == self::TYPE_CREDIT_NOTE) $label = ''.$langs->transnoentitiesnoconv("CreditNote").''; - if ($this->type == self::TYPE_DEPOSIT) $label = ''.$langs->transnoentitiesnoconv("Deposit").''; - if ($this->type == self::TYPE_SITUATION) $label = ''.$langs->transnoentitiesnoconv("InvoiceSituation").''; + $label = img_picto('', $this->picto).' '.$langs->trans("Invoice").''; + if ($this->type == self::TYPE_REPLACEMENT) $label = ''.$langs->transnoentitiesnoconv("ReplacementInvoice").''; + if ($this->type == self::TYPE_CREDIT_NOTE) $label = ''.$langs->transnoentitiesnoconv("CreditNote").''; + if ($this->type == self::TYPE_DEPOSIT) $label = ''.$langs->transnoentitiesnoconv("Deposit").''; + if ($this->type == self::TYPE_SITUATION) $label = ''.$langs->transnoentitiesnoconv("InvoiceSituation").''; + if (isset($this->statut) && isset($this->alreadypaid)) { + $label .= ' '.$this->getLibStatut(5, $this->alreadypaid); + } if (!empty($this->ref)) $label .= '
    '.$langs->trans('Ref').': '.$this->ref; if (!empty($this->ref_client)) @@ -1433,9 +1457,6 @@ class Facture extends CommonInvoice if (!empty($this->total_ttc)) $label .= '
    '.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); if ($moretitle) $label .= ' - '.$moretitle; - if (isset($this->statut) && isset($this->alreadypaid)) { - $label .= '
    '.$langs->trans("Status").": ".$this->getLibStatut(5, $this->alreadypaid); - } } $linkclose = ($target ? ' target="'.$target.'"' : ''); @@ -1547,7 +1568,6 @@ class Facture extends CommonInvoice $this->ref = $obj->ref; $this->ref_client = $obj->ref_client; $this->ref_ext = $obj->ref_ext; - $this->ref_int = $obj->ref_int; $this->type = $obj->type; $this->date = $this->db->jdate($obj->df); $this->date_pointoftax = $this->db->jdate($obj->date_pointoftax); @@ -1591,7 +1611,7 @@ class Facture extends CommonInvoice $this->user_author = $obj->fk_user_author; $this->user_valid = $obj->fk_user_valid; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated + $this->modelpdf = $obj->model_pdf; // deprecated $this->last_main_doc = $obj->last_main_doc; $this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_counter = $obj->situation_counter; @@ -1625,7 +1645,7 @@ class Facture extends CommonInvoice if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; - // Retreive all extrafield + // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); @@ -2431,14 +2451,14 @@ class Facture extends CommonInvoice * @param string $force_number Reference to force on invoice * @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease) * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @param int $batch_rule 0=do not decrement batch, else batch rule to use - * 1=take in batches ordered by sellby and eatby dates + * @param int $batch_rule 0=do not decrement batch, else batch rule to use, 1=take in batches ordered by sellby and eatby dates * @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK */ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0, $batch_rule = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $productStatic = null; $warehouseStatic = null; if ($batch_rule > 0) { @@ -2481,9 +2501,9 @@ class Facture extends CommonInvoice $this->db->begin(); // Check parameters - if ($this->type == self::TYPE_REPLACEMENT) // si facture de remplacement + if ($this->type == self::TYPE_REPLACEMENT) // if this is a replacement invoice { - // Controle que facture source connue + // Check that source invoice is known if ($this->fk_facture_source <= 0) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceReplacement")); @@ -2491,7 +2511,7 @@ class Facture extends CommonInvoice return -10; } - // Charge la facture source a remplacer + // Load source invoice that has been replaced $facreplaced = new Facture($this->db); $result = $facreplaced->fetch($this->fk_facture_source); if ($result <= 0) @@ -2501,7 +2521,7 @@ class Facture extends CommonInvoice return -11; } - // Controle que facture source non deja remplacee par une autre + // Check that source invoice not already replaced by another one. $idreplacement = $facreplaced->getIdReplacingInvoice('validated'); if ($idreplacement && $idreplacement != $this->id) { @@ -4313,22 +4333,21 @@ class Facture extends CommonInvoice * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int <0 if KO, >0 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { global $conf, $langs; - $langs->load("bills"); - $outputlangs->load("products"); + $outputlangs->loadLangs(array("bills", "products")); if (!dol_strlen($modele)) { $modele = 'crabe'; $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$this->type; - if ($this->modelpdf) { + if (!empty($this->modelpdf)) { $modele = $this->modelpdf; } elseif (!empty($conf->global->$thisTypeConfName)) { $modele = $conf->global->$thisTypeConfName; @@ -4854,11 +4873,11 @@ class FactureLigne extends CommonInvoiceLine $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; + $this->product_ref = $objp->product_ref; $this->product_label = $objp->product_label; $this->product_desc = $objp->product_desc; - $this->fk_unit = $objp->fk_unit; + $this->fk_unit = $objp->fk_unit; $this->fk_user_modif = $objp->fk_user_modif; $this->fk_user_author = $objp->fk_user_author; diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 6b95c939e2a..e6c4a5a9c22 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -33,39 +33,39 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; */ class FactureStats extends Stats { - public $socid; - public $userid; + public $socid; + public $userid; - /** + /** * @var string Name of table without prefix where object is stored */ public $table_element; - public $from; - public $field; - public $where; - public $join; + public $from; + public $field; + public $where; + public $join; /** - * Constructor - * + * Constructor + * * @param DoliDB $db Database handler * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. * @param string $mode Option ('customer', 'supplier') - * @param int $userid Id user for filter (creation user) - * @param int $typentid Id typent of thirdpary for filter - * @param int $categid Id category of thirdpary for filter + * @param int $userid Id user for filter (creation user) + * @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) { global $user, $conf; $this->db = $db; - $this->socid = ($socid > 0 ? $socid : 0); - $this->userid = $userid; + $this->socid = ($socid > 0 ? $socid : 0); + $this->userid = $userid; $this->cachefilesuffix = $mode; - $this->join = ''; + $this->join = ''; if ($mode == 'customer') { @@ -93,22 +93,22 @@ class FactureStats extends Stats { $this->where .= " AND f.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where .= ' AND f.fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND f.fk_user_author = '.$this->userid; if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where .= " AND f.type IN (0,1,2,5)"; else $this->where .= " AND f.type IN (0,1,2,3,5)"; - if ($typentid) - { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = f.fk_soc'; - $this->where .= ' AND s.fk_typent = '.$typentid; - } + if ($typentid) + { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = f.fk_soc'; + $this->where .= ' AND s.fk_typent = '.$typentid; + } - if ($categid) - { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = f.fk_soc'; - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; - $this->where .= ' AND c.rowid = '.$categid; - } + if ($categid) + { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = f.fk_soc'; + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; + $this->where .= ' AND c.rowid = '.$categid; + } } @@ -116,7 +116,7 @@ class FactureStats extends Stats * Return orders number by month for a year * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array of values */ public function getNbByMonth($year, $format = 0) @@ -126,11 +126,11 @@ class FactureStats extends Stats $sql = "SELECT date_format(f.datef,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
    '; @@ -150,10 +150,10 @@ class FactureStats extends Stats $sql = "SELECT date_format(f.datef,'%Y') as dm, COUNT(*), SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -163,7 +163,7 @@ class FactureStats extends Stats * Return the invoices amount by month for a year * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array with amount by month */ public function getAmountByMonth($year, $format = 0) @@ -173,11 +173,11 @@ class FactureStats extends Stats $sql = "SELECT date_format(datef,'%m') as dm, SUM(f.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; - $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getAmountByMonth($year, $sql, $format); //var_dump($res);print '
    '; @@ -197,11 +197,11 @@ class FactureStats extends Stats $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; - $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= $this->join; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; - $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -218,10 +218,10 @@ class FactureStats extends Stats $sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -230,7 +230,7 @@ class FactureStats extends Stats * Return nb, amount of predefined product for year * * @param int $year Year to scan - * @param int $limit Limit + * @param int $limit Limit * @return array Array of values */ public function getAllByProduct($year, $limit = 10) @@ -240,14 +240,14 @@ class FactureStats extends Stats $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; - $sql .= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; $sql .= " GROUP BY product.ref"; - $sql .= $this->db->order('nb', 'DESC'); - //$sql.= $this->db->plimit(20); + $sql .= $this->db->order('nb', 'DESC'); + //$sql.= $this->db->plimit(20); - return $this->_getAllByProduct($sql, $limit); + return $this->_getAllByProduct($sql, $limit); } } diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 9888bd23d13..97297582081 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -28,9 +28,9 @@ class PaymentTerm // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -46,7 +46,7 @@ class PaymentTerm // extends CommonObject //public $table_element='c_payment_term'; //!< Name of table without prefix where object is stored public $context = array(); - /** + /** * @var int ID */ public $id; @@ -63,27 +63,27 @@ class PaymentTerm // extends CommonObject - /** - * Constructor - * + /** + * Constructor + * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create in database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create in database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -101,7 +101,7 @@ class PaymentTerm // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_payment_term("; $sql .= "entity,"; $sql .= "code,"; @@ -112,7 +112,7 @@ class PaymentTerm // extends CommonObject $sql .= "type_cdr,"; $sql .= "nbjour,"; $sql .= "decalage"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->entity) ?getEntity('c_payment_term') : "'".$this->db->escape($this->entity)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->sortorder) ? 'NULL' : "'".$this->db->escape($this->sortorder)."'").","; @@ -127,41 +127,41 @@ class PaymentTerm // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_payment_term"); - } + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_payment_term"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @return int <0 if KO, >0 if OK - */ - public function fetch($id) - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + public function fetch($id) + { + global $langs; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.entity,"; @@ -175,18 +175,18 @@ class PaymentTerm // extends CommonObject $sql .= " t.decalage"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; - $sql .= " WHERE t.rowid = ".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."c_payment_term as t"; + $sql .= " WHERE t.rowid = ".$id; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code = $obj->code; $this->sortorder = $obj->sortorder; @@ -196,22 +196,22 @@ class PaymentTerm // extends CommonObject $this->type_cdr = $obj->type_cdr; $this->nbjour = $obj->nbjour; $this->decalage = $obj->decalage; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Return id of default payment term - * - * @return int <0 if KO, >0 if OK - */ + /** + * Return id of default payment term + * + * @return int <0 if KO, >0 if OK + */ public function getDefaultId() { global $langs; @@ -243,12 +243,12 @@ class PaymentTerm // extends CommonObject /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -325,15 +325,15 @@ class PaymentTerm // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -393,15 +393,15 @@ class PaymentTerm // extends CommonObject } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { $this->id = 0; $this->code = ''; diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 459543dfc74..57532174db7 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -59,11 +59,11 @@ if ($action == 'addcontact' && $user->rights->facture->creer) { $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { - $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } + } if ($result >= 0) { @@ -83,7 +83,7 @@ elseif ($action == 'swapstatut' && $user->rights->facture->creer) { if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } @@ -133,7 +133,7 @@ if ($id > 0 || !empty($ref)) $totalpaye = $object->getSommePaiement(); - dol_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), -1, 'bill'); + print dol_get_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), -1, 'bill'); // Invoice content @@ -148,36 +148,36 @@ if ($id > 0 || !empty($ref)) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
    '.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $langs->load("projects"); + $morehtmlref .= '
    '.$langs->trans('Project').' '; + if ($user->rights->facture->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
    '; - $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 .= ''; - } - } + } + 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 .= '
    '; @@ -185,7 +185,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; @@ -193,8 +193,8 @@ if ($id > 0 || !empty($ref)) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); foreach ($dirtpls as $reldir) { - $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) break; + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) break; } } else { // Record not found diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 722286044cc..3922228c4fa 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -101,9 +101,9 @@ if ($id > 0 || !empty($ref)) $upload_dir = $conf->facture->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $head = facture_prepare_head($object); - dol_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill'); + print dol_get_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill'); - $totalpaye = $object->getSommePaiement(); + $totalpaye = $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); @@ -114,54 +114,54 @@ if ($id > 0 || !empty($ref)) } - // Invoice content + // Invoice content - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
    '; - // Ref customer - $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
    '.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
    '; - $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 .= '
    '; + $morehtmlref = '
    '; + // Ref customer + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
    '.$langs->trans('Project').' '; + if ($user->rights->facture->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
    '; + $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 .= '
    '; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // 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); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); print '
    '; print '
    '; @@ -174,7 +174,7 @@ if ($id > 0 || !empty($ref)) print "
    \n"; - dol_fiche_end(); + print dol_get_fiche_end(); $modulepart = 'facture'; $permission = $user->rights->facture->creer; diff --git a/htdocs/compta/facture/index.php b/htdocs/compta/facture/index.php index fb044280a21..eb73132c69f 100644 --- a/htdocs/compta/facture/index.php +++ b/htdocs/compta/facture/index.php @@ -41,9 +41,9 @@ if (isset($user->socid) && $user->socid > 0) } // Maximum elements of the tables -$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; -$maxLatestEditCount = 5; -$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; +$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; +$maxLatestEditCount = 5; +$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; /* * View @@ -263,21 +263,21 @@ function getDraftTable($maxCount = 500, $socid = 0) return $result; } - $objectstatic = new Facture($db); - $companystatic = new Societe($db); - $nbofloop = min($num, $maxCount); - $total = 0; - $i = 0; + $objectstatic = new Facture($db); + $companystatic = new Societe($db); + $nbofloop = min($num, $maxCount); + $total = 0; + $i = 0; while ($i < $nbofloop) { $obj = $db->fetch_object($resql); - $objectstatic->id = $obj->rowid; - $objectstatic->ref = $obj->ref; + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->socname; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; $companystatic->client = $obj->client; $companystatic->canvas = $obj->canvas; @@ -344,9 +344,9 @@ function getLatestEditTable($maxCount = 5, $socid = 0) $result = '
    '; $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; if ($num < 1) { @@ -355,47 +355,47 @@ function getLatestEditTable($maxCount = 5, $socid = 0) return $result; } - $formfile = new FormFile($db); - $objectstatic = new Facture($db); - $companystatic = new Societe($db); - $i = 0; + $formfile = new FormFile($db); + $objectstatic = new Facture($db); + $companystatic = new Societe($db); + $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - $objectstatic->id = $obj->rowid; - $objectstatic->ref = $obj->ref; - $objectstatic->paye = $obj->paye; - $objectstatic->statut = $obj->status; + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; + $objectstatic->paye = $obj->paye; + $objectstatic->statut = $obj->status; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->socname; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; $companystatic->client = $obj->client; $companystatic->canvas = $obj->canvas; $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->propal->multidir_output[$obj->entity].'/'.$filename; - $result .= ''; + $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; - $result .= ''; + $result .= ''; $i++; } @@ -457,23 +457,23 @@ function getOpenTable($maxCount = 500, $socid = 0) return $result; } - $objectstatic = new Facture($db); - $companystatic = new Societe($db); + $objectstatic = new Facture($db); + $companystatic = new Societe($db); $formfile = new FormFile($db); $nbofloop = min($num, $maxCount); - $now = dol_now(); - $total = 0; - $i = 0; + $now = dol_now(); + $total = 0; + $i = 0; while ($i < $nbofloop) { $obj = $db->fetch_object($resql); - $objectstatic->id= $obj->id; - $objectstatic->ref = $obj->ref; + $objectstatic->id = $obj->id; + $objectstatic->ref = $obj->ref; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->socname; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->socname; $companystatic->client = $obj->client; $companystatic->canvas = $obj->canvas; diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index bad63cf1f61..f26f4ea0255 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -56,7 +56,7 @@ $object->fetch_thirdparty(); $object->info($object->id); $head = facture_prepare_head($object); -dol_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'); +print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'); $totalpaye = $object->getSommePaiement(); @@ -120,7 +120,7 @@ print '
    '.$langs->trans("LastCustomersBills", $maxCount).'
    '.$langs->trans("LastCustomersBills", $maxCount).'
    '; - $result .= ''; - $result .= ''; + $result .= ''; + $result .= ''; + $result .= '
    '; + $result .= ''; + $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; - $result .= ''; - $result .= '
    '.$objectstatic->getNomUrl(1).' '.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).''.$objectstatic->getNomUrl(1).' '.$formfile->getDocumentsLink($objectstatic->element, $filename, $filedir).'
    '; - $result .= '
    '; + $result .= '
    '.$companystatic->getNomUrl(1, 'customer').''.dol_print_date($db->jdate($obj->datec), 'day').''.$objectstatic->getLibStatut(5).''.$companystatic->getNomUrl(1, 'customer').''.dol_print_date($db->jdate($obj->datec), 'day').''.$objectstatic->getLibStatut(5).'
    '; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 16d163c4fe6..c0abc5a6028 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -154,9 +154,9 @@ if ($socid > 0) { if ($socid > 0) { - $tmpthirdparty = new Societe($db); - $res = $tmpthirdparty->fetch($socid); - if ($res > 0) $search_societe = $tmpthirdparty->name; + $tmpthirdparty = new Societe($db); + $res = $tmpthirdparty->fetch($socid); + if ($res > 0) $search_societe = $tmpthirdparty->name; } /* @@ -529,68 +529,68 @@ if ($resql) if (!empty($arrayfields['f.titre']['checked'])) { - print ''; - print $invoicerectmp->getNomUrl(1); - print ""; - print "\n"; - if (!$i) $totalarray['nbfield']++; + print ''; + print $invoicerectmp->getNomUrl(1); + print ""; + print "\n"; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['s.nom']['checked'])) { - print ''.$companystatic->getNomUrl(1, 'customer').''; - if (!$i) $totalarray['nbfield']++; + print ''.$companystatic->getNomUrl(1, 'customer').''; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['f.total']['checked'])) { - print ''.price($objp->total).''."\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total'; - $totalarray['val']['f.total'] += $objp->total; + print ''.price($objp->total).''."\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total'; + $totalarray['val']['f.total'] += $objp->total; } if (!empty($arrayfields['f.tva']['checked'])) { - print ''.price($objp->total_vat).''."\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva'; - $totalarray['val']['f.tva'] += $objp->total_vat; + print ''.price($objp->total_vat).''."\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva'; + $totalarray['val']['f.tva'] += $objp->total_vat; } if (!empty($arrayfields['f.total_ttc']['checked'])) { - print ''.price($objp->total_ttc).''."\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; - $totalarray['val']['f.total_ttc'] += $objp->total_ttc; + print ''.price($objp->total_ttc).''."\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + $totalarray['val']['f.total_ttc'] += $objp->total_ttc; } // Payment term if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - print ''; - $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); - print ''."\n"; - if (!$i) $totalarray['nbfield']++; + print ''; + $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); + print ''."\n"; + if (!$i) $totalarray['nbfield']++; } // Payment mode if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - print ''; - $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); - print ''."\n"; - if (!$i) $totalarray['nbfield']++; + print ''; + $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); + print ''."\n"; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['recurring']['checked'])) { - print ''.yn($objp->frequency ? 1 : 0).''; - if (!$i) $totalarray['nbfield']++; + print ''.yn($objp->frequency ? 1 : 0).''; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['f.frequency']['checked'])) { - print ''.($objp->frequency > 0 ? $objp->frequency : '').''; - if (!$i) $totalarray['nbfield']++; + print ''.($objp->frequency > 0 ? $objp->frequency : '').''; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['f.unit_frequency']['checked'])) { - print ''.($objp->frequency > 0 ? $objp->unit_frequency : '').''; - if (!$i) $totalarray['nbfield']++; + print ''.($objp->frequency > 0 ? $objp->unit_frequency : '').''; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['f.nb_gen_done']['checked'])) { @@ -602,10 +602,10 @@ if ($resql) // Date last generation if (!empty($arrayfields['f.date_last_gen']['checked'])) { - print ''; - print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); + print ''; + if (!$i) $totalarray['nbfield']++; } // Date next generation if (!empty($arrayfields['f.date_when']['checked'])) @@ -625,17 +625,17 @@ if ($resql) } if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($objp->datec), 'dayhour'); - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + print dol_print_date($db->jdate($objp->datec), 'dayhour'); + print ''; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($objp->tms), 'dayhour'); - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + print dol_print_date($db->jdate($objp->tms), 'dayhour'); + print ''; + if (!$i) $totalarray['nbfield']++; } $obj = $objp; @@ -647,10 +647,10 @@ if ($resql) print $hookmanager->resPrint; // Status if (!empty($arrayfields['status']['checked'])) { - print ''; - print $invoicerectmp->getLibStatut(3, 0); - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + print $invoicerectmp->getLibStatut(3, 0); + print ''; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e12e21e70b4..9e21c584678 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -39,6 +39,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +if (!empty($conf->margin->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +} require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -70,7 +73,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'inv if ($contextpage == 'poslist') { - $_GET['optioncss'] = 'print'; + $_GET['optioncss'] = 'print'; } $lineid = GETPOST('lineid', 'int'); @@ -203,6 +206,10 @@ $arrayfields = array( 'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>200), 'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>210), 'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>220), // 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) || !$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)), 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'f.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))), @@ -216,14 +223,8 @@ if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_ } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) - { - if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); - } -} +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'); @@ -299,8 +300,8 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -if ($massaction == 'makepayment'){ - $arrayofselected=is_array($toselect)?$toselect:array(); +if ($massaction == 'makepayment') { + $arrayofselected = is_array($toselect) ? $toselect : array(); $loc = dol_buildpath('/compta/paiement.php', 2).'?action=create&facids='.implode(',', $arrayofselected); @@ -405,6 +406,10 @@ if ($massaction == 'makepayment'){ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); +$formmargin = null; +if (!empty($conf->margin->enabled)) { + $formmargin = new FormMargin($db); +} $bankaccountstatic = new Account($db); $facturestatic = new Facture($db); $formcompany = new FormCompany($db); @@ -663,16 +668,16 @@ if ($resql) //'makepayment'=>$langs->trans("InvoicePaymentsLimits"), TODO Blank page when using this ); if ($conf->prelevement->enabled) { - $langs->load("withdrawals"); - $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest"); + $langs->load("withdrawals"); + $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest"); } if ($user->rights->facture->supprimer) { if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) { - $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); + $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); } elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { // mass deletion never possible on invoices on such situation - $arrayofmassactions['predelete'] = $langs->trans("Delete"); - } - } + $arrayofmassactions['predelete'] = $langs->trans("Delete"); + } + } if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -852,7 +857,7 @@ if ($resql) // Project label if (!empty($arrayfields['p.title']['checked'])) { - print ''; + print ''; } // Thirdparty if (!empty($arrayfields['s.nom']['checked'])) @@ -956,8 +961,8 @@ if ($resql) } if (!empty($arrayfields['f.retained_warranty']['checked'])) { - print ''; - print ''; + print ''; + print ''; } if (!empty($arrayfields['dynamount_payed']['checked'])) { @@ -1019,6 +1024,26 @@ if ($resql) print ''; print ''; } + if (!empty($arrayfields['total_pa']['checked'])) + { + print ''; + print ''; + } + if (!empty($arrayfields['total_margin']['checked'])) + { + print ''; + print ''; + } + if (!empty($arrayfields['total_margin_rate']['checked'])) + { + print ''; + print ''; + } + if (!empty($arrayfields['total_mark_rate']['checked'])) + { + print ''; + print ''; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -1056,7 +1081,7 @@ if ($resql) { print ''; $liststatus = array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); - print $form->selectarray('search_status', $liststatus, $search_status, 1); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1); print ''; } // Action column @@ -1102,6 +1127,10 @@ if ($resql) if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['multicurrency_rtp']['checked'])) print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['total_pa']['checked'])) print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['total_margin']['checked'])) print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['total_margin_rate']['checked'])) print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['total_mark_rate']['checked'])) print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -1135,9 +1164,9 @@ if ($resql) $facturestatic->ref = $obj->ref; $facturestatic->ref_client = $obj->ref_client; $facturestatic->type = $obj->type; - $facturestatic->total_ht = $obj->total_ht; - $facturestatic->total_tva = $obj->total_vat; - $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_vat; + $facturestatic->total_ttc = $obj->total_ttc; $facturestatic->multicurrency_code = $obj->multicurrency_code; $facturestatic->multicurrency_tx = $obj->multicurrency_tx; $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht; @@ -1146,23 +1175,23 @@ if ($resql) $facturestatic->statut = $obj->fk_statut; $facturestatic->close_code = $obj->close_code; $facturestatic->total_ttc = $obj->total_ttc; - $facturestatic->paye = $obj->paye; - $facturestatic->fk_soc = $obj->fk_soc; + $facturestatic->paye = $obj->paye; + $facturestatic->fk_soc = $obj->fk_soc; - $facturestatic->date = $db->jdate($obj->df); - $facturestatic->date_valid = $db->jdate($obj->date_valid); - $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); + $facturestatic->date = $db->jdate($obj->df); + $facturestatic->date_valid = $db->jdate($obj->date_valid); + $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); - $facturestatic->note_public = $obj->note_public; + $facturestatic->note_public = $obj->note_public; $facturestatic->note_private = $obj->note_private; if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { - $facturestatic->retained_warranty = $obj->retained_warranty; - $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit; - $facturestatic->situation_final = $obj->retained_warranty_date_limit; - $facturestatic->situation_final = $obj->retained_warranty_date_limit; - $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref; - $facturestatic->situation_counter = $obj->situation_counter; + $facturestatic->retained_warranty = $obj->retained_warranty; + $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit; + $facturestatic->situation_final = $obj->retained_warranty_date_limit; + $facturestatic->situation_final = $obj->retained_warranty_date_limit; + $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref; + $facturestatic->situation_counter = $obj->situation_counter; } $thirdpartystatic->id = $obj->socid; $thirdpartystatic->name = $obj->name; @@ -1205,19 +1234,25 @@ if ($resql) $facturestatic->alreadypaid = $paiement; - print ''; + $marginInfo = array(); + if (!empty($conf->margin->enabled)) { + $facturestatic->fetch_lines(); + $marginInfo = $formmargin->getMarginInfosArray($facturestatic); + } - // No - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''.(($offset * $limit) + $i).''; - } + print ''; - // Ref + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''.(($offset * $limit) + $i).''; + } + + // Ref if (!empty($arrayfields['f.ref']['checked'])) { print ''; @@ -1225,12 +1260,12 @@ if ($resql) print ''; print ''; if (!$i) $totalarray['nbfield']++; @@ -1307,24 +1342,24 @@ if ($resql) // Project title if (!empty($arrayfields['p.title']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; } // Third party if (!empty($arrayfields['s.nom']['checked'])) { print ''; if (!$i) $totalarray['nbfield']++; @@ -1470,7 +1505,7 @@ if ($resql) if (!empty($arrayfields['f.retained_warranty']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['dynamount_payed']['checked'])) @@ -1541,6 +1576,31 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 249d2dd9b8c..aa3bd40c591 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -77,69 +77,69 @@ if ($id > 0 || !empty($ref)) $object->fetch_thirdparty(); - $head = facture_prepare_head($object); + $head = facture_prepare_head($object); - $totalpaye = $object->getSommePaiement(); + $totalpaye = $object->getSommePaiement(); - dol_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'); + print dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'); - // Invoice content + // Invoice content - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
    '; - // Ref customer - $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
    '.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
    '; - $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 .= '
    '; + $morehtmlref = '
    '; + // Ref customer + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
    '.$langs->trans('Project').' '; + if ($user->rights->facture->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
    '; + $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 .= '
    '; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // 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); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); print '
    '; print '
    '; $cssclass = "titlefield"; - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index f69517c1037..f6a00f606ba 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -88,45 +88,45 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($action == "new") - { - if ($object->id > 0) - { - $db->begin(); + if ($action == "new") + { + if ($object->id > 0) + { + $db->begin(); - $newtype = $type; - $sourcetype = 'facture'; - if ($type == 'bank-transfer') { - $sourcetype = 'supplier_invoice'; - $newtype = 'bank-transfer'; - } + $newtype = $type; + $sourcetype = 'facture'; + if ($type == 'bank-transfer') { + $sourcetype = 'supplier_invoice'; + $newtype = 'bank-transfer'; + } - $result = $object->demande_prelevement($user, price2num(GETPOST('withdraw_request_amount', 'alpha')), $newtype, $sourcetype); - if ($result > 0) - { - $db->commit(); + $result = $object->demande_prelevement($user, price2num(GETPOST('withdraw_request_amount', 'alpha')), $newtype, $sourcetype); + if ($result > 0) + { + $db->commit(); - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - } - } - $action = ''; - } + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } + } + $action = ''; + } - if ($action == "delete") - { - if ($object->id > 0) - { - $result = $object->demande_prelevement_delete($user, GETPOST('did', 'int')); - if ($result == 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&type='.$type); - exit; - } - } - } + if ($action == "delete") + { + if ($object->id > 0) + { + $result = $object->demande_prelevement_delete($user, GETPOST('did', 'int')); + if ($result == 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&type='.$type); + exit; + } + } + } } @@ -213,7 +213,7 @@ if ($object->id > 0) $head = facture_prepare_head($object); } - dol_fiche_head($head, 'standingorders', $title, -1, 'bill'); + print dol_get_fiche_head($head, 'standingorders', $title, -1, 'bill'); // Invoice content if ($type == 'bank-transfer') { @@ -241,37 +241,37 @@ if ($object->id > 0) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
    '.$langs->trans('Project').' '; - if ($user->rights->facture->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $langs->load("projects"); + $morehtmlref .= '
    '.$langs->trans('Project').' '; + if ($user->rights->facture->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref .= ' : '; } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
    '; - $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 .= ''; - } - } + 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 .= ''; + $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 .= '
    '; @@ -462,14 +462,14 @@ if ($object->id > 0) print $langs->trans('BankAccount'); print ''; + print ''; print '
    '; - if ($contextpage == 'poslist') - { - print $obj->ref; - } else { - print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); - } + if ($contextpage == 'poslist') + { + print $obj->ref; + } else { + print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); + } $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); @@ -1286,7 +1321,7 @@ if ($resql) print ''.dol_print_date($datelimit, 'day'); if ($facturestatic->hasDelay()) { - print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); + print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); } print ''; - if ($obj->project_id > 0) - { - print $projectstatic->title; - } - print ''; + if ($obj->project_id > 0) + { + print $projectstatic->title; + } + print ''; - if ($contextpage == 'poslist') + if ($contextpage == 'poslist') { - print $thirdpartystatic->name; + print $thirdpartystatic->name; } else { - print $thirdpartystatic->getNomUrl(1, 'customer'); + print $thirdpartystatic->getNomUrl(1, 'customer'); } print ''.(!empty($obj->retained_warranty) ?price($obj->retained_warranty).'%' : ' ').''.(!empty($obj->retained_warranty) ?price($obj->retained_warranty).'%' : ' ').''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; if (($action != 'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) - print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
    '; print ''; if ($action == 'editbankaccount') { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); } print ""; print ''; @@ -503,20 +503,20 @@ if ($object->id > 0) if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount HT - print ''.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''; - print ''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; - print ''; + // Multicurrency Amount HT + print ''.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''; + print ''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; + print ''; - // Multicurrency Amount VAT - print ''.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''; - print ''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; - print ''; + // Multicurrency Amount VAT + print ''.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''; + print ''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; + print ''; - // Multicurrency Amount TTC - print ''.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''; - print ''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; - print ''; + // Multicurrency Amount TTC + print ''.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''; + print ''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; + print ''; } // Amount @@ -530,39 +530,39 @@ if ($object->id > 0) // Amount Local Taxes if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 { - print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''; - print ''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).''; + print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''; + print ''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).''; } if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 { - print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''; - print ''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).''; + print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''; + print ''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).''; } // Revenue stamp if ($selleruserevenustamp) // Test company use revenue stamp { - print ''; - print ''; - if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) - { - print ''; - } - print '
    '; - print $langs->trans('RevenueStamp'); - print 'id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'
    '; - print ''; - print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); - print ''; + print ''; + print ''; + if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) + { + print ''; + } + print '
    '; + print $langs->trans('RevenueStamp'); + print 'id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'
    '; + print ''; + print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); + print ''; } // Total with tax print ''.$langs->trans('AmountTTC').''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - // TODO Replace this by an include with same code to show already done payment visible in invoice card - print ''.$langs->trans('RemainderToPay').''.price($resteapayer, 1, '', 1, - 1, - 1, $conf->currency).''; + // TODO Replace this by an include with same code to show already done payment visible in invoice card + print ''.$langs->trans('RemainderToPay').''.price($resteapayer, 1, '', 1, - 1, - 1, $conf->currency).''; print ''; @@ -573,7 +573,7 @@ if ($object->id > 0) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); $numopen = 0; $pending = 0; $numclosed = 0; @@ -639,27 +639,27 @@ if ($object->id > 0) // Add a transfer request if ($object->statut > $object::STATUS_DRAFT && $object->paye == 0 && $num == 0) { - if ($resteapayer > 0) - { - if ($user->rights->prelevement->bons->creer) - { - $remaintopaylesspendingdebit = $resteapayer - $pending; + if ($resteapayer > 0) + { + if ($user->rights->prelevement->bons->creer) + { + $remaintopaylesspendingdebit = $resteapayer - $pending; - print '
    '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
    '; - } else { - print ''.$buttonlabel.''; - } - } else { - print ''.$buttonlabel.''; - } + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '; + } else { + print ''.$buttonlabel.''; + } + } else { + print ''.$buttonlabel.''; + } } else { if ($num == 0) { diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 81466651856..9cbd826b4a1 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -54,14 +54,14 @@ $custcats = GETPOST('custcats', 'array'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $nowyear = strftime("%Y", dol_now()); $year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; -if (!empty($conf->global->INVOICE_STATS_GRAPHS_SHOW_2_YEARS)) $startyear=$year-2; -else $startyear=$year-1; +if (!empty($conf->global->INVOICE_STATS_GRAPHS_SHOW_2_YEARS)) $startyear = $year - 2; +else $startyear = $year - 1; $endyear = $year; @@ -95,10 +95,10 @@ $stats = new FactureStats($db, $socid, $mode, ($userid > 0 ? $userid : 0), ($typ if ($mode == 'customer') { if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; - if (is_array($custcats) && !empty($custcats)) { - $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 ('.implode(',', $custcats).')'; - } + if (is_array($custcats) && !empty($custcats)) { + $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 ('.implode(',', $custcats).')'; + } } if ($mode == 'supplier') { @@ -177,38 +177,38 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; } else { - $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { - $px3->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode = 'depth'; - $px3->SetTitle($langs->trans("AmountAverage")); + $px3->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode = 'depth'; + $px3->SetTitle($langs->trans("AmountAverage")); - $px3->draw($filename_avg, $fileurl_avg); + $px3->draw($filename_avg, $fileurl_avg); } @@ -216,7 +216,7 @@ if (!$mesg) $data = $stats->getAllByYear(); $arrayyears = array(); foreach ($data as $val) { - $arrayyears[$val['year']] = $val['year']; + $arrayyears[$val['year']] = $val['year']; } if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -233,7 +233,7 @@ if ($mode == 'supplier') $type = 'supplier_invoice_stats'; complete_head_from_modules($conf, $langs, null, $head, $h, $type); -dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); +print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); // We use select_thirdparty_list instead of select_company so we can use $filter and share same code for customer and supplier. $tmp_companies = $form->select_thirdparty_list($socid, 'socid', $filter, 1, 0, 0, array(), '', 1); @@ -269,16 +269,16 @@ if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisL print ''; // Category -if (! empty($conf->category->enabled)) { +if (!empty($conf->category->enabled)) { if ($mode == 'customer') { - $cat_type = Categorie::TYPE_CUSTOMER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); + $cat_type = Categorie::TYPE_CUSTOMER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); } if ($mode == 'supplier') { - $cat_type = Categorie::TYPE_SUPPLIER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); + $cat_type = Categorie::TYPE_SUPPLIER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); } print ''.$cat_label.''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); @@ -295,13 +295,13 @@ print ''; print ''.$langs->trans("Status").''; if ($mode == 'customer') { - $liststatus = array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"), '1,2'=>$langs->trans("BillStatusNotPaid").' / '.$langs->trans("BillStatusPaid"), '3'=>$langs->trans("BillStatusCanceled")); - print $form->selectarray('object_status', $liststatus, $object_status, 1); + $liststatus = array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"), '1,2'=>$langs->trans("BillStatusNotPaid").' / '.$langs->trans("BillStatusPaid"), '3'=>$langs->trans("BillStatusCanceled")); + print $form->selectarray('object_status', $liststatus, $object_status, 1); } if ($mode == 'supplier') { - $liststatus = array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid")); - print $form->selectarray('object_status', $liststatus, $object_status, 1); + $liststatus = array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid")); + print $form->selectarray('object_status', $liststatus, $object_status, 1); } print ''; // Year @@ -371,8 +371,8 @@ if ($mesg) { print $mesg; } else { print $px1->show(); print "
    \n"; print $px2->show(); - print "
    \n"; - print $px3->show(); + print "
    \n"; + print $px3->show(); } print ''; @@ -381,7 +381,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index ef35c03eb54..92745a276e1 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -40,10 +40,10 @@ $total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - $ilink++; + $ilink++; - $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; print ''; print ''; switch ($objectlink->type) { @@ -67,37 +67,37 @@ foreach ($linkedObjectBlock as $key => $objectlink) break; } print ''; - print ''.$objectlink->getNomUrl(1).''; - print ''.$objectlink->ref_client.''; - print ''.dol_print_date($objectlink->date, 'day').''; - print ''; - if ($user->rights->facture->lire) { - $sign = 1; - if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; - if ($objectlink->statut != 3) { + print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->ref_client.''; + print ''.dol_print_date($objectlink->date, 'day').''; + print ''; + if ($user->rights->facture->lire) { + $sign = 1; + if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; + if ($objectlink->statut != 3) { // If not abandonned - $total = $total + $sign * $objectlink->total_ht; - echo price($objectlink->total_ht); - } else { - echo ''.price($objectlink->total_ht).''; - } + $total = $total + $sign * $objectlink->total_ht; + echo price($objectlink->total_ht); + } else { + echo ''.price($objectlink->total_ht).''; + } } - print ''; - print ''.$objectlink->getLibStatut(3).''; - print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; - print "\n"; + print ''; + print ''.$objectlink->getLibStatut(3).''; + print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + print "\n"; } if (count($linkedObjectBlock) > 1) { - print ''; - print ''.$langs->trans("Total").''; - print ''; - print ''; - print ''; - print ''.price($total).''; - print ''; - print ''; - print ''; + print ''; + print ''.$langs->trans("Total").''; + print ''; + print ''; + print ''; + print ''.price($total).''; + print ''; + print ''; + print ''; } print "\n"; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index 4e5a63e3a8a..1c8473637f3 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -40,10 +40,10 @@ $total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - $ilink++; + $ilink++; - $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; ?> trans("RepeatableInvoice"); ?> diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 0591d75d5a3..5614659eac0 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -8,6 +8,7 @@ * Copyright (C) 2016 Marcos García * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2020 Josep Lluís Amador * * 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 @@ -76,9 +77,6 @@ $hookmanager->initHooks(array('invoiceindex')); $now = dol_now(); -$facturestatic = new Facture($db); -$facturesupplierstatic = new FactureFournisseur($db); - $form = new Form($db); $formfile = new FormFile($db); $thirdpartystatic = new Societe($db); @@ -93,43 +91,43 @@ print '
    '; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { - // Search customer invoices - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) - { - $listofsearchfields['search_invoice'] = array('text'=>'CustomerInvoice'); - } - // Search supplier invoices - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->lire) - { - $listofsearchfields['search_supplier_invoice'] = array('text'=>'SupplierInvoice'); - } - if (!empty($conf->don->enabled) && $user->rights->don->lire) - { - $langs->load("donations"); - $listofsearchfields['search_donation'] = array('text'=>'Donation'); - } + // Search customer invoices + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) + { + $listofsearchfields['search_invoice'] = array('text'=>'CustomerInvoice'); + } + // Search supplier invoices + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->lire) + { + $listofsearchfields['search_supplier_invoice'] = array('text'=>'SupplierInvoice'); + } + if (!empty($conf->don->enabled) && $user->rights->don->lire) + { + $langs->load("donations"); + $listofsearchfields['search_donation'] = array('text'=>'Donation'); + } - if (count($listofsearchfields)) - { - print '
    '; - print ''; + if (count($listofsearchfields)) + { + print ''; + print ''; print '
    '; - print ''; - $i = 0; - foreach ($listofsearchfields as $key => $value) - { - if ($i == 0) print ''; - print ''; - print ''; - if ($i == 0) print ''; - print ''; - $i++; - } - print '
    '.$langs->trans("Search").'
    '; - print '
    '; - print '
    '; - print '
    '; - } + print ''; + $i = 0; + foreach ($listofsearchfields as $key => $value) + { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
    '.$langs->trans("Search").'
    '; + print '
    '; + print ''; + print '
    '; + } } @@ -138,13 +136,16 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles */ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { - $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client"; - $sql .= ", f.type"; - $sql .= ", s.nom as name"; - $sql .= ", s.rowid as socid, s.email"; - $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + $tmpinvoice = new Facture($db); + + $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client"; + $sql .= ", f.type, f.fk_statut as status, f.paye"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').")"; @@ -159,8 +160,9 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); $sql .= $hookmanager->resPrint; - $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, "; - $sql .= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,"; + $sql .= " s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,"; + $sql .= " cc.rowid, cc.code"; // Add Group from hooks $parameters = array(); @@ -195,18 +197,22 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); - $facturestatic->id = $obj->rowid; - $facturestatic->ref = $obj->ref; - $facturestatic->date = $db->jdate($obj->date); - $facturestatic->type = $obj->type; - $facturestatic->total_ht = $obj->total_ht; - $facturestatic->total_tva = $obj->total_tva; - $facturestatic->total_ttc = $obj->total_ttc; - $facturestatic->ref_client = $obj->ref_client; + $tmpinvoice->id = $obj->rowid; + $tmpinvoice->ref = $obj->ref; + $tmpinvoice->date = $db->jdate($obj->date); + $tmpinvoice->type = $obj->type; + $tmpinvoice->total_ht = $obj->total_ht; + $tmpinvoice->total_tva = $obj->total_tva; + $tmpinvoice->total_ttc = $obj->total_ttc; + $tmpinvoice->ref_client = $obj->ref_client; + $tmpinvoice->statut = $obj->status; + $tmpinvoice->paye = $obj->paye; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->email = $obj->email; + $companystatic->country_id = $obj->country_id; + $companystatic->country_code = $obj->country_code; $companystatic->client = 1; $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; @@ -214,7 +220,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; print ''; - print $facturestatic->getNomUrl(1, ''); + print $tmpinvoice->getNomUrl(1, ''); print ''; print ''; print $companystatic->getNomUrl(1, 'customer'); @@ -243,12 +249,14 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) */ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { - $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier"; + $facturesupplierstatic = new FactureFournisseur($db); + + $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier, f.fk_statut as status, f.paye"; $sql .= ", s.nom as name"; - $sql .= ", s.rowid as socid, s.email"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; - $sql .= ", cc.rowid as country_id, cc.code as country_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".FactureFournisseur::STATUS_DRAFT; $sql .= " AND f.entity IN (".getEntity('invoice').')'; @@ -293,6 +301,8 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $facturesupplierstatic->total_ttc = $obj->total_ttc; $facturesupplierstatic->ref_supplier = $obj->ref_supplier; $facturesupplierstatic->type = $obj->type; + $facturesupplierstatic->statut = $obj->status; + $facturesupplierstatic->paye = $obj->paye; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; @@ -338,15 +348,15 @@ print '
    '; if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $langs->load("boxes"); - $facstatic = new Facture($db); + $tmpinvoice = new Facture($db); - $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; + $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; $sql .= ", f.date_lim_reglement as datelimite"; $sql .= ", s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client, s.code_compta, s.email"; - $sql .= ", cc.rowid as country_id, cc.code as country_code"; - $sql .= ", sum(pf.amount) as am"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client, s.code_compta, s.email"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays, ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -372,7 +382,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $i = 0; $othernb = 0; - print '
    '; + print '
    '; print ''; print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; @@ -395,14 +405,15 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) continue; } - $facturestatic->ref = $obj->ref; - $facturestatic->id = $obj->rowid; - $facturestatic->total_ht = $obj->total_ht; - $facturestatic->total_tva = $obj->total_tva; - $facturestatic->total_ttc = $obj->total_ttc; - $facturestatic->statut = $obj->fk_statut; - $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); - $facturestatic->type = $obj->type; + $tmpinvoice->ref = $obj->ref; + $tmpinvoice->id = $obj->rowid; + $tmpinvoice->total_ht = $obj->total_ht; + $tmpinvoice->total_tva = $obj->total_tva; + $tmpinvoice->total_ttc = $obj->total_ttc; + $tmpinvoice->statut = $obj->status; + $tmpinvoice->paye = $obj->paye; + $tmpinvoice->date_lim_reglement = $db->jdate($obj->datelimite); + $tmpinvoice->type = $obj->type; $thirdpartystatic->id = $obj->socid; $thirdpartystatic->name = $obj->name; @@ -421,10 +432,10 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print '
    '.$langs->trans("BoxTitleLastCustomerBills", $max).''.$langs->trans("AmountHT").'
    '; print ''; print ''; @@ -432,17 +443,17 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); $urlsource = $_SERVER['PHP_SELF'].'?facid='.$obj->rowid; - print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); + print $formfile->getDocumentsLink($tmpinvoice->element, $filename, $filedir); print '
    '; - print $facturestatic->getNomUrl(1, ''); + print $tmpinvoice->getNomUrl(1, ''); print ''; - if ($facturestatic->hasDelay()) { + if ($tmpinvoice->hasDelay()) { print img_warning($langs->trans("Late")); } print '
    '; print ''; print ''; - print $thirdpartystatic->getNomUrl(1, 'customer', 44); + print $thirdpartystatic->getNomUrl(1, 'customer', 44); print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($obj->total_ht).''; print ''.price($obj->total_ttc).''; print ''.dol_print_date($db->jdate($obj->tms), 'day').''; - print ''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am).''; + print ''.$tmpinvoice->getLibStatut(3, $obj->am).''; print ''; $total_ttc += $obj->total_ttc; @@ -479,10 +490,10 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $langs->load("boxes"); $facstatic = new FactureFournisseur($db); - $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye"; + $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye"; $sql .= ", s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.email"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.email"; $sql .= ", SUM(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; @@ -506,7 +517,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU { $num = $db->num_rows($resql); - print '
    '; + print '
    '; print ''; print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; @@ -537,6 +548,8 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $facstatic->total_ht = $obj->total_ht; $facstatic->total_tva = $obj->total_tva; $facstatic->total_ttc = $obj->total_ttc; + $facstatic->statut = $obj->status; + $facstatic->paye = $obj->paye; $thirdpartystatic->id = $obj->socid; $thirdpartystatic->name = $obj->name; @@ -559,7 +572,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; - print ''; + print ''; print ''; $total += $obj->total_ht; $total_ttc += $obj->total_ttc; @@ -593,9 +606,9 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $langs->load("boxes"); - $donationstatic = new Don($db); + $donationstatic = new Don($db); - $sql = "SELECT d.rowid, d.lastname, d.firstname, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut"; + $sql = "SELECT d.rowid, d.lastname, d.firstname, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."don as d"; $sql .= " WHERE d.entity IN (".getEntity('donation').")"; // Add where from hooks @@ -614,14 +627,14 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) $i = 0; $othernb = 0; - print '
    '; + print '
    '; print '
    '.$langs->trans("BoxTitleLastSupplierBills", $max).''.$langs->trans("AmountHT").''.price($obj->total_ht).''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->tms), 'day').''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3).''.$facstatic->getLibStatut(3).'
    '; print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; if ($num) { @@ -643,6 +656,9 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) $donationstatic->ref = $objp->rowid; $donationstatic->lastname = $objp->lastname; $donationstatic->firstname = $objp->firstname; + $donationstatic->date = $objp->date; + $donationstatic->statut = $objp->status; + $donationstatic->status = $objp->status; $label = $donationstatic->getFullName($langs); if ($objp->societe) $label .= ($label ? ' - ' : '').$objp->societe; @@ -652,7 +668,7 @@ if (!empty($conf->don->enabled) && $user->rights->don->lire) print ''; print ''; print ''; - print ''; + print ''; print ''; $i++; @@ -701,7 +717,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $num = $db->num_rows($resql); - print '
    '; + print '
    '; print '
    '.$langs->trans("BoxTitleLastModifiedDonations", $max).''.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").' '.$langs->trans("AmountTTC").''.$langs->trans("DateModificationShort").' 
    '.$label.''.price($objp->amount).''.dol_print_date($db->jdate($objp->dm), 'day').''.$donationstatic->LibStatut($objp->fk_statut, 3).''.$donationstatic->getLibStatut(3).'
    '; print ''; print ''; @@ -732,6 +748,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $chargestatic->ref = $obj->rowid; $chargestatic->label = $obj->label; $chargestatic->paye = $obj->paye; + $chargestatic->status = $obj->paye; print ''; print ''; @@ -779,9 +796,9 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user $sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc"; $sql .= ", s.nom as name, s.email"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client, s.code_compta"; - $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc,"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.tva as total_tva, c.total_ttc,"; $sql .= " cc.rowid as country_id, cc.code as country_code"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -811,7 +828,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user $i = 0; $othernb = 0; - print '
    '; + print '
    '; print '
    '.$langs->trans("ContributionsToPay").($num ? ' '.$num.'' : '').'
    '.$chargestatic->getNomUrl(1).'
    '; print ""; @@ -855,6 +872,8 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user $commandestatic->id = $obj->rowid; $commandestatic->ref = $obj->ref; + $commandestatic->statut = $obj->status; + $commandestatic->billed = $obj->facture; print ''; print ''; print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''; print ''; print ''; - print ''; + print ''; print ''; $tot_ht += $obj->total_ht; $tot_ttc += $obj->total_ttc; @@ -917,15 +936,15 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user */ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { - $facstatic = new Facture($db); + $tmpinvoice = new Facture($db); - $sql = "SELECT f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; + $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; $sql .= ", f.date_lim_reglement as datelimite"; $sql .= ", s.nom as name"; - $sql .= ", s.rowid as socid, s.email"; - $sql .= ", s.code_client, s.code_compta"; - $sql .= ", cc.rowid as country_id, cc.code as country_code"; - $sql .= ", sum(pf.amount) as am"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", cc.rowid as country_id, cc.code as country_code"; + $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -982,14 +1001,15 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) continue; } - $facturestatic->ref = $obj->ref; - $facturestatic->id = $obj->rowid; - $facturestatic->total_ht = $obj->total_ht; - $facturestatic->total_tva = $obj->total_tva; - $facturestatic->total_ttc = $obj->total_ttc; - $facturestatic->type = $obj->type; - $facturestatic->statut = $obj->fk_statut; - $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); + $tmpinvoice->ref = $obj->ref; + $tmpinvoice->id = $obj->rowid; + $tmpinvoice->total_ht = $obj->total_ht; + $tmpinvoice->total_tva = $obj->total_tva; + $tmpinvoice->total_ttc = $obj->total_ttc; + $tmpinvoice->type = $obj->type; + $tmpinvoice->statut = $obj->status; + $tmpinvoice->paye = $obj->paye; + $tmpinvoice->date_lim_reglement = $db->jdate($obj->datelimite); $societestatic->id = $obj->socid; $societestatic->name = $obj->name; @@ -1007,10 +1027,10 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print '
    '; @@ -876,12 +895,12 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user print ''; - print $societestatic->getNomUrl(1, 'customer'); + print $societestatic->getNomUrl(1, 'customer'); print ''.price($obj->total_ht).''.price($obj->total_ttc).''.price($obj->total_ttc - $obj->tot_fttc).''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).''.$commandestatic->getLibStatut(3).'
    '; print ''; print ''; @@ -1018,7 +1038,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $filename = dol_sanitizeFileName($obj->ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); $urlsource = $_SERVER['PHP_SELF'].'?facid='.$obj->rowid; - print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); + print $formfile->getDocumentsLink($tmpinvoice->element, $filename, $filedir); print '
    '; - print $facturestatic->getNomUrl(1, ''); + print $tmpinvoice->getNomUrl(1, ''); print ''; - if ($facturestatic->hasDelay()) { + if ($tmpinvoice->hasDelay()) { print img_warning($langs->trans("Late")); } print '
    '; print ''; @@ -1029,7 +1049,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($obj->total_ht).''; print ''.price($obj->total_ttc).''; print ''.price($obj->am).''; - print ''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am, $obj->type).''; + print ''.$tmpinvoice->getLibStatut(3, $obj->am).''; print ''; $total_ttc += $obj->total_ttc; @@ -1075,12 +1095,12 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU { $facstatic = new FactureFournisseur($db); - $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; + $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; $sql .= ", ff.date_lim_reglement"; $sql .= ", s.nom as name"; - $sql .= ", s.rowid as socid, s.email"; - $sql .= ", s.code_client, s.code_compta"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", s.rowid as socid, s.email"; + $sql .= ", s.code_client, s.code_compta"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; @@ -1148,6 +1168,8 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $facstatic->total_ht = $obj->total_ht; $facstatic->total_tva = $obj->total_tva; $facstatic->total_ttc = $obj->total_ttc; + $facstatic->statut = $obj->status; + $facstatic->paye = $obj->paye; $societestatic->id = $obj->socid; $societestatic->name = $obj->name; @@ -1167,7 +1189,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($obj->total_ht).''; print ''.price($obj->total_ttc).''; print ''.price($obj->am).''; - print ''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am, $obj->type).''; + print ''.$facstatic->getLibStatut(3, $obj->am).''; print ''; $total += $obj->total_ht; $total_ttc += $obj->total_ttc; @@ -1209,7 +1231,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU $resql = 0; if ($resql) { - print '
    '; + print '
    '; print ''; print ''.$langs->trans("TasksToDo").''; print "\n"; diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index d754760dd57..45ffae7c1ff 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -81,8 +81,8 @@ $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); - $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); + $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); + $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } $name = $langs->trans("PurchasesJournal"); @@ -236,7 +236,7 @@ foreach ($tabfac as $key => $val) if (isset($line['inv'])) { print '"; - print '"; + print '"; } else { print '"; print '"; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 62e8c77a133..ea6222dc63f 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -143,10 +143,10 @@ if ($result) $resligne = array(); while ($i < $num) { - $obj = $db->fetch_object($result); - // les variables - $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); - $compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $cptcli); + $obj = $db->fetch_object($result); + // les variables + $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); + $compta_soc = (!empty($obj->code_compta) ? $obj->code_compta : $cptcli); $compta_prod = $obj->accountancy_code_sell; if (empty($compta_prod)) { @@ -170,14 +170,14 @@ if ($result) if ($obj->situation_percent == 0) { $situation_ratio = 0; } else { - $prev_progress = $line->get_prev_progress($obj->rowid); // id on invoice - $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; + $prev_progress = $line->get_prev_progress($obj->rowid); // id on invoice + $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; } } else { $situation_ratio = 1; } - //la ligne facture + //la ligne facture $tabfac[$obj->rowid]["date"] = $obj->datef; $tabfac[$obj->rowid]["ref"] = $obj->ref; $tabfac[$obj->rowid]["type"] = $obj->type; @@ -195,7 +195,7 @@ if ($result) $i++; } } else { - dol_print_error($db); + dol_print_error($db); } @@ -268,7 +268,7 @@ foreach ($tabfac as $key => $val) print '"; } else { print '"; - print '"; + print '"; } print ""; diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 6353d394f20..078625ca1a1 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -61,44 +61,44 @@ if ($_POST["cancel"] == $langs->trans("Cancel") && !$id) if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { - $db->begin(); + $db->begin(); - $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); - $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); + $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); + $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); - $object->accountid = GETPOST("accountid"); - $object->paymenttype = GETPOST("paiementtype"); - $object->datev = $datev; - $object->datep = $datep; - $object->amount = price2num(GETPOST("amount")); + $object->accountid = GETPOST("accountid"); + $object->paymenttype = GETPOST("paiementtype"); + $object->datev = $datev; + $object->datep = $datep; + $object->amount = price2num(GETPOST("amount")); $object->label = GETPOST("label"); $object->ltt = $lttype; - $ret = $object->addPayment($user); - if ($ret > 0) - { - $db->commit(); - header("Location: list.php?localTaxType=".$lttype); - exit; - } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - $_GET["action"] = "create"; - } + $ret = $object->addPayment($user); + if ($ret > 0) + { + $db->commit(); + header("Location: list.php?localTaxType=".$lttype); + exit; + } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + $_GET["action"] = "create"; + } } //delete payment of localtax if ($action == 'delete') { - $result = $object->fetch($id); + $result = $object->fetch($id); if ($object->rappro == 0) { - $db->begin(); + $db->begin(); - $ret = $object->delete($user); - if ($ret > 0) - { + $ret = $object->delete($user); + if ($ret > 0) + { if ($object->fk_bank) { $accountline = new AccountLine($db); @@ -116,13 +116,13 @@ if ($action == 'delete') $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - } + } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } } else { - $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; - setEventMessages($mesg, null, 'errors'); + $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; + setEventMessages($mesg, null, 'errors'); } } @@ -149,25 +149,25 @@ llxHeader("", $title, $helpurl); if ($action == 'create') { - print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); + print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); - print ''."\n"; - print ''; - print ''; - print ''; + print ''."\n"; + print ''; + print ''; + print ''; - dol_fiche_head(); + print dol_get_fiche_head(); - print '
    '.($mt < 0 ?price(-$mt) : '')."'.($mt >= 0 ?price($mt) : '')."'.($mt >= 0 ?price($mt) : '')."'.($mt >= 0 ?price($mt) : '')."'.($mt < 0 ?price(-$mt) : '')."'.($mt < 0 ?price(-$mt) : '')."'.($mt < 0 ?price(-$mt) : '')."'.($mt >= 0 ?price($mt) : '')."'.($mt >= 0 ?price($mt) : '')."
    '; + print '
    '; - print ""; - print ''; + print ""; + print ''; - print ''; + print ''; // Label print ''; @@ -175,38 +175,38 @@ if ($action == 'create') // Amount print ''; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) + { print ''; + $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 2); // Affiche liste des comptes courant + print ''; - print '\n"; - print ""; + print '\n"; + print ""; // Number print ''."\n"; - } - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + } + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - print '
    '.$langs->trans("DatePayment").''; - print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); - print '
    '.$langs->trans("DatePayment").''; + print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); + print '
    '.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; - print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1); - print '
    '.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; + print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1); + print '
    '.$langs->trans("Label").'transcountry(($lttype == 2 ? "LT2Payment" : "LT1Payment"), $mysoc->country_code)).'">
    '.$langs->trans("Amount").'
    '.$langs->trans("Account").''; - $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant - print '
    '.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST("paiementtype"), "paiementtype"); - print "
    '.$langs->trans("PaymentMode").''; + $form->select_types_paiements(GETPOST("paiementtype"), "paiementtype"); + print "
    '.$langs->trans('Numero'); print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print '
    '; + print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; print '     '; - print ''; + print ''; print '
    '; - print ''; + print ''; } @@ -219,7 +219,7 @@ if ($id) $head[$h][2] = 'card'; $h++; - dol_fiche_head($head, 'card', $langs->transcountry("LT".$object->ltt, $mysoc->country_code), -1, 'payment'); + print dol_get_fiche_head($head, 'card', $langs->transcountry("LT".$object->ltt, $mysoc->country_code), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; @@ -251,27 +251,27 @@ if ($id) if ($object->fk_account > 0) { $bankline = new AccountLine($db); - $bankline->fetch($object->fk_bank); + $bankline->fetch($object->fk_bank); - print ''; - print ''.$langs->trans('BankTransactionLine').''; + print ''; + print ''.$langs->trans('BankTransactionLine').''; print ''; print $bankline->getNomUrl(1, 0, 'showall'); - print ''; - print ''; + print ''; + print ''; } } - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - print ''; + print ''; - print '
    '; + print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 1dfeb0b8930..b14c567a01d 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -50,45 +50,45 @@ class Localtax extends CommonObject public $amount; /** - * @var string local tax - */ - public $label; + * @var string local tax + */ + public $label; - /** - * @var int ID - */ + /** + * @var int ID + */ public $fk_bank; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_creat; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - public function create($user) - { - global $conf, $langs; + /** + * Create in database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf, $langs; $error = 0; @@ -97,7 +97,7 @@ class Localtax extends CommonObject $this->label = trim($this->label); $this->note = trim($this->note); - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax("; $sql .= "localtaxtype,"; $sql .= "tms,"; @@ -109,8 +109,8 @@ class Localtax extends CommonObject $sql .= "fk_bank,"; $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; - $sql .= ") VALUES ("; - $sql .= " ".$this->ltt.","; + $sql .= ") VALUES ("; + $sql .= " ".$this->ltt.","; $sql .= " '".$this->db->idate($this->tms)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; @@ -123,41 +123,41 @@ class Localtax extends CommonObject $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."localtax"); + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."localtax"); - // Call trigger - $result = $this->call_trigger('LOCALTAX_CREATE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('LOCALTAX_CREATE', $user); + if ($result < 0) $error++; + // End call triggers - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { $this->db->rollback(); return -1; - } - } else { - $this->error = "Error ".$this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } + } + } else { + $this->error = "Error ".$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = 0) - { - global $conf, $langs; + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = 0) + { + global $conf, $langs; $error = 0; @@ -182,43 +182,43 @@ class Localtax extends CommonObject $sql .= " fk_user_modif=".(int) $this->fk_user_modif; $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = "Error ".$this->db->lasterror(); - $error++; - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = "Error ".$this->db->lasterror(); + $error++; + } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('LOCALTAX_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } + // Call trigger + $result = $this->call_trigger('LOCALTAX_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Load object in memory from database - * - * @param int $id Object id - * @return int <0 if KO, >0 if OK - */ - public function fetch($id) - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Object id + * @return int <0 if KO, >0 if OK + */ + public function fetch($id) + { + global $langs; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.localtaxtype,"; $sql .= " t.tms,"; @@ -233,21 +233,21 @@ class Localtax extends CommonObject $sql .= " b.fk_account,"; $sql .= " b.fk_type,"; $sql .= " b.rappro"; - $sql .= " FROM ".MAIN_DB_PREFIX."localtax as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."localtax as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; - $sql .= " WHERE t.rowid = ".$id; + $sql .= " WHERE t.rowid = ".$id; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->ltt = $obj->localtaxtype; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->ltt = $obj->localtaxtype; $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); $this->datev = $this->db->jdate($obj->datev); @@ -260,15 +260,15 @@ class Localtax extends CommonObject $this->fk_account = $obj->fk_account; $this->fk_type = $obj->fk_type; $this->rappro = $obj->rappro; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } /** @@ -308,7 +308,7 @@ class Localtax extends CommonObject */ public function initAsSpecimen() { - global $user; + global $user; $this->id = 0; @@ -325,221 +325,221 @@ class Localtax extends CommonObject } - /** - * Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de localtax, non ? - * - * @param int $year Year - * @return int ??? - */ - public function solde($year = 0) - { - $reglee = $this->localtax_sum_reglee($year); + /** + * Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de localtax, non ? + * + * @param int $year Year + * @return int ??? + */ + public function solde($year = 0) + { + $reglee = $this->localtax_sum_reglee($year); - $payee = $this->localtax_sum_payee($year); - $collectee = $this->localtax_sum_collectee($year); + $payee = $this->localtax_sum_payee($year); + $collectee = $this->localtax_sum_collectee($year); - $solde = $reglee - ($collectee - $payee); + $solde = $reglee - ($collectee - $payee); - return $solde; - } + return $solde; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Total de la localtax des factures emises par la societe. - * - * @param int $year Year - * @return int ??? - */ - public function localtax_sum_collectee($year = 0) - { - // phpcs:enable - $sql = "SELECT sum(f.localtax) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; - if ($year) - { - $sql .= " AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' "; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Total de la localtax des factures emises par la societe. + * + * @param int $year Year + * @return int ??? + */ + public function localtax_sum_collectee($year = 0) + { + // phpcs:enable + $sql = "SELECT sum(f.localtax) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; + if ($year) + { + $sql .= " AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->amount; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $ret = $obj->amount; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * localtax payed - * - * @param int $year Year - * @return int ??? - */ - public function localtax_sum_payee($year = 0) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * localtax payed + * + * @param int $year Year + * @return int ??? + */ + public function localtax_sum_payee($year = 0) + { + // phpcs:enable - $sql = "SELECT sum(f.total_localtax) as total_localtax"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - if ($year) - { - $sql .= " WHERE f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' "; - } + $sql = "SELECT sum(f.total_localtax) as total_localtax"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + if ($year) + { + $sql .= " WHERE f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->total_localtax; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); - return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * localtax payed - * Total de la localtax payed - * - * @param int $year Year - * @return int ??? - */ - public function localtax_sum_reglee($year = 0) - { - // phpcs:enable - - $sql = "SELECT sum(f.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."localtax as f"; - if ($year) - { - $sql .= " WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' "; - } - - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->amount; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $ret = $obj->total_localtax; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - /** - * Add a payment of localtax - * + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * localtax payed + * Total de la localtax payed + * + * @param int $year Year + * @return int ??? + */ + public function localtax_sum_reglee($year = 0) + { + // phpcs:enable + + $sql = "SELECT sum(f.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."localtax as f"; + if ($year) + { + $sql .= " WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' "; + } + + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $ret = $obj->amount; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); + return 0; + } + } else { + print $this->db->lasterror(); + return -1; + } + } + + + /** + * Add a payment of localtax + * * @param User $user Object user that insert * @return int <0 if KO, rowid in localtax table if OK - */ - public function addPayment($user) - { - global $conf, $langs; + */ + public function addPayment($user) + { + global $conf, $langs; - $this->db->begin(); + $this->db->begin(); - // Check parameters - $this->amount = price2num($this->amount); + // Check parameters + $this->amount = price2num($this->amount); if (!$this->label) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } - if ($this->amount <= 0) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - return -4; - } - if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -5; - } - if (!empty($conf->banque->enabled) && (empty($this->paymenttype) || $this->paymenttype <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -5; - } + if ($this->amount <= 0) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + return -4; + } + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + return -5; + } + if (!empty($conf->banque->enabled) && (empty($this->paymenttype) || $this->paymenttype <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + return -5; + } - // Insertion dans table des paiement localtax - $sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax (localtaxtype, datep, datev, amount"; - if ($this->note) $sql .= ", note"; - if ($this->label) $sql .= ", label"; - $sql .= ", fk_user_creat, fk_bank"; + // Insertion dans table des paiement localtax + $sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax (localtaxtype, datep, datev, amount"; + if ($this->note) $sql .= ", note"; + if ($this->label) $sql .= ", label"; + $sql .= ", fk_user_creat, fk_bank"; $sql .= ") "; - $sql .= " VALUES (".$this->ltt.", '".$this->db->idate($this->datep)."',"; - $sql .= "'".$this->db->idate($this->datev)."',".$this->amount; - if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; - if ($this->label) $sql .= ", '".$this->db->escape($this->label)."'"; - $sql .= ", ".((int) $user->id).", NULL"; - $sql .= ")"; + $sql .= " VALUES (".$this->ltt.", '".$this->db->idate($this->datep)."',"; + $sql .= "'".$this->db->idate($this->datev)."',".$this->amount; + if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; + if ($this->label) $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", ".((int) $user->id).", NULL"; + $sql .= ")"; dol_syslog(get_class($this)."::addPayment", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."localtax"); // TODO devrait s'appeler paiementlocaltax - if ($this->id > 0) - { - $ok = 1; + $result = $this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."localtax"); // TODO devrait s'appeler paiementlocaltax + if ($this->id > 0) + { + $ok = 1; if (!empty($conf->banque->enabled)) - { - // Insertion dans llx_bank - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + { + // Insertion dans llx_bank + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acc = new Account($this->db); + $acc = new Account($this->db); $result = $acc->fetch($this->accountid); if ($result <= 0) dol_print_error($this->db); - $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user); + $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user); - // Mise a jour fk_bank dans llx_localtax. On connait ainsi la ligne de localtax qui a g�n�r� l'�criture bancaire - if ($bank_line_id > 0) + // Mise a jour fk_bank dans llx_localtax. On connait ainsi la ligne de localtax qui a g�n�r� l'�criture bancaire + if ($bank_line_id > 0) { - $this->update_fk_bank($bank_line_id); - } else { + $this->update_fk_bank($bank_line_id); + } else { $this->error = $acc->error; $ok = 0; } - // Mise a jour liens - $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/localtax/card.php?id=', "(VATPayment)", "payment_vat"); - if ($result < 0) - { - $this->error = $acc->error; - $ok = 0; - } - } + // Mise a jour liens + $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/localtax/card.php?id=', "(VATPayment)", "payment_vat"); + if ($result < 0) + { + $this->error = $acc->error; + $ok = 0; + } + } if ($ok) { @@ -549,28 +549,28 @@ class Localtax extends CommonObject $this->db->rollback(); return -3; } - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Update the link betwen localtax payment and the line into llx_bank - * - * @param int $id Id bank account + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Update the link betwen localtax payment and the line into llx_bank + * + * @param int $id Id bank account * @return int <0 if KO, >0 if OK - */ + */ public function update_fk_bank($id) { - // phpcs:enable + // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.$id; $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); @@ -597,12 +597,12 @@ class Localtax extends CommonObject $result = ''; $label = $langs->trans("ShowVatPayment").': '.$this->ref; - $link = ''; + $link = ''; $linkend = ''; $picto = 'payment'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $link.$this->ref.$linkend; return $result; @@ -619,7 +619,7 @@ class Localtax extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -627,11 +627,11 @@ class Localtax extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage - return ''; - } + return ''; + } } diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 1b1ad5351d3..fe605c2224d 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -50,8 +50,8 @@ $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endda // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q = GETPOST("q"); - if (empty($q)) + $q = GETPOST("q"); + if (empty($q)) { if (GETPOST("month")) { $date_start = dol_get_first_day($year_start, GETPOST("month"), false); $date_end = dol_get_last_day($year_start, GETPOST("month"), false); } else { $date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false); @@ -119,12 +119,12 @@ $calc = $conf->global->MAIN_INFO_LOCALTAX_CALC.$local; // Affiche en-tete du rapport if ($calc == 0 || $calc == 1) // Calculate on invoice for goods and services { - $calcmode = $calc == 0 ? $langs->trans("CalcModeLT".$local) : $langs->trans("CalcModeLT".$local."Rec"); - $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); - if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .= '
    '.$langs->trans("WarningDepositsNotIncluded"); - $description .= $fsearch; - $description .= ' ('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $calcmode = $calc == 0 ? $langs->trans("CalcModeLT".$local) : $langs->trans("CalcModeLT".$local."Rec"); + $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); + if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .= '
    '.$langs->trans("WarningDepositsNotIncluded"); + $description .= $fsearch; + $description .= ' ('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; $builddate = dol_now(); $elementcust = $langs->trans("CustomersInvoices"); @@ -136,13 +136,13 @@ if ($calc == 0 || $calc == 1) // Calculate on invoice for goods and services } if ($calc == 2) // Invoice for goods, payment for services { - $calcmode = $langs->trans("CalcModeLT2Debt"); - $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); - if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .= '
    '.$langs->trans("WarningDepositsNotIncluded"); - $description .= $fsearch; - $description .= '('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; - $builddate = dol_now(); + $calcmode = $langs->trans("CalcModeLT2Debt"); + $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); + if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .= '
    '.$langs->trans("WarningDepositsNotIncluded"); + $description .= $fsearch; + $description .= '('.$langs->trans("TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.'/admin/company.php').')'; + $builddate = dol_now(); $elementcust = $langs->trans("CustomersInvoices"); $productcust = $langs->trans("Description"); @@ -213,16 +213,16 @@ if ($calc == 0 || $calc == 2) print ''.$intra.''; print ''.price($coll->amount).''; print ''.price($local == 1 ? $coll->localtax1 : $coll->localtax2).''; - $totalamount = $totalamount + $coll->amount; + $totalamount = $totalamount + $coll->amount; $total = $total + ($local == 1 ? $coll->localtax1 : $coll->localtax2); print "\n"; $i++; } } - $x_coll_sum = $total; + $x_coll_sum = $total; print ''.$langs->trans("Total").':'; - print ''.price($totalamount).''; + print ''.price($totalamount).''; print ''.price($total).''; print ''; } else { @@ -280,16 +280,16 @@ if ($calc == 0 || $calc == 1) { print ''.$intra.""; print ''.price($coll->amount).''; print ''.price($local == 1 ? $coll->localtax1 : $coll->localtax2).''; - $totalamount = $totalamount + $coll->amount; + $totalamount = $totalamount + $coll->amount; $total = $total + ($local == 1 ? $coll->localtax1 : $coll->localtax2); print "\n"; $i++; } } - $x_paye_sum = $total; + $x_paye_sum = $total; print ''.$langs->trans("Total").':'; - print ''.price($totalamount).''; + print ''.price($totalamount).''; print ''.price($total).''; print ''; } else { diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index e8bcc89821b..7d48d6e1f2d 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -86,99 +86,99 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); */ function pt($db, $sql, $date) { - global $conf, $bc, $langs; + global $conf, $bc, $langs; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; - $total = 0; - print ''; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print '
    '; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print ''; + print ''; + print "\n"; - $totalclaimed = 0; - $totalpaid = 0; - $amountclaimed = 0; - $amountpaid = 0; - $previousmonth = ''; - $previousmode = ''; - $mode = ''; + $totalclaimed = 0; + $totalpaid = 0; + $amountclaimed = 0; + $amountpaid = 0; + $previousmonth = ''; + $previousmode = ''; + $mode = ''; - while ($i < $num) { - $obj = $db->fetch_object($result); - $mode = $obj->mode; + while ($i < $num) { + $obj = $db->fetch_object($result); + $mode = $obj->mode; - //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; - if ($obj->mode == 'claimed' && !empty($previousmode)) - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; + //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; + if ($obj->mode == 'claimed' && !empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - } + $amountclaimed = 0; + $amountpaid = 0; + } - if ($obj->mode == 'claimed') - { - $amountclaimed = $obj->mm; - $totalclaimed = $totalclaimed + $amountclaimed; - } - if ($obj->mode == 'paid') - { - $amountpaid = $obj->mm; - $totalpaid = $totalpaid + $amountpaid; - } + if ($obj->mode == 'claimed') + { + $amountclaimed = $obj->mm; + $totalclaimed = $totalclaimed + $amountclaimed; + } + if ($obj->mode == 'paid') + { + $amountpaid = $obj->mm; + $totalpaid = $totalpaid + $amountpaid; + } - if ($obj->mode == 'paid') - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - $previousmode = ''; - $previousmonth = ''; - } else { - $previousmode = $obj->mode; - $previousmonth = $obj->dm; - } + if ($obj->mode == 'paid') + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; + $previousmonth = ''; + } else { + $previousmode = $obj->mode; + $previousmonth = $obj->dm; + } - $i++; - } + $i++; + } - if ($mode == 'claimed' && !empty($previousmode)) - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; + if ($mode == 'claimed' && !empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - } + $amountclaimed = 0; + $amountpaid = 0; + } - print ''; - print ''; - print ''; - print ''; - print ""; + print ''; + print ''; + print ''; + print ''; + print ""; - print "
    '.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
    '.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
    '.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
    '.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
    '.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
    '.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
    '.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
    '.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
    '.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
    '.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
    "; - $db->free($result); - } else { - dol_print_error($db); - } + print ""; + $db->free($result); + } else { + dol_print_error($db); + } } if (empty($localTaxType)) @@ -259,14 +259,14 @@ print ''; print ''; print '"; if ($CalcLT == 0) { - print ''; - print ''; + print ''; + print ''; } if ($CalcLT == 1) { - print ''; + print ''; } if ($CalcLT == 2) { - print ''; + print ''; } print ''; print "\n"; @@ -414,144 +414,144 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc } //now we have an array (x_both) indexed by rates for coll and paye - $action = "tva"; - $object = array(&$x_coll, &$x_paye, &$x_both); - $parameters["mode"] = $modetax; - $parameters["year"] = $y; - $parameters["month"] = $m; - $parameters["type"] = 'localtax'.$localTaxType; + $action = "tva"; + $object = array(&$x_coll, &$x_paye, &$x_both); + $parameters["mode"] = $modetax; + $parameters["year"] = $y; + $parameters["month"] = $m; + $parameters["type"] = 'localtax'.$localTaxType; - // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array - $hookmanager->initHooks(array('externalbalance')); - $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) - { - $langs->load("errors"); - print ''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) - { - print ''; - break; - } + if (!is_array($x_coll) && $coll_listbuy == -1) + { + $langs->load("errors"); + print ''; + break; + } + if (!is_array($x_paye) && $coll_listbuy == -2) + { + print ''; + break; + } - print ''; - print ''; + print ''; + print ''; - $x_coll_sum = 0; - foreach (array_keys($x_coll) as $rate) - { - $subtot_coll_total_ht = 0; - $subtot_coll_vat = 0; + $x_coll_sum = 0; + foreach (array_keys($x_coll) as $rate) + { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) - { - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - //print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - } - } - //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - $temp_vat = $fields['localtax'.$localTaxType] * $ratiopaymentinvoice; - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; - } - } - print ''; + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_vat = $fields['localtax'.$localTaxType] * $ratiopaymentinvoice; + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + print ''; - $x_paye_sum = 0; - foreach (array_keys($x_paye) as $rate) - { - $subtot_paye_total_ht = 0; - $subtot_paye_vat = 0; + $x_paye_sum = 0; + foreach (array_keys($x_paye) as $rate) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; - foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) - { - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - //print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - } - } - //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - $temp_vat = $fields['localtax'.$localTaxType] * $ratiopaymentinvoice; - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; - } - } - print ''; + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_vat = $fields['localtax'.$localTaxType] * $ratiopaymentinvoice; + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + print ''; - $subtotalcoll = $subtotalcoll + $x_coll_sum; - $subtotalpaye = $subtotalpaye + $x_paye_sum; + $subtotalcoll = $subtotalcoll + $x_coll_sum; + $subtotalpaye = $subtotalpaye + $x_paye_sum; - $diff = $x_coll_sum - $x_paye_sum; - $total = $total + $diff; - $subtotal = price2num($subtotal + $diff, 'MT'); + $diff = $x_coll_sum - $x_paye_sum; + $total = $total + $diff; + $subtotal = price2num($subtotal + $diff, 'MT'); - print ''."\n"; - print "\n"; - print "\n"; + print ''."\n"; + print "\n"; + print "\n"; - $i++; $m++; - if ($i > 2) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i = 0; - $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; - } + $i++; $m++; + if ($i > 2) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i = 0; + $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; + } } print ''; print "\n"; diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 2702a962281..4d7e2bf0e54 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -56,45 +56,45 @@ $sql .= " ORDER BY datev DESC"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - $total = 0; + $num = $db->num_rows($result); + $i = 0; + $total = 0; - print '
    '.$langs->trans("Year")." ".$y."'.$langs->transcountry($LTCustomer, $mysoc->country_code).''.$langs->transcountry($LTSupplier, $mysoc->country_code).''.$langs->transcountry($LTCustomer, $mysoc->country_code).''.$langs->transcountry($LTSupplier, $mysoc->country_code).''.$langs->transcountry($LTSupplier, $mysoc->country_code).''.$langs->transcountry($LTSupplier, $mysoc->country_code).''.$langs->transcountry($LTCustomer, $mysoc->country_code).''.$langs->transcountry($LTCustomer, $mysoc->country_code).''.$langs->trans("TotalToPay").' 
    '.$langs->trans("ErrorNoAccountancyModuleLoaded").'
    '.$langs->trans("FeatureNotYetAvailable").'
    '.$langs->trans("ErrorNoAccountancyModuleLoaded").'
    '.$langs->trans("FeatureNotYetAvailable").'
    '.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").'
    '.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''.price(price2num($x_coll_sum, 'MT')).''.price(price2num($x_coll_sum, 'MT')).''.price(price2num($x_paye_sum, 'MT')).''.price(price2num($x_paye_sum, 'MT')).''.price(price2num($diff, 'MT')).' 
    '.price(price2num($diff, 'MT')).' 
    '.$langs->trans("SubTotal").':'.price(price2num($subtotalcoll, 'MT')).''.price(price2num($subtotalpaye, 'MT')).''.price(price2num($subtotal, 'MT')).' 
    '.$langs->trans("SubTotal").':'.price(price2num($subtotalcoll, 'MT')).''.price(price2num($subtotalpaye, 'MT')).''.price(price2num($subtotal, 'MT')).' 
    '.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).' 
    '; - print ''; - print ''; - print ""; - print ""; - print ''; - print ""; - print "\n"; - $var = 1; - while ($i < $num) - { - $obj = $db->fetch_object($result); + print '
    '.$langs->trans("Ref").'".$langs->trans("Label")."".$langs->trans("PeriodEndDate")."'.$langs->trans("DatePayment").'".$langs->trans("PayedByThisPayment")."
    '; + print ''; + print ''; + print ""; + print ""; + print ''; + print ""; + print "\n"; + $var = 1; + while ($i < $num) + { + $obj = $db->fetch_object($result); - print ''; + print ''; $localtax_static->id = $obj->rowid; $localtax_static->ref = $obj->rowid; print "\n"; - print "\n"; - print '\n"; - print '\n"; - $total = $total + $obj->amount; + print "\n"; + print '\n"; + print '\n"; + $total = $total + $obj->amount; - print ""; - print "\n"; + print ""; + print "\n"; - $i++; - } - print ''; - print ''; + $i++; + } + print ''; + print ''; - print "
    '.$langs->trans("Ref").'".$langs->trans("Label")."".$langs->trans("PeriodEndDate")."'.$langs->trans("DatePayment").'".$langs->trans("PayedByThisPayment")."
    ".$localtax_static->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datev), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datev), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."".price($obj->amount)."
    ".price($obj->amount)."
    '.$langs->trans("Total").''.price($total).'
    '.$langs->trans("Total").''.price($total).'
    "; - $db->free($result); + print ""; + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } // End of page diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index ebb66778df7..2b0415800ac 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -142,16 +142,16 @@ $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; } else { - $prevquarter = 4; - $prevyear--; + $prevquarter = 4; + $prevyear--; } $nextyear = $year_start; $nextquarter = $q; if ($nextquarter < 4) { $nextquarter++; } else { - $nextquarter = 1; - $nextyear++; + $nextquarter = 1; + $nextyear++; } $description .= $fsearch; $builddate = dol_now(); @@ -370,12 +370,12 @@ if (!is_array($x_coll) || !is_array($x_paye)) } else { if ($type) $text = img_object($langs->trans('Service'), 'service'); else $text = img_object($langs->trans('Product'), 'product'); - if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) - { - if ($reg[1] == 'DEPOSIT') $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); - elseif ($reg[1] == 'CREDIT_NOTE') $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); - else $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); - } + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) + { + if ($reg[1] == 'DEPOSIT') $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); + elseif ($reg[1] == 'CREDIT_NOTE') $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); + else $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + } print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); // Show range @@ -438,36 +438,36 @@ if (!is_array($x_coll) || !is_array($x_paye)) } } - // Total customers for this vat rate - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) - { - print ' '; - print ' '; - } - print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; - print ''.price(price2num($subtot_coll_vat, 'MT')).''; - print ''; + // Total customers for this vat rate + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) + { + print ' '; + print ' '; + } + print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; + print ''.price(price2num($subtot_coll_vat, 'MT')).''; + print ''; } - if (count($x_coll) == 0) // Show a total ine if nothing shown - { - print ''; - print ' '; - print ''.$langs->trans("Total").':'; - if ($modetax == 0) - { - print ' '; - print ' '; - } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; - print ''; - } + if (count($x_coll) == 0) // Show a total ine if nothing shown + { + print ''; + print ' '; + print ''.$langs->trans("Total").':'; + if ($modetax == 0) + { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } - // Blank line + // Blank line print ' '; //print ''; $diff = $x_coll_sum; @@ -592,18 +592,18 @@ if (!is_array($x_coll) || !is_array($x_paye)) } } - // Total suppliers for this vat rate - print ''; - print ' '; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) - { - print ' '; - print ' '; - } - print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; - print ''.price(price2num($subtot_paye_vat, 'MT')).''; - print ''; + // Total suppliers for this vat rate + print ''; + print ' '; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) + { + print ' '; + print ' '; + } + print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; + print ''.price(price2num($subtot_paye_vat, 'MT')).''; + print ''; } if (count($x_paye) == 0) { // Show a total line if nothing shown @@ -620,7 +620,7 @@ if (!is_array($x_coll) || !is_array($x_paye)) } // Total to pay - $diff = $x_coll_sum - $x_paye_sum; + $diff = $x_coll_sum - $x_paye_sum; print ''; print ''.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').''; print ''.price(price2num($diff, 'MT'))."\n"; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index efe102c48b2..a03fd03ffef 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -61,7 +61,7 @@ $multicurrency_amountsresttopay = array(); // Security check if ($user->socid > 0) { - $socid = $user->socid; + $socid = $user->socid; } $object = new Facture($db); @@ -90,111 +90,111 @@ if (empty($reshook)) { if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) { - $error = 0; + $error = 0; - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $paiement_id = 0; - $totalpayment = 0; + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $paiement_id = 0; + $totalpayment = 0; $multicurrency_totalpayment = 0; - $atleastonepaymentnotnull = 0; + $atleastonepaymentnotnull = 0; $formquestion = array(); $i = 0; - // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice = new Facture($db); - foreach ($_POST as $key => $value) - { + // Generate payment array and check if there is payment higher than invoice and payment date before invoice date + $tmpinvoice = new Facture($db); + foreach ($_POST as $key => $value) + { if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') - { - $cursorfacid = substr($key, 7); - $amounts[$cursorfacid] = price2num(GETPOST($key)); - $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result = $tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); - if ($amounts[$cursorfacid]) - { - // Check amount - if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) - { - $addwarning = 1; - $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); - } - // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { - $langs->load("errors"); - //$error++; - setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); - } - } + { + $cursorfacid = substr($key, 7); + $amounts[$cursorfacid] = price2num(GETPOST($key)); + $totalpayment = $totalpayment + $amounts[$cursorfacid]; + if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); + if ($result <= 0) dol_print_error($db); + $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + if ($amounts[$cursorfacid]) + { + // Check amount + if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) + { + $addwarning = 1; + $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); + } + // Check date + if ($datepaye && ($datepaye < $tmpinvoice->date)) + { + $langs->load("errors"); + //$error++; + setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); + } + } - $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); - } elseif (substr($key, 0, 21) == 'multicurrency_amount_') + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); + } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); - $multicurrency_amounts[$cursorfacid] = price2num(GETPOST($key)); - $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; - if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result = $tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); - $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); - if ($multicurrency_amounts[$cursorfacid]) - { - // Check amount - if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) - { - $addwarning = 1; - $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); - } - // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { - $langs->load("errors"); - //$error++; - setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); - } - } + $multicurrency_amounts[$cursorfacid] = price2num(GETPOST($key)); + $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; + if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); + if ($result <= 0) dol_print_error($db); + $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); + if ($multicurrency_amounts[$cursorfacid]) + { + // Check amount + if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) + { + $addwarning = 1; + $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); + } + // Check date + if ($datepaye && ($datepaye < $tmpinvoice->date)) + { + $langs->load("errors"); + //$error++; + setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings'); + } + } - $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); } - } + } - // Check parameters - if (!GETPOST('paiementcode')) - { - setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors'); - $error++; - } + // Check parameters + if (!GETPOST('paiementcode')) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors'); + $error++; + } - if (!empty($conf->banque->enabled)) - { - // If bank module is on, account is required to enter a payment - if (GETPOST('accountid') <= 0) - { - setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); - $error++; - } - } + if (!empty($conf->banque->enabled)) + { + // If bank module is on, account is required to enter a payment + if (GETPOST('accountid') <= 0) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); + $error++; + } + } - if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) - { - setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors'); - $error++; - } + if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors'); + $error++; + } - if (empty($datepaye)) - { - setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); - $error++; - } + if (empty($datepaye)) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); + $error++; + } // Check if payments in both currency if ($totalpayment > 0 && $multicurrency_totalpayment > 0) { setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors'); - $error++; + $error++; } } @@ -203,11 +203,11 @@ if (empty($reshook)) */ if ($action == 'add_paiement') { - if ($error) - { - $action = 'create'; - } - // The next of this action is displayed at the page's bottom. + if ($error) + { + $action = 'create'; + } + // The next of this action is displayed at the page's bottom. } /* @@ -215,103 +215,103 @@ if (empty($reshook)) */ if ($action == 'confirm_paiement' && $confirm == 'yes') { - $error = 0; + $error = 0; - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $db->begin(); + $db->begin(); - $thirdparty = new Societe($db); - if ($socid > 0) $thirdparty->fetch($socid); + $thirdparty = new Societe($db); + if ($socid > 0) $thirdparty->fetch($socid); - // Clean parameters amount if payment is for a credit note - foreach ($amounts as $key => $value) // How payment is dispatched - { - $tmpinvoice = new Facture($db); - $tmpinvoice->fetch($key); - if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) - { - $newvalue = price2num($value, 'MT'); - $amounts[$key] = - abs($newvalue); - } - } + // Clean parameters amount if payment is for a credit note + foreach ($amounts as $key => $value) // How payment is dispatched + { + $tmpinvoice = new Facture($db); + $tmpinvoice->fetch($key); + if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) + { + $newvalue = price2num($value, 'MT'); + $amounts[$key] = - abs($newvalue); + } + } - foreach ($multicurrency_amounts as $key => $value) // How payment is dispatched - { - $tmpinvoice = new Facture($db); - $tmpinvoice->fetch($key); - if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) - { - $newvalue = price2num($value, 'MT'); - $multicurrency_amounts[$key] = - abs($newvalue); - } - } + foreach ($multicurrency_amounts as $key => $value) // How payment is dispatched + { + $tmpinvoice = new Facture($db); + $tmpinvoice->fetch($key); + if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) + { + $newvalue = price2num($value, 'MT'); + $multicurrency_amounts[$key] = - abs($newvalue); + } + } - if (!empty($conf->banque->enabled)) - { - // If the bank module is active, an account is required to input a payment - if (GETPOST('accountid', 'int') <= 0) - { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); - $error++; - } - } + if (!empty($conf->banque->enabled)) + { + // If the bank module is active, an account is required to input a payment + if (GETPOST('accountid', 'int') <= 0) + { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors'); + $error++; + } + } - // Creation of payment line - $paiement = new Paiement($db); - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); - $paiement->num_payment = GETPOST('num_paiement', 'alpha'); - $paiement->note_private = GETPOST('comment', 'alpha'); + // Creation of payment line + $paiement = new Paiement($db); + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); + $paiement->num_payment = GETPOST('num_paiement', 'alpha'); + $paiement->note_private = GETPOST('comment', 'alpha'); - if (!$error) - { - // Create payment and update this->multicurrency_amounts if this->amounts filled or - // this->amounts if this->multicurrency_amounts filled. - $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents - if ($paiement_id < 0) - { - setEventMessages($paiement->error, $paiement->errors, 'errors'); - $error++; - } - } + if (!$error) + { + // Create payment and update this->multicurrency_amounts if this->amounts filled or + // this->amounts if this->multicurrency_amounts filled. + $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents + if ($paiement_id < 0) + { + setEventMessages($paiement->error, $paiement->errors, 'errors'); + $error++; + } + } - if (!$error) - { - $label = '(CustomerInvoicePayment)'; - if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note - $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); - if ($result < 0) - { - setEventMessages($paiement->error, $paiement->errors, 'errors'); - $error++; - } - } + if (!$error) + { + $label = '(CustomerInvoicePayment)'; + if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); + if ($result < 0) + { + setEventMessages($paiement->error, $paiement->errors, 'errors'); + $error++; + } + } - if (!$error) - { - $db->commit(); + if (!$error) + { + $db->commit(); - // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card - $invoiceid = 0; - foreach ($paiement->amounts as $key => $amount) - { - $facid = $key; - if (is_numeric($amount) && $amount <> 0) - { - if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment - else $invoiceid = $facid; - } - } - if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; - else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; - header('Location: '.$loc); - exit; - } else { - $db->rollback(); - } + // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card + $invoiceid = 0; + foreach ($paiement->amounts as $key => $amount) + { + $facid = $key; + if (is_numeric($amount) && $amount <> 0) + { + if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment + else $invoiceid = $facid; + } + } + if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; + else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; + header('Location: '.$loc); + exit; + } else { + $db->rollback(); + } } } @@ -469,77 +469,77 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print ''; - // Third party - print '\n"; + // Third party + print '\n"; - // Date payment - print ''; + // Date payment + print ''; - // Payment mode - print '\n"; - print ''; + // Payment mode + print '\n"; + print ''; - // Bank account - print ''; - if (!empty($conf->banque->enabled)) - { - if ($facture->type != 2) print ''; - if ($facture->type == 2) print ''; - print ''; - } else { - print ''; - } - print "\n"; + // Bank account + print ''; + if (!empty($conf->banque->enabled)) + { + if ($facture->type != 2) print ''; + if ($facture->type == 2) print ''; + print ''; + } else { + print ''; + } + print "\n"; - // Bank check number - print ''; - print ''; + // Bank check number + print ''; + print ''; - // Check transmitter - print ''; - print ''; + // Check transmitter + print ''; + print ''; - // Bank name - print ''; - print ''; + // Bank name + print ''; + print ''; // Comments print ''; print ''; - print '
    '.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
    '.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
    '.$langs->trans('Date').''; - $datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $datepayment = ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datepayment); - print $form->selectDate($datepayment, '', '', '', 0, "add_paiement", 1, 1, 0, '', '', $facture->date); - print '
    '.$langs->trans('Date').''; + $datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $datepayment = ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datepayment); + print $form->selectDate($datepayment, '', '', '', 0, "add_paiement", 1, 1, 0, '', '', $facture->date); + print '
    '.$langs->trans('PaymentMode').''; - $form->select_types_paiements((GETPOST('paiementcode') ?GETPOST('paiementcode') : $facture->mode_reglement_code), 'paiementcode', '', 2); - print "
    '.$langs->trans('PaymentMode').''; + $form->select_types_paiements((GETPOST('paiementcode') ?GETPOST('paiementcode') : $facture->mode_reglement_code), 'paiementcode', '', 2); + print "
    '.$langs->trans('AccountToCredit').''.$langs->trans('AccountToDebit').''; - $form->select_comptes($accountid, 'accountid', 0, '', 2); - print ' 
    '.$langs->trans('AccountToCredit').''.$langs->trans('AccountToDebit').''; + $form->select_comptes($accountid, 'accountid', 0, '', 2); + print ' 
    '.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print '
    '.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
    '.$langs->trans('CheckTransmitter'); - print ' ('.$langs->trans("ChequeMaker").')'; - print '
    '.$langs->trans('CheckTransmitter'); + print ' ('.$langs->trans("ChequeMaker").')'; + print '
    '.$langs->trans('Bank'); - print ' ('.$langs->trans("ChequeBank").')'; - print '
    '.$langs->trans('Bank'); + print ' ('.$langs->trans("ChequeBank").')'; + print '
    '.$langs->trans('Comments').''; print '
    '; + print ''; - dol_fiche_end(); + print dol_get_fiche_end(); - /* + /* * List of unpaid invoices */ - $sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,'; - $sql .= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; + $sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,'; + $sql .= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql .= ' WHERE f.entity IN ('.getEntity('facture').')'; - $sql .= ' AND (f.fk_soc = '.$facture->socid; + $sql .= ' AND (f.fk_soc = '.$facture->socid; // Can pay invoices of all child of parent company if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; @@ -548,23 +548,23 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (!empty($conf->global->FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES)) { $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->id.')'; } - $sql .= ') AND f.paye = 0'; - $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled - if ($facture->type != Facture::TYPE_CREDIT_NOTE) - { - $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation - } else { - $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes - } - // Sort invoices by date and serial number: the older one comes first - $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; + $sql .= ') AND f.paye = 0'; + $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled + if ($facture->type != Facture::TYPE_CREDIT_NOTE) + { + $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation + } else { + $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes + } + // Sort invoices by date and serial number: the older one comes first + $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num > 0) - { + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num > 0) + { $arraytitle = $langs->trans('Invoice'); if ($facture->type == 2) $arraytitle = $langs->trans("CreditNotes"); $alreadypayedlabel = $langs->trans('Received'); @@ -574,55 +574,55 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake'); if ($facture->type == 2) { $remaindertopay = $langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack"); } - $i = 0; - //print ''; - print '
    '; - print ''; + $i = 0; + //print '\n"; - } - $db->free($resql); - } else { - dol_print_error($db); - } + print ''; + print ''; + print ''; // Autofilled + print ''; + print "\n"; + } + print "
    '; + print '
    '; + print ''; - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; - print ''; - print ''; - print ''; - print ''; - } - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + print ''; + print ''; + print ''; + print ''; + } + print ''; + print ''; + print ''; + print ''; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook - print ''; - print "\n"; + print ''; + print "\n"; - $total = 0; - $totalrecu = 0; - $totalrecucreditnote = 0; - $totalrecudeposits = 0; + $total = 0; + $totalrecu = 0; + $totalrecucreditnote = 0; + $totalrecudeposits = 0; - while ($i < $num) - { - $objp = $db->fetch_object($resql); + while ($i < $num) + { + $objp = $db->fetch_object($resql); - $sign = 1; - if ($facture->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; + $sign = 1; + if ($facture->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; $soc = new Societe($db); $soc->fetch($objp->socid); - $invoice = new Facture($db); - $invoice->fetch($objp->facid); - $paiement = $invoice->getSommePaiement(); - $creditnotes = $invoice->getSumCreditNotesUsed(); - $deposits = $invoice->getSumDepositsUsed(); - $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); + $invoice = new Facture($db); + $invoice->fetch($objp->facid); + $paiement = $invoice->getSommePaiement(); + $creditnotes = $invoice->getSumCreditNotesUsed(); + $deposits = $invoice->getSumDepositsUsed(); + $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); // Multicurrency Price if (!empty($conf->multicurrency->enabled)) { @@ -630,209 +630,209 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1); $multicurrency_deposits = $invoice->getSumDepositsUsed(1); $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT'); - $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); + $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); } print ''; print '\n"; + print $invoice->getNomUrl(1, ''); + if ($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; + print "\n"; - // Date - print '\n"; + // Date + print '\n"; - // Due date - if ($objp->dlr > 0) - { - print ''; - } else { - print ''; - } + print ''; + } else { + print ''; + } - // Currency - if (!empty($conf->multicurrency->enabled)) print '\n"; + // Currency + if (!empty($conf->multicurrency->enabled)) print '\n"; // Multicurrency Price if (!empty($conf->multicurrency->enabled)) { - print ''; + print ''; - // Multicurrency Price + // Multicurrency Price print ''; + print ''; - // Multicurrency remain to pay - print ''; + // Multicurrency remain to pay + print ''; - print '"; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + { + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + print ''; + print ''; + } else { + print ''; + print ''; + } + } + print ""; } // Price - print ''; + print ''; - // Received or paid back - print ''; + // Received or paid back + print ''; - // Remain to take or to pay back - print ''; - //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits)); + // Remain to take or to pay back + print ''; + //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits)); - // Amount - print '"; + print ''; + print ''; + } else { + print ''; + print ''; + } + print ""; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook - // Warning - print ''; + // Warning + print ''; - print "\n"; + print "\n"; - $total += $objp->total; - $total_ttc += $objp->total_ttc; - $totalrecu += $paiement; - $totalrecucreditnote += $creditnotes; - $totalrecudeposits += $deposits; - $i++; - } + $total += $objp->total; + $total_ttc += $objp->total_ttc; + $totalrecu += $paiement; + $totalrecucreditnote += $creditnotes; + $totalrecudeposits += $deposits; + $i++; + } - if ($i > 1) - { - // Print total - print ''; - print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; - print ''; - print ''; - print ''; - print ''; - } + if ($i > 1) + { + // Print total + print ''; + print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + print ''; + print ''; + print ''; + print ''; + } print ''; - print ''; - print ''; - print ''; // Autofilled - print ''; - print "\n"; - } - print "
    '.$arraytitle.''.$langs->trans('Date').''.$langs->trans('DateMaxPayment').''.$langs->trans('Currency').''.$langs->trans('MulticurrencyAmountTTC').''.$multicurrencyalreadypayedlabel.''.$multicurrencyremaindertopay.''.$langs->trans('MulticurrencyPaymentAmount').''.$langs->trans('AmountTTC').''.$alreadypayedlabel.''.$remaindertopay.''.$langs->trans('PaymentAmount').'
    '.$arraytitle.''.$langs->trans('Date').''.$langs->trans('DateMaxPayment').''.$langs->trans('Currency').''.$langs->trans('MulticurrencyAmountTTC').''.$multicurrencyalreadypayedlabel.''.$multicurrencyremaindertopay.''.$langs->trans('MulticurrencyPaymentAmount').''.$langs->trans('AmountTTC').''.$alreadypayedlabel.''.$remaindertopay.''.$langs->trans('PaymentAmount').' 
     
    '; - print $invoice->getNomUrl(1, ''); - if ($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; - print "'.dol_print_date($db->jdate($objp->df), 'day')."'.dol_print_date($db->jdate($objp->df), 'day')."'; - print dol_print_date($db->jdate($objp->dlr), 'day'); + // Due date + if ($objp->dlr > 0) + { + print ''; + print dol_print_date($db->jdate($objp->dlr), 'day'); - if ($invoice->hasDelay()) - { - print img_warning($langs->trans('Late')); - } + if ($invoice->hasDelay()) + { + print img_warning($langs->trans('Late')); + } - print ''.$objp->multicurrency_code."'.$objp->multicurrency_code."'; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $objp->multicurrency_total_ttc); - print ''; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $objp->multicurrency_total_ttc); + print ''; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - print price($sign * $multicurrency_payment); - if ($multicurrency_creditnotes) print '+'.price($multicurrency_creditnotes); - if ($multicurrency_deposits) print '+'.price($multicurrency_deposits); + print price($sign * $multicurrency_payment); + if ($multicurrency_creditnotes) print '+'.price($multicurrency_creditnotes); + if ($multicurrency_deposits) print '+'.price($multicurrency_deposits); } - print ''; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay); - print ''; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay); + print ''; + print ''; - // Add remind multicurrency amount - $namef = 'multicurrency_amount_'.$objp->facid; - $nameRemain = 'multicurrency_remain_'.$objp->facid; + // Add remind multicurrency amount + $namef = 'multicurrency_amount_'.$objp->facid; + $nameRemain = 'multicurrency_remain_'.$objp->facid; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { - if ($action != 'add_paiement') - { - if (!empty($conf->use_javascript_ajax)) - print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); - print ''; - print ''; - } else { - print ''; - print ''; - } - } - print "'.price($sign * $objp->total_ttc).''.price($sign * $objp->total_ttc).''.price($sign * $paiement); - if ($creditnotes) print '+'.price($creditnotes); - if ($deposits) print '+'.price($deposits); - print ''.price($sign * $paiement); + if ($creditnotes) print '+'.price($creditnotes); + if ($deposits) print '+'.price($deposits); + print ''.price($sign * $remaintopay).''.price($sign * $remaintopay).''; + // Amount + print ''; - // Add remind amount - $namef = 'amount_'.$objp->facid; - $nameRemain = 'remain_'.$objp->facid; + // Add remind amount + $namef = 'amount_'.$objp->facid; + $nameRemain = 'remain_'.$objp->facid; - if ($action != 'add_paiement') - { - if (!empty($conf->use_javascript_ajax)) + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); - print ''; - print ''; - } else { - print ''; - print ''; - } - print "'; - //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
    "; - if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id])) - || $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) - { - print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay")); - } - print '
    '; + //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
    "; + if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id])) + || $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) + { + print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay")); + } + print '
    '.$langs->trans('TotalTTC').'
    '.$langs->trans('TotalTTC').''.price($sign * $total_ttc).''.price($sign * $totalrecu); - if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); - if ($totalrecudeposits) print '+'.price($totalrecudeposits); - print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).' 
    "; - //print "
    '.price($sign * $totalrecu); + if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); + if ($totalrecudeposits) print '+'.price($totalrecudeposits); + print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).' 
    "; + //print "\n"; + } + $db->free($resql); + } else { + dol_print_error($db); + } - // Save button - if ($action != 'add_paiement') - { - $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically"); - if ($facture->type == Facture::TYPE_CREDIT_NOTE) $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically"); - $buttontitle = $langs->trans('ToMakePayment'); - if ($facture->type == Facture::TYPE_CREDIT_NOTE) $buttontitle = $langs->trans('ToMakePaymentBack'); + // Save button + if ($action != 'add_paiement') + { + $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically"); + if ($facture->type == Facture::TYPE_CREDIT_NOTE) $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically"); + $buttontitle = $langs->trans('ToMakePayment'); + if ($facture->type == Facture::TYPE_CREDIT_NOTE) $buttontitle = $langs->trans('ToMakePaymentBack'); - print '
    '; - print ' '.$checkboxlabel; - /*if (! empty($conf->prelevement->enabled)) + print '
    '; + print ' '.$checkboxlabel; + /*if (! empty($conf->prelevement->enabled)) { $langs->load("withdrawals"); if (! empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '
    '.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed"); }*/ - print '


    '; - print '
    '; - } + print '


    '; + print '
    '; + } - // Form to confirm payment - if ($action == 'add_paiement') - { - $preselectedchoice = $addwarning ? 'no' : 'yes'; + // Form to confirm payment + if ($action == 'add_paiement') + { + $preselectedchoice = $addwarning ? 'no' : 'yes'; - print '
    '; - if (!empty($totalpayment)) $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency)); + print '
    '; + if (!empty($totalpayment)) $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency)); if (!empty($multicurrency_totalpayment)) { $text .= '
    '.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); } - if (GETPOST('closepaidinvoices')) - { - $text .= '
    '.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); - print ''; - } - print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice); - } + if (GETPOST('closepaidinvoices')) + { + $text .= '
    '.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); + print ''; + } + print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice); + } - print "\n"; - } + print "\n"; + } } @@ -841,62 +841,62 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie */ if (!GETPOST('action', 'aZ09')) { - if (empty($page) || $page == -1) $page = 0; - $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; - $offset = $limit * $page; + if (empty($page) || $page == -1) $page = 0; + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; + $offset = $limit * $page; - if (!$sortorder) $sortorder = 'DESC'; - if (!$sortfield) $sortfield = 'p.datep'; + if (!$sortorder) $sortorder = 'DESC'; + if (!$sortfield) $sortfield = 'p.datep'; - $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref'; - $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql .= ', '.MAIN_DB_PREFIX.'facture as f'; - $sql .= ' WHERE p.fk_facture = f.rowid'; - $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; - if ($socid) - { - $sql .= ' AND f.fk_soc = '.$socid; - } + $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref'; + $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql .= ', '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' WHERE p.fk_facture = f.rowid'; + $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; + if ($socid) + { + $sql .= ' AND f.fk_soc = '.$socid; + } - $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; - $sql .= $db->plimit($limit + 1, $offset); - $resql = $db->query($sql); + $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; + $sql .= $db->plimit($limit + 1, $offset); + $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num); - print ''; - print ''; - print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right '); + print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num); + print '
    '; + print ''; + print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right '); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); - print "\n"; + print "\n"; - while ($i < min($num, $limit)) - { - $objp = $db->fetch_object($resql); + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($resql); - print ''; - print '\n"; - print '\n"; - print '\n"; - print ''; - print ''; - print ''; + print ''; + print '\n"; + print '\n"; + print '\n"; + print ''; + print ''; + print ''; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook - $i++; - } - print '
    '.$objp->ref."'.dol_print_date($db->jdate($objp->dp))."'.$objp->paiement_type.' '.$objp->num_payment."'.price($objp->amount).' 
    '.$objp->ref."'.dol_print_date($db->jdate($objp->dp))."'.$objp->paiement_type.' '.$objp->num_payment."'.price($objp->amount).' 
    '; - } + $i++; + } + print ''; + } } llxFooter(); diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index c6789aacfad..9d452ef52b3 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -57,18 +57,18 @@ $object = new Paiement($db); if ($action == 'setnote' && $user->rights->facture->paiement) { - $db->begin(); + $db->begin(); - $object->fetch($id); - $result = $object->update_note(GETPOST('note', 'restricthtml')); - if ($result > 0) - { - $db->commit(); - $action = ''; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); - } + $object->fetch($id); + $result = $object->update_note(GETPOST('note', 'restricthtml')); + if ($result > 0) + { + $db->commit(); + $action = ''; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } } if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->paiement) @@ -79,29 +79,29 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture-> $result = $object->delete(); if ($result > 0) { - $db->commit(); + $db->commit(); - if ($backtopage) - { - header("Location: ".$backtopage); - exit; - } else { - header("Location: list.php"); - exit; - } + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } else { + header("Location: list.php"); + exit; + } } else { - $langs->load("errors"); + $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); + $db->rollback(); } } -if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture->paiement) +if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture->paiement) { $db->begin(); - $object->fetch($id); - if ($object->valide($user) > 0) + $object->fetch($id); + if ($object->validate($user) > 0) { $db->commit(); @@ -126,7 +126,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture-> header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); exit; } else { - $langs->load("errors"); + $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } @@ -135,7 +135,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture-> if ($action == 'setnum_paiement' && !empty($_POST['num_paiement'])) { $object->fetch($id); - $res = $object->update_num($_POST['num_paiement']); + $res = $object->update_num($_POST['num_paiement']); if ($res === 0) { setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs'); @@ -177,7 +177,7 @@ $form = new Form($db); $head = payment_prepare_head($object); -dol_fiche_head($head, 'payment', $langs->trans("PaymentCustomerInvoice"), -1, 'payment'); +print dol_get_fiche_head($head, 'payment', $langs->trans("PaymentCustomerInvoice"), -1, 'payment'); // Confirmation of payment delete if ($action == 'delete') @@ -189,7 +189,7 @@ if ($action == 'delete') if ($action == 'valide') { $facid = $_GET['facid']; - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide', '', 0, 2); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_validate', '', 0, 2); } $linkback = ''.$langs->trans("BackToList").''; @@ -299,7 +299,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); /* @@ -332,9 +332,9 @@ if ($resql) print ''.$langs->trans('Company').''; if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)) print ''.$langs->trans('Entity').''; print ''.$langs->trans('ExpectedToPay').''; - print ''.$langs->trans('PayedByThisPayment').''; - print ''.$langs->trans('RemainderToPay').''; - print ''.$langs->trans('Status').''; + print ''.$langs->trans('PayedByThisPayment').''; + print ''.$langs->trans('RemainderToPay').''; + print ''.$langs->trans('Status').''; print "\n"; if ($num > 0) @@ -356,7 +356,7 @@ if ($resql) print ''; - // Invoice + // Invoice print ''; print $invoice->getNomUrl(1); print "\n"; @@ -376,11 +376,11 @@ if ($resql) // Expected to pay print ''.price($objp->total_ttc).''; - // Amount payed - print ''.price($objp->amount).''; + // Amount payed + print ''.price($objp->amount).''; - // Remain to pay - print ''.price($remaintopay).''; + // Remain to pay + print ''.price($remaintopay).''; // Status print ''.$invoice->getLibStatut(5, $alreadypayed).''; diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index b4927ae4503..4b93cb4cca3 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2011-2016 Juanjo Menent * Copyright (C) 2013 Philippe Grand * Copyright (C) 2015-2016 Alexandre Spangaro - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -68,37 +68,37 @@ $object = new RemiseCheque($db); if ($action == 'setdate' && $user->rights->banque->cheque) { - $result = $object->fetch(GETPOST('id', 'int')); - if ($result > 0) - { - //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $date = dol_mktime(0, 0, 0, $_POST['datecreate_month'], $_POST['datecreate_day'], $_POST['datecreate_year']); + $result = $object->fetch(GETPOST('id', 'int')); + if ($result > 0) + { + //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $date = dol_mktime(0, 0, 0, $_POST['datecreate_month'], $_POST['datecreate_day'], $_POST['datecreate_year']); - $result = $object->set_date($user, $date); - if ($result < 0) - { + $result = $object->set_date($user, $date); + if ($result < 0) + { setEventMessages($object->error, $object->errors, 'errors'); - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } } if ($action == 'setrefext' && $user->rights->banque->cheque) { - $result = $object->fetch(GETPOST('id', 'int')); - if ($result > 0) - { - $ref_ext = GETPOST('ref_ext'); + $result = $object->fetch(GETPOST('id', 'int')); + if ($result > 0) + { + $ref_ext = GETPOST('ref_ext'); - $result = $object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + $result = $object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } } if ($action == 'setref' && $user->rights->banque->cheque) @@ -125,30 +125,30 @@ if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->che $result = $object->create($user, $_POST["accountid"], 0, $_POST['toRemise']); if ($result > 0) { - if ($object->statut == 1) // If statut is validated, we build doc - { - $object->fetch($object->id); // To force to reload all properties in correct property name - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; - //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (!empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $object->generatePdf($_POST["model"], $outputlangs); - } + if ($object->statut == 1) // If statut is validated, we build doc + { + $object->fetch($object->id); // To force to reload all properties in correct property name + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; + //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $result = $object->generatePdf($_POST["model"], $outputlangs); + } - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); - exit; + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); + exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } else { setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'mesgs'); - $action = 'new'; + $action = 'new'; } } @@ -178,25 +178,25 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->c } } -if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->banque->cheque) +if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->banque->cheque) { $result = $object->fetch($id); $result = $object->validate($user); if ($result >= 0) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; - //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (!empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $object->generatePdf(GETPOST('model'), $outputlangs); + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; + //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $result = $object->generatePdf(GETPOST('model'), $outputlangs); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -229,15 +229,15 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) // Save last template used to generate document //if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; - //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (!empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; + //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } $result = $object->generatePdf($_POST["model"], $outputlangs); if ($result <= 0) { @@ -270,8 +270,8 @@ elseif ($action == 'remove_file' && $user->rights->banque->cheque) if (GETPOST('removefilter')) { - $filterdate = ''; - $filteraccountid = 0; + $filterdate = ''; + $filteraccountid = 0; } $title = $langs->trans("Cheques")." - ".$langs->trans("Card"); @@ -309,7 +309,7 @@ if ($action == 'new') // $head[$h][1] = $langs->trans("Info"); // $h++; - dol_fiche_head($head, $hselected, $langs->trans("Cheques"), -1, 'payment'); + print dol_get_fiche_head($head, $hselected, $langs->trans("Cheques"), -1, 'payment'); /* * Confirmation of slip's delete @@ -324,7 +324,7 @@ if ($action == 'new') */ if ($action == 'valide') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide', '', '', 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_validate', '', '', 1); } /* @@ -357,7 +357,7 @@ if ($action == 'new') print ''; print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print ''; //print ''; @@ -365,27 +365,27 @@ if ($action == 'new') print ''; - print ''; + print ''; print '
    '.$langs->trans('Date').''.dol_print_date($now,'day').'
    '.$langs->trans("DateChequeReceived").''; print $form->selectDate($filterdate, 'fd', 0, 0, 1, '', 1, 1); print '
    '.$langs->trans("BankAccount").''; - $form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1); - print '
    '.$langs->trans("BankAccount").''; + $form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1); + print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); - print '
    '; + print '
    '; print ''; - if ($filterdate || $filteraccountid > 0) - { - print '   '; - print ''; - } + if ($filterdate || $filteraccountid > 0) + { + print '   '; + print ''; + } print '
    '; - print ''; + print ''; print '
    '; $sql = "SELECT ba.rowid as bid, b.datec as datec, b.dateo as date, b.rowid as transactionid, "; $sql .= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque,"; - $sql .= " p.rowid as paymentid"; + $sql .= " p.rowid as paymentid, p.ref as paymentref"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)"; @@ -394,7 +394,7 @@ if ($action == 'new') $sql .= " AND b.fk_bordereau = 0"; $sql .= " AND b.amount > 0"; if ($filterdate) $sql .= " AND b.dateo = '".$db->idate($filterdate)."'"; - if ($filteraccountid > 0) $sql .= " AND ba.rowid = ".((int) $filteraccountid); + if ($filteraccountid > 0) $sql .= " AND ba.rowid = ".((int) $filteraccountid); $sql .= $db->order("b.dateo,b.rowid", "ASC"); $resql = $db->query($sql); @@ -411,6 +411,7 @@ if ($action == 'new') $lines[$obj->bid][$i]["banque"] = $obj->banque; $lines[$obj->bid][$i]["id"] = $obj->transactionid; $lines[$obj->bid][$i]["paymentid"] = $obj->paymentid; + $lines[$obj->bid][$i]["paymentref"] = $obj->paymentref; $i++; } @@ -422,7 +423,7 @@ if ($action == 'new') foreach ($accounts as $bid => $account_label) { - print ' + print ' '."\n"; } - print '
    '; - print ''; - print ''; + print ''; + print ''; + print ''; - print '
    '; - print '
    '; - print $langs->trans("Type").':   '; - print '
    '; - print ''; - print '   '; - print ''; - print '
    '; - print "
    \n"; + print '
    '; + print '
    '; + print $langs->trans("Type").':   '; + print '
    '; + print ''; + print '   '; + print ''; + print '
    '; + print "
    \n"; - dol_fiche_head(); + print dol_get_fiche_head(); - print ''; + print '
    '; - print ""; - print ''; + print ""; + print ''; - print ''; + print ''; // Label if ($refund == 1) { @@ -268,14 +268,14 @@ if ($action == 'create') // Amount print ''; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) + { print ''; - } + print ''; + } - // Type payment + // Type payment print '\n"; @@ -286,22 +286,22 @@ if ($action == 'create') print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print ''."\n"; - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - print '
    '.$langs->trans("DatePayment").''; - print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); - print '
    '.$langs->trans("DatePayment").''; + print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); + print '
    '.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; - print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1); - print '
    '.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; + print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1); + print '
    '.$langs->trans("Amount").'
    '.$langs->trans("BankAccount").''; $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 2); // List of bank account available - print '
    '.$langs->trans("PaymentMode").''; $form->select_types_paiements(GETPOST("type_payment"), "type_payment"); print "
    '; + print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; print '     '; - print ''; + print ''; print '
    '; - print '
    '; + print ''; } // View mode @@ -309,7 +309,7 @@ if ($id) { $head = vat_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("VATPayment"), -1, 'payment'); + print dol_get_fiche_head($head, 'card', $langs->trans("VATPayment"), -1, 'payment'); $morehtmlref = '
    '; // Label of social contribution @@ -369,7 +369,7 @@ if ($id) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); /* * Action buttons diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 5f661609e52..51cac4c7394 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -56,45 +56,50 @@ class Tva extends CommonObject public $num_payment; /** - * @var string label - */ - public $label; + * @var string label + */ + public $label; - /** - * @var int ID - */ + /** + * @var int ID + */ public $fk_bank; /** - * @var int ID - */ + * @var int accountid + */ + public $accountid; + + /** + * @var int ID + */ public $fk_user_creat; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - public function create($user) - { - global $conf, $langs; + /** + * Create in database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf, $langs; $error = 0; $now = dol_now(); @@ -123,7 +128,7 @@ class Tva extends CommonObject $sql .= "fk_bank,"; $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; @@ -136,41 +141,41 @@ class Tva extends CommonObject $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); - // Call trigger - $result = $this->call_trigger('TVA_CREATE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('TVA_CREATE', $user); + if ($result < 0) $error++; + // End call triggers - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { $this->db->rollback(); return -1; - } - } else { + } + } else { $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; - } - } + } + } - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; @@ -188,7 +193,7 @@ class Tva extends CommonObject $this->db->begin(); // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; $sql .= " tms='".$this->db->idate($this->tms)."',"; $sql .= " datep='".$this->db->idate($this->datep)."',"; $sql .= " datev='".$this->db->idate($this->datev)."',"; @@ -198,46 +203,46 @@ class Tva extends CommonObject $sql .= " fk_bank=".$this->fk_bank.","; $sql .= " fk_user_creat=".$this->fk_user_creat.","; $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id).""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = "Error ".$this->db->lasterror(); - $error++; - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = "Error ".$this->db->lasterror(); + $error++; + } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('TVA_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } + // Call trigger + $result = $this->call_trigger('TVA_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Load object in memory from database - * - * @param int $id id object - * @param User $user User that load - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $user = null) - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id id object + * @param User $user User that load + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $user = null) + { + global $langs; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.tms,"; @@ -255,20 +260,20 @@ class Tva extends CommonObject $sql .= " b.fk_type,"; $sql .= " b.rappro"; - $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; - $sql .= " WHERE t.rowid = ".$id; + $sql .= " WHERE t.rowid = ".$id; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); $this->datev = $this->db->jdate($obj->datev); @@ -283,23 +288,23 @@ class Tva extends CommonObject $this->fk_account = $obj->fk_account; $this->fk_type = $obj->fk_type; $this->rappro = $obj->rappro; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } /** - * Delete object in database - * - * @param User $user User that delete - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @return int <0 if KO, >0 if OK + */ public function delete($user) { global $conf, $langs; @@ -328,11 +333,11 @@ class Tva extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ public function initAsSpecimen() { @@ -350,154 +355,154 @@ class Tva extends CommonObject } - /** - * Balance of VAT - * - * @param int $year Year - * @return double Amount - */ - public function solde($year = 0) - { + /** + * Balance of VAT + * + * @param int $year Year + * @return double Amount + */ + public function solde($year = 0) + { - $reglee = $this->tva_sum_reglee($year); + $reglee = $this->tva_sum_reglee($year); - $payee = $this->tva_sum_payee($year); - $collectee = $this->tva_sum_collectee($year); + $payee = $this->tva_sum_payee($year); + $collectee = $this->tva_sum_collectee($year); - $solde = $reglee - ($collectee - $payee); + $solde = $reglee - ($collectee - $payee); - return $solde; - } + return $solde; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Total of the VAT from invoices emitted by the thirdparty. - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_collectee($year = 0) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Total of the VAT from invoices emitted by the thirdparty. + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_collectee($year = 0) + { + // phpcs:enable - $sql = "SELECT sum(f.tva) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; - if ($year) - { - $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; - } + $sql = "SELECT sum(f.tva) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; + if ($year) + { + $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); $ret = $obj->amount; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * VAT payed - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_payee($year = 0) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * VAT payed + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_payee($year = 0) + { + // phpcs:enable - $sql = "SELECT sum(f.total_tva) as total_tva"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - if ($year) - { - $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; - } + $sql = "SELECT sum(f.total_tva) as total_tva"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + if ($year) + { + $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->total_tva; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $ret = $obj->total_tva; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Total of the VAT payed - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_reglee($year = 0) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Total of the VAT payed + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_reglee($year = 0) + { + // phpcs:enable - $sql = "SELECT sum(f.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."tva as f"; + $sql = "SELECT sum(f.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as f"; - if ($year) - { - $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' "; - } + if ($year) + { + $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->amount; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $ret = $obj->amount; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - /** - * Create in database - * + /** + * Create in database + * * @param User $user Object user that insert * @return int <0 if KO, rowid in tva table if OK - */ - public function addPayment($user) - { - global $conf, $langs; + */ + public function addPayment($user) + { + global $conf, $langs; - $this->db->begin(); + $this->db->begin(); - // Clean parameters - $this->amount = price2num(trim($this->amount)); - $this->label = trim($this->label); + // Clean parameters + $this->amount = price2num(trim($this->amount)); + $this->label = trim($this->label); $this->note = trim($this->note); $this->num_payment = trim($this->num_payment); $this->fk_bank = (int) $this->fk_bank; @@ -505,81 +510,81 @@ class Tva extends CommonObject $this->fk_user_modif = (int) $this->fk_user_modif; if (empty($this->datec)) $this->datec = dol_now(); - // Check parameters + // Check parameters if (!$this->label) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } - if ($this->amount == '') - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - return -4; - } - if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -5; - } - if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -5; - } + if ($this->amount == '') + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + return -4; + } + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + return -5; + } + if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + return -5; + } - // Insert into llx_tva - $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva ("; - $sql .= "datec"; - $sql .= ", datep"; - $sql .= ", datev"; + // Insert into llx_tva + $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva ("; + $sql .= "datec"; + $sql .= ", datep"; + $sql .= ", datev"; $sql .= ", amount"; $sql .= ", fk_typepayment"; $sql .= ", num_payment"; if ($this->note) $sql .= ", note"; - if ($this->label) $sql .= ", label"; - $sql .= ", fk_user_creat"; + if ($this->label) $sql .= ", label"; + $sql .= ", fk_user_creat"; $sql .= ", fk_bank"; $sql .= ", entity"; $sql .= ") "; - $sql .= " VALUES ("; - $sql .= " '".$this->db->idate($this->datec)."'"; - $sql .= ", '".$this->db->idate($this->datep)."'"; - $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= " VALUES ("; + $sql .= " '".$this->db->idate($this->datec)."'"; + $sql .= ", '".$this->db->idate($this->datep)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; $sql .= ", ".$this->amount; - $sql .= ", '".$this->db->escape($this->type_payment)."'"; + $sql .= ", '".$this->db->escape($this->type_payment)."'"; $sql .= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; - if ($this->label) $sql .= ", '".$this->db->escape($this->label)."'"; - $sql .= ", '".$this->db->escape($user->id)."'"; + if ($this->label) $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->escape($user->id)."'"; $sql .= ", NULL"; $sql .= ", ".$conf->entity; - $sql .= ")"; + $sql .= ")"; dol_syslog(get_class($this)."::addPayment", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat' + $result = $this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat' - // Call trigger - //XXX: Should be done just befor commit no ? - $result = $this->call_trigger('TVA_ADDPAYMENT', $user); - if ($result < 0) - { - $this->id = 0; - $ok = 0; - } - // End call triggers + // Call trigger + //XXX: Should be done just befor commit no ? + $result = $this->call_trigger('TVA_ADDPAYMENT', $user); + if ($result < 0) + { + $this->id = 0; + $ok = 0; + } + // End call triggers - if ($this->id > 0) - { - $ok = 1; + if ($this->id > 0) + { + $ok = 1; if (!empty($conf->banque->enabled) && !empty($this->amount)) - { - // Insert into llx_bank - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + { + // Insert into llx_bank + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acc = new Account($this->db); + $acc = new Account($this->db); $result = $acc->fetch($this->accountid); if ($result <= 0) dol_print_error($this->db); @@ -589,23 +594,23 @@ class Tva extends CommonObject $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), $this->num_payment, '', $user); } - // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction - if ($bank_line_id > 0) + // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction + if ($bank_line_id > 0) { - $this->update_fk_bank($bank_line_id); - } else { + $this->update_fk_bank($bank_line_id); + } else { $this->error = $acc->error; $ok = 0; } - // Update links - $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat"); - if ($result < 0) - { - $this->error = $acc->error; - $ok = 0; - } - } + // Update links + $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat"); + if ($result < 0) + { + $this->error = $acc->error; + $ok = 0; + } + } if ($ok) { @@ -615,27 +620,27 @@ class Tva extends CommonObject $this->db->rollback(); return -3; } - } else { - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } + } else { + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Update link between payment tva and line generate into llx_bank - * - * @param int $id_bank Id bank account + * + * @param int $id_bank Id bank account * @return int <0 if KO, >0 if OK - */ + */ public function update_fk_bank($id_bank) { - // phpcs:enable + // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.(int) $id_bank; $sql .= ' WHERE rowid = '.(int) $this->id; $result = $this->db->query($sql); @@ -653,8 +658,8 @@ class Tva extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option link option - * @param int $notooltip 1=Disable tooltip - * @param string $morecss More CSS + * @param int $notooltip 1=Disable tooltip + * @param string $morecss More CSS * @return string Chaine with URL */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '') @@ -669,23 +674,23 @@ class Tva extends CommonObject $label .= '
    '; $label .= ''.$langs->trans('Ref').': '.$this->ref; - $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id; - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + $linkclose = ''; + if (empty($notooltip)) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; $picto = 'payment'; @@ -698,34 +703,34 @@ class Tva extends CommonObject } /** - * Return amount of payments already done - * - * @return int Amount of payment already done, <0 if KO - */ - public function getSommePaiement() - { - $table = 'paiementcharge'; - $field = 'fk_charge'; + * Return amount of payments already done + * + * @return int Amount of payment already done, <0 if KO + */ + public function getSommePaiement() + { + $table = 'paiementcharge'; + $field = 'fk_charge'; - $sql = 'SELECT sum(amount) as amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$table; - $sql .= ' WHERE '.$field.' = '.$this->id; + $sql = 'SELECT sum(amount) as amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; + $sql .= ' WHERE '.$field.' = '.$this->id; - dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $amount = 0; + dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $amount = 0; - $obj = $this->db->fetch_object($resql); - if ($obj) $amount = $obj->amount ? $obj->amount : 0; + $obj = $this->db->fetch_object($resql); + if ($obj) $amount = $obj->amount ? $obj->amount : 0; - $this->db->free($resql); - return $amount; - } else { - return -1; - } - } + $this->db->free($resql); + return $amount; + } else { + return -1; + } + } /** * Informations of vat payment object @@ -780,10 +785,10 @@ class Tva extends CommonObject */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->statut, $mode); + return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -791,11 +796,11 @@ class Tva extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage - return ''; - } + return ''; + } } diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index a91d637c39d..d4acecf063d 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -53,10 +53,10 @@ $year = GETPOST("year", "int"); if (empty($year)) { $year_current = $current_date['year']; - $year_start = $year_current; + $year_start = $year_current; } else { - $year_current = $year; - $year_start = $year; + $year_current = $year; + $year_start = $year; } $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); @@ -64,35 +64,35 @@ $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endda if (empty($date_start) || empty($date_end)) // We define date_start and date_end { $q = GETPOST("q", "int"); - if (empty($q)) - { - if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); } else { - if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter - $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); - $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat - if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { - if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year - $year_start--; - } - } else { - if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year - $year_start--; - } - } - $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); - $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month - $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); - $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; - } - } - } else { - if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } - if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } - if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } - if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } - } + if (empty($q)) + { + if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); } else { + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); + $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { + if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year + $year_start--; + } + } else { + if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year + $year_start--; + } + } + $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); + $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); + $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + } + } + } else { + if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } + if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } + if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } + if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } + } } $min = price2num(GETPOST("min", "alpha")); @@ -130,12 +130,12 @@ $morequerystring = ''; $listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); foreach ($listofparams as $param) { - if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); + if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); } $special_report = false; if (isset($_REQUEST['extra_report']) && $_REQUEST['extra_report'] == 1) { - $special_report = true; + $special_report = true; } llxHeader('', $langs->trans("VATReport"), '', '', 0, 0, '', '', $morequerystring); @@ -158,18 +158,18 @@ $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '. $prevyear = $year_start; $prevquarter = $q; if ($prevquarter > 1) { - $prevquarter--; + $prevquarter--; } else { - $prevquarter = 4; - $prevyear--; + $prevquarter = 4; + $prevyear--; } $nextyear = $year_start; $nextquarter = $q; if ($nextquarter < 4) { - $nextquarter++; + $nextquarter++; } else { - $nextquarter = 1; - $nextyear++; + $nextquarter = 1; + $nextyear++; } $builddate = dol_now(); @@ -178,7 +178,7 @@ if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->t if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '
    '.$langs->trans("RulesVATDueServices"); if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '
    '.$langs->trans("RulesVATInServices"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $description .= '
    '.$langs->trans("DepositsAreNotIncluded"); + $description .= '
    '.$langs->trans("DepositsAreNotIncluded"); } if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
    '.$langs->trans("ThisIsAnEstimatedValue"); @@ -186,15 +186,15 @@ if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
    '.$langs $description .= ($description ? '
    ' : '').$fsearch; if (!empty($conf->global->TAX_REPORT_EXTRA_REPORT)) { - $description .= '
    '; - $description .= ' '; - $description .= $langs->trans('SimpleReport'); - $description .= ''; - $description .= '
    '; - $description .= ' '; - $description .= $langs->trans('AddExtraReport'); - $description .= ''; - $description .= '
    '; + $description .= '
    '; + $description .= ' '; + $description .= $langs->trans('SimpleReport'); + $description .= ''; + $description .= '
    '; + $description .= ' '; + $description .= $langs->trans('AddExtraReport'); + $description .= ''; + $description .= '
    '; } $elementcust = $langs->trans("CustomersInvoices"); @@ -202,13 +202,13 @@ $productcust = $langs->trans("Description"); $namerate = $langs->trans("VATRate"); $amountcust = $langs->trans("AmountHT"); if ($mysoc->tva_assuj) { - $vatcust .= ' ('.$langs->trans("StatusToPay").')'; + $vatcust .= ' ('.$langs->trans("StatusToPay").')'; } $elementsup = $langs->trans("SuppliersInvoices"); $productsup = $langs->trans("Description"); $amountsup = $langs->trans("AmountHT"); if ($mysoc->tva_assuj) { - $vatsup .= ' ('.$langs->trans("ToGetBack").')'; + $vatsup .= ' ('.$langs->trans("ToGetBack").')'; } report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); @@ -231,529 +231,529 @@ $x_paye = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'bu if (!is_array($x_coll) || !is_array($x_paye)) { - $langs->load("errors"); - if ($x_coll == -1) { - print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; - } elseif ($x_coll == -2) { - print ''.$langs->trans("FeatureNotYetAvailable").''; - } else { - print ''.$langs->trans("Error").''; - } + $langs->load("errors"); + if ($x_coll == -1) { + print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; + } elseif ($x_coll == -2) { + print ''.$langs->trans("FeatureNotYetAvailable").''; + } else { + print ''.$langs->trans("Error").''; + } } else { - $x_both = array(); - //now, from these two arrays, get another array with one rate per line - foreach (array_keys($x_coll) as $my_coll_thirdpartyid) - { - $x_both[$my_coll_thirdpartyid]['coll']['totalht'] = $x_coll[$my_coll_thirdpartyid]['totalht']; - $x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat']; - $x_both[$my_coll_thirdpartyid]['paye']['totalht'] = 0; - $x_both[$my_coll_thirdpartyid]['paye']['vat'] = 0; - $x_both[$my_coll_thirdpartyid]['coll']['links'] = ''; - $x_both[$my_coll_thirdpartyid]['coll']['detail'] = array(); - foreach ($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) { - $invoice_customer->id = $x_coll[$my_coll_thirdpartyid]['facid'][$id]; - $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid]['facnum'][$id]; - $invoice_customer->type = $x_coll[$my_coll_thirdpartyid]['type'][$id]; - $company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]); - $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( - 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], - 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], - 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], - 'pref' =>$x_coll[$my_coll_thirdpartyid]['pref'][$id], - 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], - 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], - 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], - 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], - 'dtype' =>$x_coll[$my_coll_thirdpartyid]['dtype'][$id], - 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], - 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], - 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], - 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], - 'vat' =>$x_coll[$my_coll_thirdpartyid]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1, '', 12) - ); - } - } - // tva paid - foreach (array_keys($x_paye) as $my_paye_thirdpartyid) { - $x_both[$my_paye_thirdpartyid]['paye']['totalht'] = $x_paye[$my_paye_thirdpartyid]['totalht']; - $x_both[$my_paye_thirdpartyid]['paye']['vat'] = $x_paye[$my_paye_thirdpartyid]['vat']; - if (!isset($x_both[$my_paye_thirdpartyid]['coll']['totalht'])) { - $x_both[$my_paye_thirdpartyid]['coll']['totalht'] = 0; - $x_both[$my_paye_thirdpartyid]['coll']['vat'] = 0; - } - $x_both[$my_paye_thirdpartyid]['paye']['links'] = ''; - $x_both[$my_paye_thirdpartyid]['paye']['detail'] = array(); + $x_both = array(); + //now, from these two arrays, get another array with one rate per line + foreach (array_keys($x_coll) as $my_coll_thirdpartyid) + { + $x_both[$my_coll_thirdpartyid]['coll']['totalht'] = $x_coll[$my_coll_thirdpartyid]['totalht']; + $x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat']; + $x_both[$my_coll_thirdpartyid]['paye']['totalht'] = 0; + $x_both[$my_coll_thirdpartyid]['paye']['vat'] = 0; + $x_both[$my_coll_thirdpartyid]['coll']['links'] = ''; + $x_both[$my_coll_thirdpartyid]['coll']['detail'] = array(); + foreach ($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) { + $invoice_customer->id = $x_coll[$my_coll_thirdpartyid]['facid'][$id]; + $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid]['facnum'][$id]; + $invoice_customer->type = $x_coll[$my_coll_thirdpartyid]['type'][$id]; + $company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]); + $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( + 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], + 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], + 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], + 'pref' =>$x_coll[$my_coll_thirdpartyid]['pref'][$id], + 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], + 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], + 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], + 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], + 'dtype' =>$x_coll[$my_coll_thirdpartyid]['dtype'][$id], + 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], + 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], + 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], + 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], + 'vat' =>$x_coll[$my_coll_thirdpartyid]['vat_list'][$id], + 'link' =>$invoice_customer->getNomUrl(1, '', 12) + ); + } + } + // tva paid + foreach (array_keys($x_paye) as $my_paye_thirdpartyid) { + $x_both[$my_paye_thirdpartyid]['paye']['totalht'] = $x_paye[$my_paye_thirdpartyid]['totalht']; + $x_both[$my_paye_thirdpartyid]['paye']['vat'] = $x_paye[$my_paye_thirdpartyid]['vat']; + if (!isset($x_both[$my_paye_thirdpartyid]['coll']['totalht'])) { + $x_both[$my_paye_thirdpartyid]['coll']['totalht'] = 0; + $x_both[$my_paye_thirdpartyid]['coll']['vat'] = 0; + } + $x_both[$my_paye_thirdpartyid]['paye']['links'] = ''; + $x_both[$my_paye_thirdpartyid]['paye']['detail'] = array(); - foreach ($x_paye[$my_paye_thirdpartyid]['facid'] as $id=>$dummy) - { - // ExpenseReport - if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment') - { - $expensereport->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; - $expensereport->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; - $expensereport->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; + foreach ($x_paye[$my_paye_thirdpartyid]['facid'] as $id=>$dummy) + { + // ExpenseReport + if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment') + { + $expensereport->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; + $expensereport->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; + $expensereport->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; - $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], - 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], - 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], - 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], - 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], - 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), - 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], - 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], - 'ddate_start' =>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], - 'link' =>$expensereport->getNomUrl(1) - ); - } else { - $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; - $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; - $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; - $company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]); - $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], - 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], - 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], - 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], - 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], - 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), - 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], - 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], - 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], - 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1, '', 12) - ); - } - } - } - //now we have an array (x_both) indexed by rates for coll and paye + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'ddate_start' =>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' =>$expensereport->getNomUrl(1) + ); + } else { + $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; + $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; + $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; + $company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]); + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], + 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' =>$invoice_supplier->getNomUrl(1, '', 12) + ); + } + } + } + //now we have an array (x_both) indexed by rates for coll and paye - //print table headers for this quadri - incomes first + //print table headers for this quadri - incomes first - $x_coll_sum = 0; - $x_coll_ht = 0; - $x_paye_sum = 0; - $x_paye_ht = 0; + $x_coll_sum = 0; + $x_coll_ht = 0; + $x_paye_sum = 0; + $x_paye_ht = 0; - $span = $columns; - if ($modetax != 1) $span += 2; + $span = $columns; + if ($modetax != 1) $span += 2; - //print ''..')'; + //print ''..')'; - // Customers invoices - print ''; - print ''.$elementcust.''; - print ''.$langs->trans("DateInvoice").''; - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; - else print ''; - print ''.$namerate.''; - print ''.$productcust.''; - if ($modetax != 1) - { - print ''.$amountcust.''; - print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; - } - print ''.$langs->trans("AmountHTVATRealReceived").''; - print ''.$vatcust.''; - print ''; + // Customers invoices + print ''; + print ''.$elementcust.''; + print ''.$langs->trans("DateInvoice").''; + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; + else print ''; + print ''.$namerate.''; + print ''.$productcust.''; + if ($modetax != 1) + { + print ''.$amountcust.''; + print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; + } + print ''.$langs->trans("AmountHTVATRealReceived").''; + print ''.$vatcust.''; + print ''; - $action = "tvadetail"; - $parameters["mode"] = $modetax; - $parameters["start"] = $date_start; - $parameters["end"] = $date_end; - $parameters["type"] = 'vat'; + $action = "tvadetail"; + $parameters["mode"] = $modetax; + $parameters["start"] = $date_start; + $parameters["end"] = $date_end; + $parameters["type"] = 'vat'; - $object = array(&$x_coll, &$x_paye, &$x_both); - // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array - $hookmanager->initHooks(array('externalbalance')); - $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $object = array(&$x_coll, &$x_paye, &$x_both); + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - foreach (array_keys($x_coll) as $thirdparty_id) { - $subtot_coll_total_ht = 0; - $subtot_coll_vat = 0; + foreach (array_keys($x_coll) as $thirdparty_id) { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) - { - if (is_array($x_both[$thirdparty_id]['coll']['detail'])) - { - // VAT Rate - print ""; - print ''; - if (is_numeric($thirdparty_id)) { - $company_static->fetch($thirdparty_id); - print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); - } else { - $tmpid = preg_replace('/userid_/', '', $thirdparty_id); - $user_static->fetch($tmpid); - print $langs->trans("User").': '.$user_static->getNomUrl(1); - } - print ''; - print ''."\n"; + if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) + { + if (is_array($x_both[$thirdparty_id]['coll']['detail'])) + { + // VAT Rate + print ""; + print ''; + if (is_numeric($thirdparty_id)) { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); + } else { + $tmpid = preg_replace('/userid_/', '', $thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User").': '.$user_static->getNomUrl(1); + } + print ''; + print ''."\n"; - foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - print ''; + print ''; - // Ref - print ''.$fields['link'].''; + // Ref + print ''.$fields['link'].''; - // Invoice date - print ''.dol_print_date($fields['datef'], 'day').''; + // Invoice date + print ''.dol_print_date($fields['datef'], 'day').''; - // Payment date - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { - print ''.dol_print_date($fields['datep'], 'day').''; - } else { - print ''; - } + // Payment date + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + print ''.dol_print_date($fields['datep'], 'day').''; + } else { + print ''; + } - // Rate - print ''.$fields['drate'].''; + // Rate + print ''.$fields['drate'].''; - // Description - print ''; - if ($fields['pid']) { - $product_static->id = $fields['pid']; - $product_static->ref = $fields['pref']; - $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) { - print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - } - } else { - if ($type) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } - if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { - if ($reg[1] == 'DEPOSIT') { - $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); - } elseif ($reg[1] == 'CREDIT_NOTE') { - $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); - } else { - $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); - } - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + // Description + print ''; + if ($fields['pid']) { + $product_static->id = $fields['pid']; + $product_static->ref = $fields['pref']; + $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + } + } else { + if ($type) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { + if ($reg[1] == 'DEPOSIT') { + $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1] == 'CREDIT_NOTE') { + $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - // Show range - print_date_range($fields['ddate_start'], $fields['ddate_end']); - } - print ''; + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); + } + print ''; - // Total HT - if ($modetax != 1) { - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; - } - print ''; - } + // Total HT + if ($modetax != 1) { + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + } - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) { - print ''; - //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) { - $payment_static->id = $fields['payment_id']; - print $payment_static->getNomUrl(2); - } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { - print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - print price(price2num($fields['payment_amount'], 'MT')); - if (isset($fields['payment_amount'])) { - print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; - } - } - print ''; - } + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) { + print ''; + //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) { + $payment_static->id = $fields['payment_id']; + print $payment_static->getNomUrl(2); + } + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'], 'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; + } + } + print ''; + } - // Total collected - print ''; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - print price(price2num($temp_ht, 'MT'), 1); - print ''; + // Total collected + print ''; + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT'), 1); + print ''; - // VAT - print ''; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - print price(price2num($temp_vat, 'MT'), 1); - //print price($fields['vat']); - print ''; - print ''; + // VAT + print ''; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + print price(price2num($temp_vat, 'MT'), 1); + //print price($fields['vat']); + print ''; + print ''; - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; - } - } - // Total customers for this vat rate - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; - print ''.price(price2num($subtot_coll_vat, 'MT')).''; - print ''; - } - } + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + // Total customers for this vat rate + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; + print ''.price(price2num($subtot_coll_vat, 'MT')).''; + print ''; + } + } - if (count($x_coll) == 0) // Show a total ine if nothing shown - { - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; - print ''; - } + if (count($x_coll) == 0) // Show a total ine if nothing shown + { + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } - // Blank line - print ' '; + // Blank line + print ' '; - // Print table headers for this quadri - expenses now - print ''; - print ''.$elementsup.''; - print ''.$langs->trans("DateInvoice").''; - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; - else print ''; - print ''.$namesup.''; - print ''.$productsup.''; - if ($modetax != 1) { - print ''.$amountsup.''; - print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; - } - print ''.$langs->trans("AmountHTVATRealPaid").''; - print ''.$vatsup.''; - print ''."\n"; + // Print table headers for this quadri - expenses now + print ''; + print ''.$elementsup.''; + print ''.$langs->trans("DateInvoice").''; + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; + else print ''; + print ''.$namesup.''; + print ''.$productsup.''; + if ($modetax != 1) { + print ''.$amountsup.''; + print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; + } + print ''.$langs->trans("AmountHTVATRealPaid").''; + print ''.$vatsup.''; + print ''."\n"; - foreach (array_keys($x_paye) as $thirdparty_id) - { - $subtot_paye_total_ht = 0; - $subtot_paye_vat = 0; + foreach (array_keys($x_paye) as $thirdparty_id) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; - if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['paye']['totalht'] > $min)) { - if (is_array($x_both[$thirdparty_id]['paye']['detail'])) { - print ""; - print ''; - if (is_numeric($thirdparty_id)) { - $company_static->fetch($thirdparty_id); - print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); - } else { - $tmpid = preg_replace('/userid_/', '', $thirdparty_id); - $user_static->fetch($tmpid); - print $langs->trans("User").': '.$user_static->getNomUrl(1); - } - print ''; - print ''."\n"; + if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['paye']['totalht'] > $min)) { + if (is_array($x_both[$thirdparty_id]['paye']['detail'])) { + print ""; + print ''; + if (is_numeric($thirdparty_id)) { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); + } else { + $tmpid = preg_replace('/userid_/', '', $thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User").': '.$user_static->getNomUrl(1); + } + print ''; + print ''."\n"; - foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index => $fields) { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index => $fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - print ''; + print ''; - // Ref - print ''.$fields['link'].''; + // Ref + print ''.$fields['link'].''; - // Invoice date - print ''.dol_print_date($fields['datef'], 'day').''; + // Invoice date + print ''.dol_print_date($fields['datef'], 'day').''; - // Payment date - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { - print ''.dol_print_date($fields['datep'], 'day').''; - } else { - print ''; - } + // Payment date + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + print ''.dol_print_date($fields['datep'], 'day').''; + } else { + print ''; + } - // Company name - print ''.$fields['company_link'].''; + // Company name + print ''.$fields['company_link'].''; - // Description - print ''; - if ($fields['pid']) { - $product_static->id = $fields['pid']; - $product_static->ref = $fields['pref']; - $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) { - print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - } - } else { - if ($type) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } - if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { - if ($reg[1] == 'DEPOSIT') { - $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); - } elseif ($reg[1] == 'CREDIT_NOTE') { - $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); - } else { - $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); - } - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + // Description + print ''; + if ($fields['pid']) { + $product_static->id = $fields['pid']; + $product_static->ref = $fields['pref']; + $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + } + } else { + if ($type) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { + if ($reg[1] == 'DEPOSIT') { + $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1] == 'CREDIT_NOTE') { + $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - // Show range - print_date_range($fields['ddate_start'], $fields['ddate_end']); - } - print ''; + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); + } + print ''; - // Total HT - if ($modetax != 1) { - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; - } - print ''; - } + // Total HT + if ($modetax != 1) { + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + } - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $paymentfourn_static->id = $fields['payment_id']; - print $paymentfourn_static->getNomUrl(2); - } + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + print ''; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $paymentfourn_static->id = $fields['payment_id']; + print $paymentfourn_static->getNomUrl(2); + } - if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) - { - print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - print price(price2num($fields['payment_amount'], 'MT')); - if (isset($fields['payment_amount'])) { - print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; - } - } - print ''; - } + if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) + { + print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'], 'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; + } + } + print ''; + } - // VAT paid - print ''; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - print price(price2num($temp_ht, 'MT'), 1); - print ''; + // VAT paid + print ''; + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT'), 1); + print ''; - // VAT - print ''; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - print price(price2num($temp_vat, 'MT'), 1); - //print price($fields['vat']); - print ''; - print ''; + // VAT + print ''; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + print price(price2num($temp_vat, 'MT'), 1); + //print price($fields['vat']); + print ''; + print ''; - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; - } - } - // Total suppliers for this vat rate - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; - print ''.price(price2num($subtot_paye_vat, 'MT')).''; - print ''; - } - } + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + // Total suppliers for this vat rate + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; + print ''.price(price2num($subtot_paye_vat, 'MT')).''; + print ''; + } + } - if (count($x_paye) == 0) { // Show a total line if nothing shown - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; - print ''; - } + if (count($x_paye) == 0) { // Show a total line if nothing shown + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } - // Total to pay - print ''; + // Total to pay + print ''; - $diff = $x_coll_sum - $x_paye_sum; - print ''; - print ''.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').''; - print ''.price(price2num($diff, 'MT'))."\n"; - print "\n"; + $diff = $x_coll_sum - $x_paye_sum; + print ''; + print ''.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').''; + print ''.price(price2num($diff, 'MT'))."\n"; + print "\n"; - $i++; + $i++; } print ''; diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 830dfb78d3a..e310e61fcb8 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -36,8 +36,8 @@ 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)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page @@ -58,7 +58,7 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { - $page = 0; + $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; @@ -82,10 +82,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if ($action == 'setlib' && $user->rights->tax->charges->creer) { - $object->fetch($id); - $result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); + $object->fetch($id); + $result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); } @@ -104,9 +104,9 @@ if ($object->id) { $alreadypayed = $object->getSommePaiement(); - $head = vat_prepare_head($object); + $head = vat_prepare_head($object); - dol_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment'); + print dol_get_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment'); $morehtmlref = '
    '; // Label of social contribution @@ -123,33 +123,33 @@ if ($object->id) print '
    '; print '
    '; - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) - { - $totalsize += $file['size']; - } + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) + { + $totalsize += $file['size']; + } - print ''; + print '
    '; - print ''; - print ''; - print '
    '.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
    '.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
    '; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; + print ''; - print '
    '; + print '
    '; - print '
    '; + print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); - $permission = $user->rights->tax->charges->creer; - $permtoedit = $user->rights->fournisseur->facture->creer; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $permission = $user->rights->tax->charges->creer; + $permtoedit = $user->rights->fournisseur->facture->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { - print $langs->trans("ErrorUnknown"); + print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index a4fd1293b4d..4a16d996ab8 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -108,100 +108,100 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); */ function pt($db, $sql, $date) { - global $conf, $bc, $langs; + global $conf, $bc, $langs; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; - $total = 0; - print ''; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print '
    '; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print ''; + print ''; + print "\n"; - $totalclaimed = 0; - $totalpaid = 0; - $amountclaimed = 0; - $amountpaid = 0; - $previousmonth = ''; - $previousmode = ''; - $mode = ''; + $totalclaimed = 0; + $totalpaid = 0; + $amountclaimed = 0; + $amountpaid = 0; + $previousmonth = ''; + $previousmode = ''; + $mode = ''; - while ($i < $num) { - $obj = $db->fetch_object($result); - $mode = $obj->mode; + while ($i < $num) { + $obj = $db->fetch_object($result); + $mode = $obj->mode; - //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; - if ($obj->mode == 'claimed' && !empty($previousmode)) - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; + //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; + if ($obj->mode == 'claimed' && !empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - } + $amountclaimed = 0; + $amountpaid = 0; + } - if ($obj->mode == 'claimed') - { - $amountclaimed = $obj->mm; - $totalclaimed = $totalclaimed + $amountclaimed; - } - if ($obj->mode == 'paid') - { - $amountpaid = $obj->mm; - $totalpaid = $totalpaid + $amountpaid; - } + if ($obj->mode == 'claimed') + { + $amountclaimed = $obj->mm; + $totalclaimed = $totalclaimed + $amountclaimed; + } + if ($obj->mode == 'paid') + { + $amountpaid = $obj->mm; + $totalpaid = $totalpaid + $amountpaid; + } - if ($obj->mode == 'paid') - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - $previousmode = ''; - $previousmonth = ''; - } else { - $previousmode = $obj->mode; - $previousmonth = $obj->dm; - } + if ($obj->mode == 'paid') + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; + $previousmonth = ''; + } else { + $previousmode = $obj->mode; + $previousmonth = $obj->dm; + } - $i++; - } + $i++; + } - if ($mode == 'claimed' && !empty($previousmode)) - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; + if ($mode == 'claimed' && !empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - } + $amountclaimed = 0; + $amountpaid = 0; + } - print ''; - print ''; - print ''; - print ''; - print ""; + print ''; + print ''; + print ''; + print ''; + print ""; - print "
    '.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
    '.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
    '.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
    '.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
    '.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
    '.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
    '.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
    '.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
    '.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
    '.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
    "; + print ""; - $db->free($result); - } else { - dol_print_error($db); - } + $db->free($result); + } else { + dol_print_error($db); + } } @@ -392,144 +392,144 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc } //now we have an array (x_both) indexed by rates for coll and paye - $action = "tva"; - $object = array(&$x_coll, &$x_paye, &$x_both); - $parameters["mode"] = $modetax; - $parameters["year"] = $y; - $parameters["month"] = $m; - $parameters["type"] = 'vat'; + $action = "tva"; + $object = array(&$x_coll, &$x_paye, &$x_both); + $parameters["mode"] = $modetax; + $parameters["year"] = $y; + $parameters["month"] = $m; + $parameters["type"] = 'vat'; - // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array - $hookmanager->initHooks(array('externalbalance')); - $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) - { - $langs->load("errors"); - print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) - { - print ''.$langs->trans("FeatureNotYetAvailable").''; - break; - } + if (!is_array($x_coll) && $coll_listbuy == -1) + { + $langs->load("errors"); + print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; + break; + } + if (!is_array($x_paye) && $coll_listbuy == -2) + { + print ''.$langs->trans("FeatureNotYetAvailable").''; + break; + } - print ''; - print ''.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''; + print ''; + print ''.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''; - $x_coll_sum = 0; - foreach (array_keys($x_coll) as $rate) - { - $subtot_coll_total_ht = 0; - $subtot_coll_vat = 0; + $x_coll_sum = 0; + foreach (array_keys($x_coll) as $rate) + { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) - { - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - //print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - } - } - //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; - } - } - print ''.price(price2num($x_coll_sum, 'MT')).''; + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + print ''.price(price2num($x_coll_sum, 'MT')).''; - $x_paye_sum = 0; - foreach (array_keys($x_paye) as $rate) - { - $subtot_paye_total_ht = 0; - $subtot_paye_vat = 0; + $x_paye_sum = 0; + foreach (array_keys($x_paye) as $rate) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; - foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) - { - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - //print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - } - } - //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; - } - } - print ''.price(price2num($x_paye_sum, 'MT')).''; + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + print ''.price(price2num($x_paye_sum, 'MT')).''; - $subtotalcoll = $subtotalcoll + $x_coll_sum; - $subtotalpaye = $subtotalpaye + $x_paye_sum; + $subtotalcoll = $subtotalcoll + $x_coll_sum; + $subtotalpaye = $subtotalpaye + $x_paye_sum; - $diff = $x_coll_sum - $x_paye_sum; - $total = $total + $diff; - $subtotal = price2num($subtotal + $diff, 'MT'); + $diff = $x_coll_sum - $x_paye_sum; + $total = $total + $diff; + $subtotal = price2num($subtotal + $diff, 'MT'); - print ''.price(price2num($diff, 'MT')).''."\n"; - print " \n"; - print "\n"; + print ''.price(price2num($diff, 'MT')).''."\n"; + print " \n"; + print "\n"; - $i++; $m++; - if ($i > 2) - { - print ''; - print ''.$langs->trans("SubTotal").':'; - print ''.price(price2num($subtotalcoll, 'MT')).''; - print ''.price(price2num($subtotalpaye, 'MT')).''; - print ''.price(price2num($subtotal, 'MT')).''; - print ' '; - $i = 0; - $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; - } + $i++; $m++; + if ($i > 2) + { + print ''; + print ''.$langs->trans("SubTotal").':'; + print ''.price(price2num($subtotalcoll, 'MT')).''; + print ''.price(price2num($subtotalpaye, 'MT')).''; + print ''.price(price2num($subtotal, 'MT')).''; + print ' '; + $i = 0; + $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; + } } print ''.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).''; print " \n"; @@ -578,37 +578,37 @@ if (!empty($conf->global->MAIN_FEATURES_LEVEL)) * Recap */ - print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation + print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation - $sql1 = "SELECT SUM(amount) as mm"; - $sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f"; - $sql1 .= " WHERE f.entity = ".$conf->entity; - $sql1 .= " AND f.datev >= '".$db->idate($date_start)."'"; - $sql1 .= " AND f.datev <= '".$db->idate($date_end)."'"; + $sql1 = "SELECT SUM(amount) as mm"; + $sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f"; + $sql1 .= " WHERE f.entity = ".$conf->entity; + $sql1 .= " AND f.datev >= '".$db->idate($date_start)."'"; + $sql1 .= " AND f.datev <= '".$db->idate($date_end)."'"; - $result = $db->query($sql1); - if ($result) { - $obj = $db->fetch_object($result); - print ''; + $result = $db->query($sql1); + if ($result) { + $obj = $db->fetch_object($result); + print '
    '; - print ""; - print ''; - print ''; - print "\n"; + print ""; + print ''; + print ''; + print "\n"; - print ""; - print ''; - print '\n"; - print "\n"; + print ""; + print ''; + print '\n"; + print "\n"; - $restopay = $total - $obj->mm; - print ""; - print ''; - print ''; - print "\n"; + $restopay = $total - $obj->mm; + print ""; + print ''; + print ''; + print "\n"; - print '
    '.$langs->trans("VATDue").''.price(price2num($total, 'MT')).'
    '.$langs->trans("VATDue").''.price(price2num($total, 'MT')).'
    '.$langs->trans("VATPaid").''.price(price2num($obj->mm, 'MT'))."
    '.$langs->trans("VATPaid").''.price(price2num($obj->mm, 'MT'))."
    '.$langs->trans("RemainToPay").''.price(price2num($restopay, 'MT')).'
    '.$langs->trans("RemainToPay").''.price(price2num($restopay, 'MT')).'
    '; - } + print ''; + } } print '
    '; diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index 5ef3956bd35..ddabf6e2b49 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -68,7 +68,7 @@ $object->info($id); $head = vat_prepare_head($object); -dol_fiche_head($head, 'info', $langs->trans("VATPayment"), -1, 'payment'); +print dol_get_fiche_head($head, 'info', $langs->trans("VATPayment"), -1, 'payment'); $morehtmlref = '
    '; // Label of social contribution @@ -89,7 +89,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); llxFooter(); diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 554143e7a7e..a142518279f 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -44,26 +44,26 @@ $langs->loadLangs(array('compta', 'bills')); $action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$optioncss = GETPOST('optioncss', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'salestaxeslist'; $search_ref = GETPOST('search_ref', 'alpha'); -$search_label = GETPOST('search_label', 'alpha'); -$search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int')); -$search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int')); -$search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int')); -$search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int')); -$search_type = GETPOST('search_type', 'int'); -$search_cheque = GETPOST('search_cheque', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int')); +$search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int')); +$search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int')); +$search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int')); +$search_type = GETPOST('search_type', 'int'); +$search_cheque = GETPOST('search_cheque', 'alpha'); $search_account = GETPOST('search_account', 'int'); $search_amount = GETPOST('search_amount', 'alpha'); -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); -if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -357,13 +357,13 @@ while ($i < min($num, $limit)) { } // Label - if (!empty($arrayfields['t.label']['checked'])) { + if (!empty($arrayfields['t.label']['checked'])) { print ''.dol_trunc($obj->label, 40).''; if (!$i) $totalarray['nbfield']++; } // Date end period - if (!empty($arrayfields['t.datev']['checked'])) { + if (!empty($arrayfields['t.datev']['checked'])) { print ''.dol_print_date($db->jdate($obj->datev), 'day').''; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 8fb4c32bf72..ba12b08b3b0 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -159,16 +159,16 @@ $prevyear = $year_start; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; } else { - $prevquarter = 4; - $prevyear--; + $prevquarter = 4; + $prevyear--; } $nextyear = $year_start; $nextquarter = $q; if ($nextquarter < 4) { $nextquarter++; } else { - $nextquarter = 1; - $nextyear++; + $nextquarter = 1; + $nextyear++; } $description .= $fsearch; $builddate = dol_now(); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 23a6042fbf9..2aeb2e4e2a1 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -67,17 +67,17 @@ $objcanvas = null; $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('contact', 'contactcard', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('contact', 'contactcard', $canvas); } if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -110,19 +110,19 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { - $actioncode = ''; - $search_agenda_label = ''; - } + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $actioncode = ''; + $search_agenda_label = ''; + } } @@ -140,138 +140,138 @@ llxHeader('', $title, $help_url); if ($socid > 0) { - $objsoc = new Societe($db); - $objsoc->fetch($socid); + $objsoc = new Societe($db); + $objsoc->fetch($socid); } if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { - // ----------------------------------------- - // When used with CANVAS - // ----------------------------------------- - if (empty($object->error) && $id) + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + if (empty($object->error) && $id) { $object = new Contact($db); $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template + $objcanvas->display_canvas($action); // Show template } else { - // ----------------------------------------- - // When used in standard mode - // ----------------------------------------- + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- - // Confirm deleting contact - if ($user->rights->societe->contact->supprimer) - { - if ($action == 'delete') - { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); - } - } + // Confirm deleting contact + if ($user->rights->societe->contact->supprimer) + { + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + } + } - /* + /* * Onglets */ - $head = array(); - if ($id > 0) - { - // Si edition contact deja existant - $object = new Contact($db); - $res = $object->fetch($id, $user); - if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res = $object->fetch_optionals(); - if ($res < 0) { dol_print_error($db, $object->error); exit; } + $head = array(); + if ($id > 0) + { + // Si edition contact deja existant + $object = new Contact($db); + $res = $object->fetch($id, $user); + if ($res < 0) { dol_print_error($db, $object->error); exit; } + $res = $object->fetch_optionals(); + if ($res < 0) { dol_print_error($db, $object->error); exit; } - // Show tabs - $head = contact_prepare_head($object); + // Show tabs + $head = contact_prepare_head($object); - $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); - } + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); + } - if (!empty($id) && $action != 'edit' && $action != 'create') - { - $objsoc = new Societe($db); + if (!empty($id) && $action != 'edit' && $action != 'create') + { + $objsoc = new Societe($db); - /* + /* * Fiche en mode visualisation */ - dol_htmloutput_errors($error, $errors); + dol_htmloutput_errors($error, $errors); - dol_fiche_head($head, 'agenda', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'agenda', $title, -1, 'contact'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
    '; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
    '; + $morehtmlref = '
    '; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
    '; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
    '; + print '
    '; - print '
    '; + print '
    '; - $object->info($id); - dol_print_object_info($object, 1); + $object->info($id); + dol_print_object_info($object, 1); - print '
    '; + print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); - // Actions buttons + // Actions buttons - $objcon = $object; - $object->fetch_thirdparty(); - $objthirdparty = $object->thirdparty; + $objcon = $object; + $object->fetch_thirdparty(); + $objthirdparty = $object->thirdparty; - $out = ''; - $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) - { + $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 (!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); - } - } + $newcardbutton = ''; + if (!empty($conf->agenda->enabled)) + { + 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))) - { - print '
    '; + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) + { + print '
    '; - $param = '&id='.$id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + $param = '&id='.$id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - print load_fiche_titre($langs->trans("ActionsOnContact"), $newcardbutton, ''); - //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1); + print load_fiche_titre($langs->trans("ActionsOnContact"), $newcardbutton, ''); + //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1); - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; - show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode, '', $filters, $sortfield, $sortorder); - } - } + show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } + } } diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 415d9e47790..f6f6fa0b45e 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -27,15 +27,15 @@ */ abstract class ActionsContactCardCommon { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $dirmodule; - public $targetmodule; - public $canvas; - public $card; + public $dirmodule; + public $targetmodule; + public $canvas; + public $card; //! Template container public $tpl = array(); @@ -55,14 +55,14 @@ abstract class ActionsContactCardCommon /** - * Get object + * Get object * - * @param int $id Object id - * @return object Object loaded - */ - public function getObject($id) - { - /*$ret = $this->getInstanceDao(); + * @param int $id Object id + * @return object Object loaded + */ + public function getObject($id) + { + /*$ret = $this->getInstanceDao(); if (is_object($this->object) && method_exists($this->object,'fetch')) { @@ -70,39 +70,39 @@ abstract class ActionsContactCardCommon } else {*/ - $object = new Contact($this->db); - if (!empty($id)) $object->fetch($id); - $this->object = $object; - //} - } + $object = new Contact($this->db); + if (!empty($id)) $object->fetch($id); + $this->object = $object; + //} + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set content of ->tpl array, to use into template - * - * @param string $action Type of action - * @param int $id Id - * @return string HTML output - */ - public function assign_values(&$action, $id) - { - // phpcs:enable - global $conf, $langs, $user, $canvas; - global $form, $formcompany, $objsoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set content of ->tpl array, to use into template + * + * @param string $action Type of action + * @param int $id Id + * @return string HTML output + */ + public function assign_values(&$action, $id) + { + // phpcs:enable + global $conf, $langs, $user, $canvas; + global $form, $formcompany, $objsoc; - if ($action == 'add' || $action == 'update') $this->assign_post(); + if ($action == 'add' || $action == 'update') $this->assign_post(); - foreach ($this->object as $key => $value) - { - $this->tpl[$key] = $value; - } + foreach ($this->object as $key => $value) + { + $this->tpl[$key] = $value; + } - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; - if ($action == 'create' || $action == 'edit') - { - if ($conf->use_javascript_ajax) + if ($action == 'create' || $action == 'edit') + { + if ($conf->use_javascript_ajax) { $this->tpl['ajax_selectcountry'] = "\n".''."\n"; } - if (is_object($objsoc) && $objsoc->id > 0) - { - $this->tpl['company'] = $objsoc->getNomUrl(1); - $this->tpl['company_id'] = $objsoc->id; - } else { - $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); - } + if (is_object($objsoc) && $objsoc->id > 0) + { + $this->tpl['company'] = $objsoc->getNomUrl(1); + $this->tpl['company_id'] = $objsoc->id; + } else { + $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); + } - // Civility - $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); + // Civility + $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); - // Predefined with third party - if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) - { - if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; - if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; - if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; - if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->phone; - if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax; - if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; - } + // Predefined with third party + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) + { + if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; + if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; + if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; + if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->phone; + if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax; + if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; + } - // Zip - $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + // Zip + $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); - // Town - $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + // Town + $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; + if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; - // Country - $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); - $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + // Country + $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); + $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; - if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - // State - if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); - else $this->tpl['select_state'] = $countrynotdefined; + // State + if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); + else $this->tpl['select_state'] = $countrynotdefined; - // Public or private - $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); - $this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0); - } + // Public or private + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); + $this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0); + } - if ($action == 'view' || $action == 'edit' || $action == 'delete') - { - // Emailing - if (!empty($conf->mailing->enabled)) + if ($action == 'view' || $action == 'edit' || $action == 'delete') + { + // Emailing + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); } - // Linked element - $this->tpl['contact_element'] = array(); - $i = 0; + // Linked element + $this->tpl['contact_element'] = array(); + $i = 0; - $this->object->load_ref_elements(); + $this->object->load_ref_elements(); - if (!empty($conf->commande->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder"); - $i++; - } - if (!empty($conf->propal->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal"); - $i++; - } - if (!empty($conf->contrat->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts"); - $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)) - { - $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++; - } + if (!empty($conf->commande->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder"); + $i++; + } + if (!empty($conf->propal->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal"); + $i++; + } + if (!empty($conf->contrat->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts"); + $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)) + { + $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++; + } - // Dolibarr user - if ($this->object->user_id) + // Dolibarr user + if ($this->object->user_id) { $dolibarr_user = new User($this->db); $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); - } + } - if ($action == 'view' || $action == 'delete') - { - $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); + if ($action == 'view' || $action == 'delete') + { + $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); - if ($this->object->socid > 0) - { - $objsoc = new Societe($this->db); + if ($this->object->socid > 0) + { + $objsoc = new Societe($this->db); - $objsoc->fetch($this->object->socid); - $this->tpl['company'] = $objsoc->getNomUrl(1); - } else { - $this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany"); - } + $objsoc->fetch($this->object->socid); + $this->tpl['company'] = $objsoc->getNomUrl(1); + } else { + $this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany"); + } - $this->tpl['civility'] = $this->object->getCivilityLabel(); + $this->tpl['civility'] = $this->object->getCivilityLabel(); - $this->tpl['address'] = dol_nl2br($this->object->address); + $this->tpl['address'] = dol_nl2br($this->object->address); - $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); + $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); - $img = picto_from_langcode($this->object->country_code); - $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; + $img = picto_from_langcode($this->object->country_code); + $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; - $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX'); - $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); + $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX'); + $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); - $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv); + $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv); - $this->tpl['note'] = nl2br($this->object->note); - } + $this->tpl['note'] = nl2br($this->object->note); + } - if ($action == 'create_user') - { - // Full firstname and lastname separated with a dot : firstname.lastname - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $login = dol_buildlogin($this->object->lastname, $this->object->firstname); + if ($action == 'create_user') + { + // Full firstname and lastname separated with a dot : firstname.lastname + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $login = dol_buildlogin($this->object->lastname, $this->object->firstname); - $generated_password = getRandomPassword(false); - $password = $generated_password; + $generated_password = getRandomPassword(false); + $password = $generated_password; - // Create a form array - $formquestion = array( - array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), - array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); + // Create a form array + $formquestion = array( + array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), + array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); - $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateContact"), "confirm_create_user", $formquestion, 'no'); - } - } + $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateContact"), "confirm_create_user", $formquestion, 'no'); + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Assign POST values into object - * - * @return string HTML output - */ - private function assign_post() - { - // phpcs:enable - global $langs, $mysoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Assign POST values into object + * + * @return string HTML output + */ + private function assign_post() + { + // phpcs:enable + global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; - $this->object->socid = $_POST["socid"]; - $this->object->lastname = $_POST["name"]; - $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; - $this->object->poste = $_POST["poste"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_pro = $_POST["phone_pro"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; - $this->object->fax = $_POST["fax"]; - $this->object->email = $_POST["email"]; - $this->object->jabberid = $_POST["jabberid"]; - $this->object->priv = $_POST["priv"]; - $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->socid = $_POST["socid"]; + $this->object->lastname = $_POST["name"]; + $this->object->firstname = $_POST["firstname"]; + $this->object->civility_id = $_POST["civility_id"]; + $this->object->poste = $_POST["poste"]; + $this->object->address = $_POST["address"]; + $this->object->zip = $_POST["zipcode"]; + $this->object->town = $_POST["town"]; + $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; + $this->object->state_id = $_POST["state_id"]; + $this->object->phone_pro = $_POST["phone_pro"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; + $this->object->fax = $_POST["fax"]; + $this->object->email = $_POST["email"]; + $this->object->jabberid = $_POST["jabberid"]; + $this->object->priv = $_POST["priv"]; + $this->object->note = $_POST["note"]; + $this->object->canvas = $_POST["canvas"]; - // We set country_id, and country_code label of the chosen country - if ($this->object->country_id) - { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - } else { - dol_print_error($this->db); - } - $this->object->country_id = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; - } - } + // We set country_id, and country_code label of the chosen country + if ($this->object->country_id) + { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + } else { + dol_print_error($this->db); + } + $this->object->country_id = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; + } + } } diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index 099c973b0a4..d399584b48d 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -29,22 +29,22 @@ include_once DOL_DOCUMENT_ROOT.'/contact/canvas/actions_contactcard_common.class */ class ActionsContactCardDefault extends ActionsContactCardCommon { - /** - * Constructor - * - * @param DoliDB $db Handler acces base de donnees - * @param string $dirmodule Name of directory of module - * @param string $targetmodule Name of directory of module where canvas is stored - * @param string $canvas Name of canvas - * @param string $card Name of tab (sub-canvas) - */ - public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) - { - $this->db = $db; - $this->dirmodule = $dirmodule; - $this->targetmodule = $targetmodule; - $this->canvas = $canvas; - $this->card = $card; + /** + * Constructor + * + * @param DoliDB $db Handler acces base de donnees + * @param string $dirmodule Name of directory of module + * @param string $targetmodule Name of directory of module where canvas is stored + * @param string $canvas Name of canvas + * @param string $card Name of tab (sub-canvas) + */ + public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) + { + $this->db = $db; + $this->dirmodule = $dirmodule; + $this->targetmodule = $targetmodule; + $this->canvas = $canvas; + $this->card = $card; } /** @@ -66,7 +66,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -76,50 +76,50 @@ class ActionsContactCardDefault extends ActionsContactCardCommon */ public function assign_values(&$action, $id) { - // phpcs:enable + // phpcs:enable global $limit, $offset, $sortfield, $sortorder; global $conf, $db, $langs, $user; global $form; $ret = $this->getObject($id); - parent::assign_values($action, $id); + parent::assign_values($action, $id); - $this->tpl['title'] = $this->getTitle($action); - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['title'] = $this->getTitle($action); + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; if ($action == 'view') { - // Card header - $head = contact_prepare_head($this->object); - $title = $this->getTitle($action); + // Card header + $head = contact_prepare_head($this->object); + $title = $this->getTitle($action); - $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'contact'); - $this->tpl['showend'] = dol_get_fiche_end(); + $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'contact'); + $this->tpl['showend'] = dol_get_fiche_end(); - $objsoc = new Societe($db); - $objsoc->fetch($this->object->socid); + $objsoc = new Societe($db); + $objsoc->fetch($this->object->socid); - $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); - $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->societe->contact->supprimer) - { - $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); - } + if ($action == 'delete' && $user->rights->societe->contact->supprimer) + { + $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + } } if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); + $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -129,13 +129,13 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - public function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { - // phpcs:enable - global $conf, $langs; + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) + { + // phpcs:enable + global $conf, $langs; - //$this->getFieldList(); + //$this->getFieldList(); - $this->list_datas = array(); - } + $this->list_datas = array(); + } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index e4e7ecaf5fb..ad646af15b0 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2019 Josep Lluís Amador * Copyright (C) 2020 Open-Dsi * @@ -55,7 +55,7 @@ $action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); $confirm = GETPOST('confirm', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $id = GETPOST('id', 'int'); -$socid = GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); $object = new Contact($db); $extrafields = new ExtraFields($db); @@ -178,15 +178,15 @@ if (empty($reshook)) $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); $object->socid = GETPOST("socid", 'int'); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->civility_code = GETPOST("civility_code", 'alpha'); - $object->poste = GETPOST("poste", 'alpha'); - $object->address = GETPOST("address", 'alpha'); - $object->zip = GETPOST("zipcode", 'alpha'); - $object->town = GETPOST("town", 'alpha'); - $object->country_id = GETPOST("country_id", 'int'); - $object->state_id = GETPOST("state_id", 'int'); + $object->lastname = (string) GETPOST("lastname", 'alpha'); + $object->firstname = (string) GETPOST("firstname", 'alpha'); + $object->civility_code = (string) GETPOST("civility_code", 'alpha'); + $object->poste = (string) GETPOST("poste", 'alpha'); + $object->address = (string) GETPOST("address", 'alpha'); + $object->zip = (string) GETPOST("zipcode", 'alpha'); + $object->town = (string) GETPOST("town", 'alpha'); + $object->country_id = (int) GETPOST("country_id", 'int'); + $object->state_id = (int) GETPOST("state_id", 'int'); //$object->jabberid = GETPOST("jabberid", 'alpha'); //$object->skype = GETPOST("skype", 'alpha'); //$object->twitter = GETPOST("twitter", 'alpha'); @@ -196,22 +196,22 @@ if (empty($reshook)) if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { - $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + $object->socialnetworks[$key] = (string) GETPOST($key, 'alphanohtml'); } } } - $object->email = GETPOST("email", 'alpha'); + $object->email = (string) GETPOST("email", 'alpha'); $object->no_email = GETPOST("no_email", "int"); - $object->phone_pro = GETPOST("phone_pro", 'alpha'); - $object->phone_perso = GETPOST("phone_perso", 'alpha'); - $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); - $object->fax = GETPOST("fax", 'alpha'); + $object->phone_pro = (string) GETPOST("phone_pro", 'alpha'); + $object->phone_perso = (string) GETPOST("phone_perso", 'alpha'); + $object->phone_mobile = (string) GETPOST("phone_mobile", 'alpha'); + $object->fax = (string) GETPOST("fax", 'alpha'); $object->priv = GETPOST("priv", 'int'); - $object->note_public = GETPOST("note_public", 'restricthtml'); - $object->note_private = GETPOST("note_private", 'restricthtml'); + $object->note_public = (string) GETPOST("note_public", 'restricthtml'); + $object->note_private = (string) GETPOST("note_private", 'restricthtml'); $object->roles = GETPOST("roles", 'array'); - $object->statut = 1; //Defult status to Actif + $object->statut = 1; //Default status to Actif // Note: Correct date should be completed with location to have exact GM time of birth. $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth", 'int'), GETPOST("birthdayday", 'int'), GETPOST("birthdayyear", 'int')); @@ -225,9 +225,9 @@ if (empty($reshook)) $action = 'create'; } - if (!GETPOST("lastname")) - { - $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); + if (!GETPOST("lastname")) { + $error++; + $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); $action = 'create'; } @@ -236,7 +236,8 @@ if (empty($reshook)) $id = $object->create($user); if ($id <= 0) { - $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); + $error++; + $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); $action = 'create'; } else { // Categories association @@ -278,14 +279,12 @@ if (empty($reshook)) $result = $object->fetch($id); $object->oldcopy = clone $object; - $object->old_lastname = GETPOST("old_lastname"); - $object->old_firstname = GETPOST("old_firstname"); + $object->old_lastname = (string) GETPOST("old_lastname", 'alpha'); + $object->old_firstname = (string) GETPOST("old_firstname", 'alpha'); $result = $object->delete(); - if ($result > 0) - { - if ($backtopage) - { + if ($result > 0) { + if ($backtopage) { header("Location: ".$backtopage); exit; } else { @@ -360,22 +359,22 @@ if (empty($reshook)) $object->oldcopy = clone $object; - $object->old_lastname = GETPOST("old_lastname", 'alpha'); - $object->old_firstname = GETPOST("old_firstname", 'alpha'); + $object->old_lastname = (string) GETPOST("old_lastname", 'alpha'); + $object->old_firstname = (string) GETPOST("old_firstname", 'alpha'); $object->socid = GETPOST("socid", 'int'); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->civility_code = GETPOST("civility_code", 'alpha'); - $object->poste = GETPOST("poste", 'alpha'); + $object->lastname = (string) GETPOST("lastname", 'alpha'); + $object->firstname = (string) GETPOST("firstname", 'alpha'); + $object->civility_code = (string) GETPOST("civility_code", 'alpha'); + $object->poste = (string) GETPOST("poste", 'alpha'); - $object->address = GETPOST("address", 'alpha'); - $object->zip = GETPOST("zipcode", 'alpha'); - $object->town = GETPOST("town", 'alpha'); - $object->state_id = GETPOST("state_id", 'int'); - $object->country_id = GETPOST("country_id", 'int'); + $object->address = (string) GETPOST("address", 'alpha'); + $object->zip = (string) GETPOST("zipcode", 'alpha'); + $object->town = (string) GETPOST("town", 'alpha'); + $object->state_id = GETPOST("state_id", 'int'); + $object->country_id = GETPOST("country_id", 'int'); - $object->email = GETPOST("email", 'alpha'); + $object->email = (string) GETPOST("email", 'alpha'); $object->no_email = GETPOST("no_email", "int"); //$object->jabberid = GETPOST("jabberid", 'alpha'); //$object->skype = GETPOST("skype", 'alpha'); @@ -386,17 +385,17 @@ if (empty($reshook)) if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { - $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + $object->socialnetworks[$key] = (string) GETPOST($key, 'alphanohtml'); } } } - $object->phone_pro = GETPOST("phone_pro", 'alpha'); - $object->phone_perso = GETPOST("phone_perso", 'alpha'); - $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); - $object->fax = GETPOST("fax", 'alpha'); - $object->priv = GETPOST("priv", 'int'); - $object->note_public = GETPOST("note_public", 'restricthtml'); - $object->note_private = GETPOST("note_private", 'restricthtml'); + $object->phone_pro = (string) GETPOST("phone_pro", 'alpha'); + $object->phone_perso = (string) GETPOST("phone_perso", 'alpha'); + $object->phone_mobile = (string) GETPOST("phone_mobile", 'alpha'); + $object->fax = (string) GETPOST("fax", 'alpha'); + $object->priv = (string) GETPOST("priv", 'int'); + $object->note_public = (string) GETPOST("note_public", 'restricthtml'); + $object->note_private = (string) GETPOST("note_private", 'restricthtml'); $object->roles = GETPOST("roles", 'array'); // Fill array 'array_options' with data from add form @@ -611,7 +610,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; } - dol_fiche_head($head, 'card', '', 0, ''); + print dol_get_fiche_head($head, 'card', '', 0, ''); print ''; @@ -873,7 +872,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print "
    "; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -940,7 +939,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; if (!empty($backtopage)) print ''; - dol_fiche_head($head, 'card', $title, 0, 'contact'); + print dol_get_fiche_head($head, 'card', $title, 0, 'contact'); print ''; @@ -1237,7 +1236,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1249,21 +1248,21 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } } - // Select mail models is same action as presend - if (GETPOST('modelselected', 'alpha')) { - $action = 'presend'; - } + // Select mail models is same action as presend + if (GETPOST('modelselected', 'alpha')) { + $action = 'presend'; + } - if (!empty($id) && $action != 'edit' && $action != 'create') - { - $objsoc = new Societe($db); + if (!empty($id) && $action != 'edit' && $action != 'create') + { + $objsoc = new Societe($db); // View mode // Show errors dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); - dol_fiche_head($head, 'card', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'card', $title, -1, 'contact'); if ($action == 'create_user') { @@ -1482,7 +1481,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
    '; print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); // Barre d'actions print '
    '; @@ -1559,7 +1558,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $modelmail = 'contact'; $defaulttopic = 'Information'; $diroutput = $conf->contact->dir_output; - $trackid = 'con'.$object->id; + $trackid = 'ctc'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 91a32f39f26..1185ce5ecf8 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -131,80 +131,106 @@ class Contact extends CommonObject public $civility; /** - * Address - * @var string + * @var string Address */ public $address; + + /** + * @var string zip code + */ public $zip; + + /** + * @var string Town + */ public $town; public $state_id; // Id of department public $state_code; // Code of department public $state; // Label of department - public $poste; // Position + public $poste; // Position public $socid; // fk_soc public $statut; // 0=inactif, 1=actif public $code; - /** - * Email - * @var string - */ + /** + * Email + * @var string + */ public $email; - /** - * Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings + /** + * Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings * @var int - */ + */ public $no_email; - /** - * @var array array of socialnetworks - */ - public $socialnetworks; + /** + * @var array array of socialnetworks + */ + public $socialnetworks; - /** - * Skype username - * @var string - * @deprecated - */ + /** + * Skype username + * @var string + * @deprecated + */ public $skype; /** - * Twitter username - * @var string - * @deprecated - */ + * Twitter username + * @var string + * @deprecated + */ public $twitter; /** - * Facebook username - * @var string - * @deprecated - */ + * Facebook username + * @var string + * @deprecated + */ public $facebook; /** - * Linkedin username - * @var string - * @deprecated - */ - public $linkedin; + * Linkedin username + * @var string + * @deprecated + */ + public $linkedin; - /** - * Jabber username - * @var string - * @deprecated - */ + /** + * Jabber username + * @var string + * @deprecated + */ public $jabberid; + /** + * @var string filename for photo + */ public $photo; + + /** + * @var string phone pro + */ public $phone_pro; + + /** + * @var string phone perso + */ public $phone_perso; + + /** + * @var string phone mobile + */ public $phone_mobile; + + /** + * @var string fax + */ public $fax; /** @@ -227,10 +253,10 @@ class Contact extends CommonObject // END MODULEBUILDER PROPERTIES - /** - * Old copy - * @var Contact - */ + /** + * Old copy + * @var Contact + */ public $oldcopy; // To contains a clone of this when we need to save old properties of object public $roles = array(); @@ -253,9 +279,12 @@ class Contact extends CommonObject $this->db = $db; $this->statut = 1; // By default, status is enabled - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; - if (empty($conf->mailing->enabled)) $this->fields['no_email']['enabled'] = 0; - + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->mailing->enabled)) { + $this->fields['no_email']['enabled'] = 0; + } // typical ['s.nom'] is used for third-parties if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $this->fields['fk_soc']['enabled'] = 0; @@ -268,10 +297,8 @@ class Contact extends CommonObject } // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } @@ -281,7 +308,7 @@ class Contact extends CommonObject { foreach($this->fields as $key => $val) { - if (is_array($val['arrayofkeyval'])) + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { foreach($val['arrayofkeyval'] as $key2 => $val2) { @@ -292,7 +319,7 @@ class Contact extends CommonObject }*/ } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators into this->nb for board * @@ -300,7 +327,7 @@ class Contact extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable global $user; $this->nb = array(); @@ -310,14 +337,14 @@ class Contact extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $clause = "AND"; } $sql .= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; $sql .= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; - if ($user->socid > 0) $sql .= " AND sp.fk_soc = ".$user->socid; + if ($user->socid > 0) $sql .= " AND sp.fk_soc = ".$user->socid; $resql = $this->db->query($sql); if ($resql) @@ -352,11 +379,9 @@ class Contact extends CommonObject // Clean parameters $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name); - $this->firstname = trim($this->firstname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname)); - if (empty($this->socid)) $this->socid = 0; + $this->firstname = trim($this->firstname); + $this->setUpperOrLowerCase(); + if (empty($this->socid)) $this->socid = 0; if (empty($this->priv)) $this->priv = 0; if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request @@ -365,11 +390,11 @@ class Contact extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; $sql .= " datec"; $sql .= ", fk_soc"; - $sql .= ", lastname"; - $sql .= ", firstname"; - $sql .= ", fk_user_creat"; + $sql .= ", lastname"; + $sql .= ", firstname"; + $sql .= ", fk_user_creat"; $sql .= ", priv"; - $sql.= ", fk_stcommcontact"; + $sql .= ", fk_stcommcontact"; $sql .= ", statut"; $sql .= ", canvas"; $sql .= ", entity"; @@ -380,15 +405,15 @@ class Contact extends CommonObject if ($this->socid > 0) $sql .= " ".$this->db->escape($this->socid).","; else $sql .= "null,"; $sql .= "'".$this->db->escape($this->lastname)."',"; - $sql .= "'".$this->db->escape($this->firstname)."',"; - $sql .= " ".($user->id > 0 ? "'".$this->db->escape($user->id)."'" : "null").","; + $sql .= "'".$this->db->escape($this->firstname)."',"; + $sql .= " ".($user->id > 0 ? "'".$this->db->escape($user->id)."'" : "null").","; $sql .= " ".$this->db->escape($this->priv).","; - $sql.= " 0,"; + $sql .= " 0,"; $sql .= " ".$this->db->escape($this->statut).","; - $sql .= " ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null").","; - $sql .= " ".$this->db->escape($this->entity).","; - $sql .= "'".$this->db->escape($this->ref_ext)."',"; - $sql .= " ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); + $sql .= " ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null").","; + $sql .= " ".$this->db->escape($this->entity).","; + $sql .= "'".$this->db->escape($this->ref_ext)."',"; + $sql .= " ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -399,41 +424,41 @@ class Contact extends CommonObject if (!$error) { - $result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ... - if ($result < 0) - { - $error++; - $this->error = $this->db->lasterror(); - } + $result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ... + if ($result < 0) + { + $error++; + $this->error = $this->db->lasterror(); + } } if (!$error) - { - $result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update - if ($result < 0) - { - $error++; - $this->error = $this->db->lasterror(); - } - } + { + $result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update + if ($result < 0) + { + $error++; + $this->error = $this->db->lasterror(); + } + } - if (!$error) - { - // Call trigger - $result = $this->call_trigger('CONTACT_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error) + { + // Call trigger + $result = $this->call_trigger('CONTACT_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -2; - } + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -2; + } } else { $this->error = $this->db->lasterror(); @@ -464,10 +489,6 @@ class Contact extends CommonObject $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); // Clean parameters - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords(strtolower($this->lastname)); - if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(strtolower($this->firstname)); - $this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname); $this->firstname = trim($this->firstname); $this->email = trim($this->email); @@ -478,8 +499,9 @@ class Contact extends CommonObject $this->skype = trim($this->skype); $this->photo = trim($this->photo); $this->fax = trim($this->fax); - $this->zip = (empty($this->zip) ? '' : $this->zip); - $this->town = (empty($this->town) ? '' : $this->town); + $this->zip = (empty($this->zip) ? '' : trim($this->zip)); + $this->town = (empty($this->town) ? '' : trim($this->town)); + $this->setUpperOrLowerCase(); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); if (empty($this->statut)) $this->statut = 0; if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility @@ -499,7 +521,7 @@ class Contact extends CommonObject $sql .= ", poste='".$this->db->escape($this->poste)."'"; $sql .= ", fax='".$this->db->escape($this->fax)."'"; $sql .= ", email='".$this->db->escape($this->email)."'"; - $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); @@ -523,22 +545,22 @@ class Contact extends CommonObject $result = $this->db->query($sql); if ($result) { - unset($this->country_code); - unset($this->country); - unset($this->state_code); - unset($this->state); + unset($this->country_code); + unset($this->country); + unset($this->state_code); + unset($this->state); - $action = 'update'; + $action = 'update'; - // Actions on extra fields - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (!$error) { $result = $this->updateRoles(); @@ -645,14 +667,14 @@ class Contact extends CommonObject } } else { $this->error = $this->db->lasterror().' sql='.$sql; - $this->db->rollback(); + $this->db->rollback(); return -1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -664,7 +686,7 @@ class Contact extends CommonObject */ public function _load_ldap_dn($info, $mode = 0) { - // phpcs:enable + // phpcs:enable global $conf; $dn = ''; if ($mode == 0) $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN; @@ -674,8 +696,8 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Initialise tableau info (tableau des attributs LDAP) * @@ -683,12 +705,12 @@ class Contact extends CommonObject */ public function _load_ldap_info() { - // phpcs:enable + // phpcs:enable global $conf, $langs; - $info = array(); + $info = array(); - // Object classes + // Object classes $info["objectclass"] = explode(',', $conf->global->LDAP_CONTACT_OBJECT_CLASS); $this->fullname = $this->getFullName($langs); @@ -717,8 +739,8 @@ class Contact extends CommonObject if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso; if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; - if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; - if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); + if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; + if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') @@ -750,22 +772,22 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update field alert birthday * * @param int $id Id of contact * @param User $user User asking to change alert or birthday * @param int $notrigger 0=no, 1=yes - * @return int <0 if KO, >=0 if OK + * @return int <0 if KO, >=0 if OK */ public function update_perso($id, $user = null, $notrigger = 0) { - // phpcs:enable - $error = 0; - $result = false; + // phpcs:enable + $error = 0; + $result = false; - $this->db->begin(); + $this->db->begin(); // Mis a jour contact $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; @@ -796,8 +818,8 @@ class Contact extends CommonObject $result = $this->db->query($sql); if (!$result) { - $error++; - $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } } else { $result = true; @@ -808,27 +830,27 @@ class Contact extends CommonObject $result = $this->db->query($sql); if (!$result) { - $error++; - $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTACT_MODIFY', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTACT_MODIFY', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -$error; + dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -$error; } } @@ -838,9 +860,9 @@ class Contact extends CommonObject * * @param int $id Id of contact * @param User $user Load also alerts of this user (subscribing to alerts) that want alerts about this contact - * @param string $ref_ext External reference, not given by Dolibarr - * @param string $email Email - * @param int $loadalsoroles Load also roles + * @param string $ref_ext External reference, not given by Dolibarr + * @param string $email Email + * @param int $loadalsoroles Load also roles * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ public function fetch($id, $user = null, $ref_ext = '', $email = '', $loadalsoroles = 0) @@ -864,9 +886,9 @@ class Contact extends CommonObject $sql .= " c.birthday,"; $sql .= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,"; $sql .= " c.socialnetworks,"; - $sql .= " c.photo,"; + $sql .= " c.photo,"; $sql .= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; - $sql.= " c.fk_prospectcontactlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,"; + $sql .= " c.fk_prospectcontactlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,"; $sql .= " c.import_key,"; $sql .= " c.datec as date_creation, c.tms as date_modification,"; $sql .= " co.label as country, co.code as country_code,"; @@ -878,7 +900,7 @@ class Contact extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id'; if ($id) $sql .= " WHERE c.rowid = ".((int) $id); else { $sql .= " WHERE c.entity IN (".getEntity($this->element).")"; @@ -912,7 +934,7 @@ class Contact extends CommonObject $this->civility_code = $obj->civility_code; $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; - $this->lastname = $obj->lastname; + $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; $this->address = $obj->address; $this->zip = $obj->zip; @@ -936,11 +958,11 @@ class Contact extends CommonObject $this->fk_prospectlevel = $obj->fk_prospectcontactlevel; - $transcode=$langs->trans('StatusProspect'.$obj->fk_stcommcontact); - $libelle=($transcode!='StatusProspect'.$obj->fk_stcommcontact?$transcode:$obj->stcomm); - $this->stcomm_id = $obj->fk_stcommcontact; // id statut commercial - $this->statut_commercial = $libelle; // libelle statut commercial - $this->stcomm_picto = $obj->stcomm_picto; // Picto statut commercial + $transcode = $langs->trans('StatusProspect'.$obj->fk_stcommcontact); + $libelle = ($transcode != 'StatusProspect'.$obj->fk_stcommcontact ? $transcode : $obj->stcomm); + $this->stcomm_id = $obj->fk_stcommcontact; // id statut commercial + $this->statut_commercial = $libelle; // libelle statut commercial + $this->stcomm_picto = $obj->stcomm_picto; // Picto statut commercial $this->phone_pro = trim($obj->phone); $this->fax = trim($obj->fax); @@ -987,7 +1009,7 @@ class Contact extends CommonObject return -1; } - // Retreive all extrafield + // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); @@ -1054,7 +1076,7 @@ class Contact extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load number of elements the contact is used as a link for * ref_facturation @@ -1062,11 +1084,11 @@ class Contact extends CommonObject * ref_commande (for order and/or shipments) * ref_propale * - * @return int <0 if KO, >=0 if OK + * @return int <0 if KO, >=0 if OK */ public function load_ref_elements() { - // phpcs:enable + // phpcs:enable // Compte les elements pour lesquels il est contact $sql = "SELECT tc.element, count(ec.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc"; @@ -1192,18 +1214,18 @@ class Contact extends CommonObject } // Removed extrafields - if (!$error) { - // For avoid conflicts if trigger used + if (!$error) { + // For avoid conflicts if trigger used $result = $this->deleteExtraFields(); if ($result < 0) $error++; } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTACT_DELETE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTACT_DELETE', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) @@ -1296,7 +1318,7 @@ class Contact extends CommonObject * @param string $option Where the link point to * @param int $maxlen Max length of * @param string $moreparam Add more param into URL - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $notooltip 1=Disable tooltip * @return string String with URL */ @@ -1313,41 +1335,42 @@ class Contact extends CommonObject $label .= '
    '; } - $label .= img_picto('', $this->picto).' '.$langs->trans("Contact").''; - $label .= '
    '.$langs->trans("Name").': '.$this->getFullName($langs); - //if ($this->civility_id) $label.= '
    ' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code - if (!empty($this->poste)) $label .= '
    '.$langs->trans("Poste").': '.$this->poste; - $label .= '
    '.$langs->trans("EMail").': '.$this->email; - $phonelist = array(); - if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $this->country_code, $this->id, 0, '', ' ', 'phone'); - if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); - if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $this->country_code, $this->id, 0, '', ' ', 'phone'); - $label .= '
    '.$langs->trans("Phone").': '.implode(' ', $phonelist); - $label .= '
    '.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); + $label .= img_picto('', $this->picto).' '.$langs->trans("Contact").''; + $label .= ' '.$this->getLibStatut(4); + $label .= '
    '.$langs->trans("Name").': '.$this->getFullName($langs); + //if ($this->civility_id) $label.= '
    ' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code + if (!empty($this->poste)) $label .= '
    '.$langs->trans("Poste").': '.$this->poste; + $label .= '
    '.$langs->trans("EMail").': '.$this->email; + $phonelist = array(); + if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $this->country_code, $this->id, 0, '', ' ', 'phone'); + if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); + if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $this->country_code, $this->id, 0, '', ' ', 'phone'); + $label .= '
    '.$langs->trans("Phone").': '.implode(' ', $phonelist); + $label .= '
    '.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); - $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; - if ($option !== 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option !== 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - $url .= $moreparam; + $url .= $moreparam; - $linkclose = ""; + $linkclose = ""; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowContact"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowContact"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; - /* + /* $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 @@ -1407,7 +1430,7 @@ class Contact extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1417,7 +1440,7 @@ class Contact extends CommonObject */ public function LibStatut($status, $mode) { - // phpcs:enable + // phpcs:enable global $langs; $labelStatus = array( @@ -1443,7 +1466,7 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label of Public or Private * @@ -1452,7 +1475,7 @@ class Contact extends CommonObject */ public function LibPubPriv($status) { - // phpcs:enable + // phpcs:enable global $langs; if ($status == '1') return $langs->trans('ContactPrivate'); else return $langs->trans('ContactPublic'); @@ -1460,11 +1483,11 @@ class Contact extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return int >0 if ok + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return int >0 if ok */ public function initAsSpecimen() { @@ -1479,6 +1502,7 @@ class Contact extends CommonObject // Initialise parameters $this->id = 0; + $this->entity = 1; $this->specimen = 1; $this->lastname = 'DOLIBARR'; $this->firstname = 'SPECIMEN'; @@ -1533,10 +1557,10 @@ class Contact extends CommonObject dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); if ($result) { - // Call trigger - $result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user); + if ($result < 0) { $error++; } + // End call triggers } if ($error) @@ -1557,7 +1581,7 @@ class Contact extends CommonObject * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs - * @return void + * @return void */ public function setCategories($categories) { @@ -1770,15 +1794,15 @@ class Contact extends CommonObject { global $langs; - $sql = "SELECT id, code, libelle as label, picto FROM " . MAIN_DB_PREFIX . "c_stcommcontact"; - if ($active >= 0) $sql .= " WHERE active = " . $active; + $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcommcontact"; + if ($active >= 0) $sql .= " WHERE active = ".$active; $resql = $this->db->query($sql); $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $this->cacheprospectstatus[$obj->id] = array('id' => $obj->id, 'code' => $obj->code, 'label' => ($langs->trans("ST_" . strtoupper($obj->code)) == "ST_" . strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_" . strtoupper($obj->code)), 'picto' => $obj->picto); + $this->cacheprospectstatus[$obj->id] = array('id' => $obj->id, 'code' => $obj->code, 'label' => ($langs->trans("ST_".strtoupper($obj->code)) == "ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_".strtoupper($obj->code)), 'picto' => $obj->picto); $i++; } return 1; @@ -1804,9 +1828,9 @@ class Contact extends CommonObject { global $langs; - $lib = $langs->trans("ProspectLevel" . $fk_prospectlevel); + $lib = $langs->trans("ProspectLevel".$fk_prospectlevel); // If lib not found in language file, we get label from cache/databse - if ($lib == $langs->trans("ProspectLevel" . $fk_prospectlevel)) + if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) { $lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label'); } @@ -1858,13 +1882,13 @@ class Contact extends CommonObject if ($mode == 2) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto) . ' ' . $langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto) . ' ' . $langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto) . ' ' . $langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto) . ' ' . $langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto) . ' ' . $langs->trans("StatusProspect3"); + if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); else { - return img_action(($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label, 0, $picto) . ' ' . (($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label); + return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); } } if ($mode == 3) @@ -1875,18 +1899,18 @@ class Contact extends CommonObject elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto); elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto); else { - return img_action(($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label, 0, $picto); + return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto); } } if ($mode == 4) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto) . ' ' . $langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto) . ' ' . $langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto) . ' ' . $langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto) . ' ' . $langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto) . ' ' . $langs->trans("StatusProspect3"); + if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); else { - return img_action(($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label, 0, $picto) . ' ' . (($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label); + return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); } } diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 7655e00ea3f..da00374cc2a 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -62,10 +62,10 @@ $year = GETPOST('year', 'int'); // Clean up on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $sref = ''; - $sprod_fulldescr = ''; - $year = ''; - $month = ''; + $sref = ''; + $sprod_fulldescr = ''; + $year = ''; + $month = ''; } // Customer or supplier selected in drop box $thirdTypeSelect = GETPOST("third_select_id"); @@ -106,18 +106,18 @@ if (empty($id)) } $head = contact_prepare_head($object); -dol_fiche_head($head, 'consumption', $langs->trans("ContactsAddresses"), -1, 'contact'); +print dol_get_fiche_head($head, 'consumption', $langs->trans("ContactsAddresses"), -1, 'contact'); $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
    '; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - $objsoc->fetch($socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + $objsoc->fetch($socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); } $morehtmlref .= '
    '; @@ -148,7 +148,7 @@ if ($object->thirdparty->fournisseur) { $thirdTypeArray['supplier'] = $langs->trans("supplier"); if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices'); - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order']= $langs->transnoentitiesnoconv('SuppliersOrders'); + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); // There no contact type for supplier proposals // if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals'); @@ -158,7 +158,7 @@ print ''; print '
    '; -dol_fiche_end(); +print dol_get_fiche_end(); print '
    '; @@ -172,9 +172,9 @@ if ($type_element == 'fichinter') $documentstatic = new Fichinter($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'fichinterdet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)"; $where = ' WHERE f.entity IN ('.getEntity('ficheinter').')'; $dateprint = 'f.datec'; $doc_number = 'f.ref'; @@ -184,10 +184,10 @@ if ($type_element == 'fichinter') $documentstatic = new Facture($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'facturedet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)"; $where = " WHERE f.entity IN (".getEntity('invoice').")"; $dateprint = 'f.datef'; $doc_number = 'f.ref'; @@ -198,10 +198,10 @@ if ($type_element == 'fichinter') $documentstatic = new Propal($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'propaldet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('propal').')'; $datePrint = 'c.datep'; $doc_number = 'c.ref'; @@ -212,10 +212,10 @@ if ($type_element == 'fichinter') $documentstatic = new Commande($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'commandedet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('order').')'; $dateprint = 'c.date_commande'; $doc_number = 'c.ref'; @@ -226,10 +226,10 @@ if ($type_element == 'fichinter') $documentstatic = new FactureFournisseur($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'facture_fourn_det d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)"; $where = ' WHERE f.entity IN ('.getEntity($documentstatic->element).')'; $dateprint = 'f.datef'; $doc_number = 'f.ref'; @@ -254,10 +254,10 @@ elseif ($type_element == 'supplier_order') $documentstatic = new CommandeFournisseur($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'commande_fournisseurdet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity($documentstatic->element).')'; $dateprint = 'c.date_valid'; $doc_number = 'c.ref'; @@ -269,10 +269,10 @@ elseif ($type_element == 'supplier_order') $documentstaticline = new ContratLigne($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'contratdet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('contrat').')'; $dateprint = 'c.date_valid'; $doc_number = 'c.ref'; @@ -293,16 +293,16 @@ if (!empty($sql_select)) $sql .= " "; if ($type_element != 'fichinter') $sql .= ", p.ref as prod_ref, p.label as product_label"; $sql .= " FROM "/*.MAIN_DB_PREFIX."societe as s, "*/.$tables_from; - // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; + // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; $sql .= $where; $sql .= dolSqlDateFilter($dateprint, 0, $month, $year); if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; if ($sprod_fulldescr) { - $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; - if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; - if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; - $sql .= ")"; + $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; + $sql .= ")"; } $sql .= $db->order($sortfield, $sortorder); $resql = $db->query($sql); @@ -314,8 +314,8 @@ if (!empty($sql_select)) $disabled = 0; $showempty = 2; if (empty($elementTypeArray) && !$object->thirdparty->client && !$object->thirdparty->fournisseur) { - $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); - $disabled = 1; + $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); + $disabled = 1; } // Define type of elements @@ -340,7 +340,7 @@ if ($sql_select) $num = $db->num_rows($resql); $param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element); - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); if ($sref) $param .= "&sref=".urlencode($sref); @@ -348,48 +348,48 @@ if ($sql_select) if ($year) $param .= "&year=".urlencode($year); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); - print '
    '; - print ''."\n"; + print '
    '; + print '
    '."\n"; - // Filters - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // Filters + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - // Titles with sort buttons - print ''; - print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('ContactType', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('TotalHT', $_SERVER['PHP_SELF'], 'total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('UnitPrice', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - print "\n"; + // Titles with sort buttons + print ''; + print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('ContactType', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('TotalHT', $_SERVER['PHP_SELF'], 'total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('UnitPrice', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + print "\n"; $i = 0; @@ -478,7 +478,7 @@ if ($sql_select) elseif ($objp->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid"); //else $txt=$langs->trans("Discount"); print $txt; - print ''; + print ''; if ($objp->description) { if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) @@ -576,7 +576,7 @@ if ($sql_select) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -588,25 +588,25 @@ if ($sql_select) } $db->free($resql); } elseif (empty($type_element) || $type_element == -1) { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - print '
    '; - 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 ''; - print ''; - print ''; - print ''; // TODO: Add filters ! - print ''; - print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
    '; + 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 ''; + print ''; + print ''; + print ''; // TODO: Add filters ! + print ''; + print ''; + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
    '.$langs->trans('Total').''.$total_qty.''.price($total_ht).''.price($total_ht / (empty($total_qty) ? 1 : $total_qty)).'
    '."\n"; - // Titles with sort buttons - print ''; - print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_status', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); - print "\n"; + print '
    '."\n"; + // Titles with sort buttons + print ''; + print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_status', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); + print "\n"; print ''; print "
    '.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).'
    "; } else { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - print ''."\n"; + print '
    '."\n"; print ''; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index f8498ddae9a..2065ab772e6 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -45,9 +45,9 @@ $objcanvas = null; $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('contact', 'contactcard', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('contact', 'contactcard', $canvas); } // Security check @@ -96,43 +96,43 @@ llxHeader('', $title, $helpurl); if ($object->id) { - $head = contact_prepare_head($object); + $head = contact_prepare_head($object); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); - dol_fiche_head($head, 'documents', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'documents', $title, -1, 'contact'); - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) - { - $totalsize += $file['size']; - } + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) + { + $totalsize += $file['size']; + } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
    '; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
    '; + $morehtmlref = '
    '; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
    '; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
    '; + print '
    '; - print '
    '; - print '
    '.$langs->trans("FeatureNotYetAvailable").'
    '; + print '
    '; + print '
    '; - // Company - /* + // Company + /* if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { if ($object->socid > 0) @@ -151,26 +151,26 @@ if ($object->id) } }*/ - // Civility - print ''; + // Civility + print ''; - print ''; - print ''; - print '
    '.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
    '.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
    '.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
    '.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
    '; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; + print ''; - print '
    '; + print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); - $modulepart = 'contact'; - $permission = $user->rights->societe->contact->creer; - $permtoedit = $user->rights->societe->contact->creer; - $param = '&id='.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $modulepart = 'contact'; + $permission = $user->rights->societe->contact->creer; + $permtoedit = $user->rights->societe->contact->creer; + $param = '&id='.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { - print $langs->trans("ErrorUnknown"); + print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/contact/info.php b/htdocs/contact/info.php index 68fe24d0044..c39c20d3d25 100644 --- a/htdocs/contact/info.php +++ b/htdocs/contact/info.php @@ -60,7 +60,7 @@ if ($id > 0) $head = contact_prepare_head($object); - dol_fiche_head($head, 'info', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'info', $title, -1, 'contact'); $linkback = ''.$langs->trans("BackToList").''; @@ -77,7 +77,7 @@ if ($id > 0) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index f601086ad05..78934c5857e 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -86,7 +86,7 @@ llxHeader('', $title, 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_ $head = contact_prepare_head($object); -dol_fiche_head($head, 'ldap', $title, -1, 'contact'); +print dol_get_fiche_head($head, 'ldap', $title, -1, 'contact'); $linkback = ''.$langs->trans("BackToList").''; @@ -130,7 +130,7 @@ print ''; print ''; -dol_fiche_end(); +print dol_get_fiche_end(); /* @@ -174,7 +174,7 @@ if ($result > 0) //var_dump($records); // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { if (!is_array($records)) { diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 4d30977bf6a..16f7ea82f36 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -203,20 +203,8 @@ if (!empty($conf->socialnetworks->enabled)) { } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) - { - if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key] = array( - 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), - 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]), - 'langfile'=>$extrafields->attributes[$object->table_element]['langfile'][$key], - ); - } -} +include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; + $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -891,7 +879,7 @@ while ($i < min($num, $limit)) if (!empty($arrayfields['p.lastname']['checked'])) { print ''; - print $contactstatic->getNomUrl(1, '', 0); + print $contactstatic->getNomUrl(1); print ''; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 572664890e1..ae32ef5c95e 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -67,46 +67,46 @@ llxHeader('', $title, $help_url); if ($id > 0) { - /* + /* * Affichage onglets */ - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); - $head = contact_prepare_head($object); + $head = contact_prepare_head($object); - dol_fiche_head($head, 'note', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'note', $title, -1, 'contact'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
    '; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
    '; + $morehtmlref = '
    '; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
    '; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - $cssclass = 'titlefield'; - //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; - //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; + $cssclass = 'titlefield'; + //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; + //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; - print '
    '; - print '
    '; + print '
    '; + print '
    '; print ''; - // Civility - print ''; + // Civility + print ''; - print "
    '.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
    '.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
    "; + print ""; $cssclass = "titlefield"; @@ -114,7 +114,7 @@ if ($id > 0) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 1710b4dda6a..d8d7b709736 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -66,9 +66,9 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- if ($file_OK) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; if (GETPOST('deletephoto')) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $fileimg = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/'.$object->photo; $dirthumbs = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/thumbs'; dol_delete_file($fileimg); @@ -86,8 +86,8 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } else { - // Create thumbs - $object->addThumbs($newfile); + // Create thumbs + $object->addThumbs($newfile); } } } else { @@ -130,119 +130,119 @@ $head = contact_prepare_head($object); if ($action == 'edit') { - /* + /* * Fiche en mode edition */ - print '
    '; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - dol_fiche_head($head, 'perso', $title, 0, 'contact'); + print dol_get_fiche_head($head, 'perso', $title, 0, 'contact'); - print ''; + print '
    '; - // Ref - print ''; + // Ref + print ''; - // Photo - print ''; + print ''; + print ''; + print '
    '.$langs->trans("Ref").''; - print $object->id; - print '
    '.$langs->trans("Ref").''; + print $object->id; + print ''; - print $form->showphoto('contact', $object)."\n"; - if ($object->photo) print "
    \n"; + // Photo + print '
    '; + print $form->showphoto('contact', $object)."\n"; + if ($object->photo) print "
    \n"; - print ''; + print '
    '; - if ($object->photo) print ''; - print ''; - print ''; - print '
    '.$langs->trans("Delete").'

    '.$langs->trans("PhotoFile").'
    '; + if ($object->photo) print '
    '.$langs->trans("Delete").'

    '.$langs->trans("PhotoFile").'
    '; - print ''; + print ''; - // Name - print ''.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''; - print ''.$langs->trans("Firstname").''.$object->firstname.''; + // Name + print ''.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''; + print ''.$langs->trans("Firstname").''.$object->firstname.''; - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - if ($object->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + if ($object->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); - print ''.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).''; - } else { - print ''.$langs->trans("ThirdParty").''; - print $langs->trans("ContactNotLinkedToCompany"); - print ''; - } - } + print ''.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).''; + } else { + print ''.$langs->trans("ThirdParty").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; + } + } - // Civility - print ''.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print ''; + // Civility + print ''.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print ''; - // Date To Birth - print ''.$langs->trans("DateOfBirth").''; - $form = new Form($db); - print $form->selectDate($object->birthday, 'birthday', 0, 0, 1, "perso", 1, 0); - print ''; + // Date To Birth + print ''.$langs->trans("DateOfBirth").''; + $form = new Form($db); + print $form->selectDate($object->birthday, 'birthday', 0, 0, 1, "perso", 1, 0); + print ''; - print ''.$langs->trans("Alert").': '; - if (!empty($object->birthday_alert)) - { - print ''; - } else { - print ''; - } - print ''; + print ''.$langs->trans("Alert").': '; + if (!empty($object->birthday_alert)) + { + print ''; + } else { + print ''; + } + print ''; - print ""; + print ""; - dol_fiche_end(); + print dol_get_fiche_end(); - print '
    '; - print ''; - print '     '; - print ''; - print '
    '; + print '
    '; + print ''; + print '     '; + print ''; + print '
    '; - print "
    "; + print ""; } else { - // View mode + // View mode - dol_fiche_head($head, 'perso', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'perso', $title, -1, 'contact'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
    '; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
    '; + $morehtmlref = '
    '; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
    '; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
    '; + print '
    '; - print '
    '; - print ''; + print '
    '; + print '
    '; - // Company - /* + // Company + /* if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { if ($object->socid > 0) @@ -261,59 +261,59 @@ if ($action == 'edit') } }*/ - // Civility - print ''; + // Civility + print ''; - // Date To Birth - print ''; - if (!empty($object->birthday)) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + // Date To Birth + print ''; + if (!empty($object->birthday)) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - print ''; - } else { - print ''; - } - print ""; + print '   -   '; + if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); + else print $langs->trans("BirthdayAlertOff"); + print ''; + } else { + print ''; + } + print ""; - print "
    '.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
    '.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
    '.$langs->trans("DateOfBirth").''.dol_print_date($object->birthday, "day"); + print ''.$langs->trans("DateOfBirth").''.dol_print_date($object->birthday, "day"); - print '   '; - //var_dump($birthdatearray); - $ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970; - $agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1; - if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; - elseif ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; - else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; + print '   '; + //var_dump($birthdatearray); + $ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970; + $agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1; + if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; + elseif ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; + else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; - print '   -   '; - if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); - else print $langs->trans("BirthdayAlertOff"); - print ''.$langs->trans("DateOfBirth").'
    '.$langs->trans("DateOfBirth").'
    "; + print ""; - print '
    '; + print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); } if ($action != 'edit') { - // Barre d'actions - if ($user->socid == 0) - { - print '
    '; + // Barre d'actions + if ($user->socid == 0) + { + print '
    '; - if ($user->rights->societe->contact->creer) - { - print ''.$langs->trans('Modify').''; - } + if ($user->rights->societe->contact->creer) + { + print ''.$langs->trans('Modify').''; + } - print "
    "; - } + print "
    "; + } } diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index ee325317033..05426db19a6 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -66,7 +66,7 @@ $v->setPhoneNumber($contact->phone_pro, "TYPE=WORK;VOICE"); $v->setPhoneNumber($contact->phone_mobile, "TYPE=CELL;VOICE"); $v->setPhoneNumber($contact->fax, "TYPE=WORK;FAX"); -$country = $contact->country_code ? $contact->country : '' ; +$country = $contact->country_code ? $contact->country : ''; $v->setAddress("", "", $contact->address, $contact->town, $contact->state, $contact->zip, $country, "TYPE=WORK;POSTAL"); $v->setLabel("", "", $contact->address, $contact->town, $contact->state, $contact->zip, $country, "TYPE=WORK"); @@ -79,9 +79,9 @@ $v->setTitle($contact->poste); if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (! $contact->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); - if (! $contact->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); - if (! $contact->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + if (!$contact->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); + if (!$contact->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); + if (!$contact->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); // when company e-mail is empty, use only contact e-mail if (empty(trim($company->email))) @@ -124,7 +124,7 @@ $db->close(); $output = $v->getVCard(); -$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" +$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); //$filename = dol_sanitizeFileName($filename); diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index 5343ab8f349..8571856362a 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -70,11 +70,11 @@ print load_fiche_titre($langs->trans("ContractsSetup"), $linkback, 'title_setup' $head = contract_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Contracts"), -1, 'contract'); +print dol_get_fiche_head($head, 'attributes', $langs->trans("Contracts"), -1, 'contract'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/contrat/admin/contractdet_extrafields.php b/htdocs/contrat/admin/contractdet_extrafields.php index bd0c7b132d0..4b3f03ffedf 100644 --- a/htdocs/contrat/admin/contractdet_extrafields.php +++ b/htdocs/contrat/admin/contractdet_extrafields.php @@ -70,11 +70,11 @@ print load_fiche_titre($langs->trans("ContractsSetup"), $linkback, 'title_setup' $head = contract_admin_prepare_head(); -dol_fiche_head($head, 'attributeslines', $langs->trans("Contracts"), -1, 'contract'); +print dol_get_fiche_head($head, 'attributeslines', $langs->trans("Contracts"), -1, 'contract'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; -dol_fiche_end(); +print dol_get_fiche_end(); // Buttons diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index d016cb23d75..f88b470215c 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -132,7 +132,7 @@ if ($id > 0) if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = contract_prepare_head($object); - dol_fiche_head($head, 'agenda', $langs->trans("Contract"), -1, 'contract'); + print dol_get_fiche_head($head, 'agenda', $langs->trans("Contract"), -1, 'contract'); $linkback = ''.$langs->trans("BackToList").''; @@ -204,7 +204,7 @@ if ($id > 0) print '
    '; - dol_fiche_end(); + print dol_get_fiche_end(); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index b6e77e69dca..f152ff5cc69 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -409,13 +409,13 @@ if (empty($reshook)) $error++; } - $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) - { - setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); - $error++; - } + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) + { + setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); + $error++; + } // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -684,9 +684,9 @@ if (empty($reshook)) $objectline->pa_ht = $pa_ht; if ($fk_unit > 0) { - $objectline->fk_unit = GETPOST('unit'); + $objectline->fk_unit = GETPOST('unit'); } else { - $objectline->fk_unit = null; + $objectline->fk_unit = null; } // Extrafields @@ -877,11 +877,11 @@ if (empty($reshook)) $old_ref = $object->ref; - $result = $object->setValueFrom('ref', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'editref'; - } else { + $result = $object->setValueFrom('ref', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'editref'; + } else { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $old_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($old_ref); $new_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref); @@ -896,13 +896,13 @@ if (empty($reshook)) } } - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - } else { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - exit; - } + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + } else { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } } elseif ($action == 'setdate_contrat') { $cancelbutton = GETPOST('cancel', 'alpha'); @@ -1092,7 +1092,7 @@ if ($action == 'create') print ''."\n"; print ''; - dol_fiche_head(); + print dol_get_fiche_head(); print ''; @@ -1197,7 +1197,7 @@ if ($action == 'create') print "
    \n"; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; print ''; @@ -1233,8 +1233,8 @@ if ($action == 'create') $result = $object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed if ($result < 0) { - dol_print_error($db, $object->error); - } + dol_print_error($db, $object->error); + } $nbofservices = count($object->lines); @@ -1249,55 +1249,55 @@ if ($action == 'create') $head = contract_prepare_head($object); - $hselected = 0; - $formconfirm = ''; + $hselected = 0; + $formconfirm = ''; - dol_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); + print dol_get_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); - if ($action == 'delete') { - //Confirmation de la suppression du contrat - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAContract"), $langs->trans("ConfirmDeleteAContract"), "confirm_delete", '', 0, 1); - } elseif ($action == 'valid') { - //Confirmation de la validation - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { - $numref = $object->getNextNumRef($object->thirdparty); - } else { - $numref = $object->ref; - } - $text = $langs->trans('ConfirmValidateContract', $numref); - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ValidateAContract"), $text, "confirm_valid", '', 0, 1); - } elseif ($action == 'close') { - // Confirmation de la fermeture - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); - } elseif ($action == 'activate') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); - } elseif ($action == 'clone') { - // Clone confirmation - $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } + if ($action == 'delete') { + //Confirmation de la suppression du contrat + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAContract"), $langs->trans("ConfirmDeleteAContract"), "confirm_delete", '', 0, 1); + } elseif ($action == 'valid') { + //Confirmation de la validation + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { + $numref = $object->getNextNumRef($object->thirdparty); + } else { + $numref = $object->ref; + } + $text = $langs->trans('ConfirmValidateContract', $numref); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ValidateAContract"), $text, "confirm_valid", '', 0, 1); + } elseif ($action == 'close') { + // Confirmation de la fermeture + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); + } elseif ($action == 'activate') { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); + } elseif ($action == 'clone') { + // Clone confirmation + $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } - // Call Hook formConfirm - $parameters = array( - 'formConfirm' => $formconfirm, - 'id' => $id, - //'lineid' => $lineid, - ); - // Note that $action and $object may have been modified by hook - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array( + 'formConfirm' => $formconfirm, + 'id' => $id, + //'lineid' => $lineid, + ); + // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } - // Print form confirm - print $formconfirm; + // Print form confirm + print $formconfirm; - /* + /* * Contrat */ if (!empty($object->brouillon) && $user->rights->contrat->creer) @@ -1488,8 +1488,8 @@ if ($action == 'create') // Line in view mode if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) { - $moreparam = ''; - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; + $moreparam = ''; + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; print ''; // Label if ($objp->fk_product > 0) @@ -1622,7 +1622,7 @@ if ($action == 'create') $line = new ContratLigne($db); $line->id = $objp->rowid; $line->fetch_optionals(); - print $line->showOptionals($extrafields, 'view', array('class'=>'oddeven','style'=>$moreparam, 'colspan'=>$colspan), '', '', 1); + print $line->showOptionals($extrafields, 'view', array('class'=>'oddeven', 'style'=>$moreparam, 'colspan'=>$colspan), '', '', 1); } } // Line in mode update @@ -1733,8 +1733,8 @@ if ($action == 'create') if ($object->statut > 0) { - $moreparam = ''; - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline-1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; + $moreparam = ''; + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline - 1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; print ''; print '
    '; print "\n"; @@ -1850,12 +1850,12 @@ if ($action == 'create') // Si active et en cours if ($objp->date_debut_reelle && !$objp->date_fin_reelle) { print $langs->trans("DateStartReal").': '; - print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); + print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); } // Si desactive if ($objp->date_debut_reelle && $objp->date_fin_reelle) { print $langs->trans("DateStartReal").': '; - print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); + print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); print '  -  '; print $langs->trans("DateEndReal").': '; print dol_print_date($db->jdate($objp->date_fin_reelle), 'day'); @@ -2015,7 +2015,7 @@ if ($action == 'create') print ''; } - dol_fiche_end(); + print dol_get_fiche_end(); /* @@ -2092,16 +2092,16 @@ if ($action == 'create') //} } - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) - { - if ($action == 'showclosedlines') print ''; - else print ''; - } + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) + { + if ($action == 'showclosedlines') print ''; + else print ''; + } - // Clone - if ($user->rights->contrat->creer) { - print ''; - } + // Clone + if ($user->rights->contrat->creer) { + print ''; + } // On peut supprimer entite si // - Droit de creer + mode brouillon (erreur creation) diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 671ac1177f6..20604f25798 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2016 Laurent Destailleur - * Copyright (C) 2018 Frédéric France +/* Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,648 +30,647 @@ class Contracts extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'socid', - 'date_contrat', - 'commercial_signature_id', - 'commercial_suivi_id' - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid', + 'date_contrat', + 'commercial_signature_id', + 'commercial_suivi_id' + ); - /** - * @var Contrat $contract {@type Contrat} - */ - public $contract; + /** + * @var Contrat $contract {@type Contrat} + */ + public $contract; - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - $this->contract = new Contrat($this->db); - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->contract = new Contrat($this->db); + } - /** - * Get properties of a contract object - * - * Return an array with contract informations - * - * @param int $id ID of contract - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id) - { - if (!DolibarrApiAccess::$user->rights->contrat->lire) { - throw new RestException(401); - } + /** + * Get properties of a contract object + * + * Return an array with contract informations + * + * @param int $id ID of contract + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id) + { + if (!DolibarrApiAccess::$user->rights->contrat->lire) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contract not found'); - } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contract not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->contract->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->contract); - } + $this->contract->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->contract); + } - /** - * List contracts - * - * Get a list of contracts - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter contracts of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" - * @return array Array of contract objects - * - * @throws RestException 404 Not found - * @throws RestException 503 Error - */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') - { - global $db, $conf; + /** + * List contracts + * + * Get a list of contracts + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter contracts of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of contract objects + * + * @throws RestException 404 Not found + * @throws RestException 503 Error + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; - $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql .= " FROM ".MAIN_DB_PREFIX."contrat as t"; + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql .= ' WHERE t.entity IN ('.getEntity('contrat').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $sql .= ' WHERE t.entity IN ('.getEntity('contrat').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (!DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit + 1, $offset); - } + $sql .= $this->db->plimit($limit + 1, $offset); + } - dol_syslog("API Rest request"); - $result = $this->db->query($sql); + dol_syslog("API Rest request"); + $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - $i = 0; - while ($i < $min) - { - $obj = $this->db->fetch_object($result); - $contrat_static = new Contrat($this->db); - if ($contrat_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($contrat_static); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve contrat list : '.$this->db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No contract found'); - } - return $obj_ret; - } + if ($result) + { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; + while ($i < $min) + { + $obj = $this->db->fetch_object($result); + $contrat_static = new Contrat($this->db); + if ($contrat_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($contrat_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve contrat list : '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No contract found'); + } + return $obj_ret; + } - /** - * Create contract object - * - * @param array $request_data Request data - * @return int ID of contrat - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401, "Insufficient rights"); - } - // Check mandatory fields - $result = $this->_validate($request_data); + /** + * Create contract object + * + * @param array $request_data Request data + * @return int ID of contrat + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401, "Insufficient rights"); + } + // Check mandatory fields + $result = $this->_validate($request_data); - foreach ($request_data as $field => $value) { - $this->contract->$field = $value; - } - /*if (isset($request_data["lines"])) { + foreach ($request_data as $field => $value) { + $this->contract->$field = $value; + } + /*if (isset($request_data["lines"])) { $lines = array(); foreach ($request_data["lines"] as $line) { array_push($lines, (object) $line); } $this->contract->lines = $lines; }*/ - if ($this->contract->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, "Error creating contract", array_merge(array($this->contract->error), $this->contract->errors)); - } + if ($this->contract->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating contract", array_merge(array($this->contract->error), $this->contract->errors)); + } - return $this->contract->id; - } + return $this->contract->id; + } - /** - * Get lines of a contract - * - * @param int $id Id of contract - * - * @url GET {id}/lines - * - * @return array - */ - public function getLines($id) - { - if (!DolibarrApiAccess::$user->rights->contrat->lire) { - throw new RestException(401); - } + /** + * Get lines of a contract + * + * @param int $id Id of contract + * + * @url GET {id}/lines + * + * @return array + */ + public function getLines($id) + { + if (!DolibarrApiAccess::$user->rights->contrat->lire) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contract not found'); - } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contract not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->contract->getLinesArray(); - $result = array(); - foreach ($this->contract->lines as $line) { - array_push($result, $this->_cleanObjectDatas($line)); - } - return $result; - } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->contract->getLinesArray(); + $result = array(); + foreach ($this->contract->lines as $line) { + array_push($result, $this->_cleanObjectDatas($line)); + } + return $result; + } - /** - * Add a line to given contract - * - * @param int $id Id of contrat to update - * @param array $request_data Contractline data - * - * @url POST {id}/lines - * - * @return int|bool - */ - public function postLine($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + /** + * Add a line to given contract + * + * @param int $id Id of contrat to update + * @param array $request_data Contractline data + * + * @url POST {id}/lines + * + * @return int|bool + */ + public function postLine($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contract not found'); - } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contract not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->contract->addline( - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - $request_data->fk_product, - $request_data->remise_percent, - $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real - $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real - $request_data->HT, - $request_data->subprice_excl_tax, - $request_data->info_bits, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->array_options, - $request_data->fk_unit, - $request_data->rang - ); + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->contract->addline( + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->fk_product, + $request_data->remise_percent, + $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real + $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real + $request_data->HT, + $request_data->subprice_excl_tax, + $request_data->info_bits, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->array_options, + $request_data->fk_unit, + $request_data->rang + ); - if ($updateRes > 0) { - return $updateRes; - } - return false; - } + if ($updateRes > 0) { + return $updateRes; + } + return false; + } - /** - * Update a line to given contract - * - * @param int $id Id of contrat to update - * @param int $lineid Id of line to update - * @param array $request_data Contractline data - * - * @url PUT {id}/lines/{lineid} - * - * @return array|bool - */ - public function putLine($id, $lineid, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + /** + * Update a line to given contract + * + * @param int $id Id of contrat to update + * @param int $lineid Id of line to update + * @param array $request_data Contractline data + * + * @url PUT {id}/lines/{lineid} + * + * @return array|bool + */ + public function putLine($id, $lineid, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contrat not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $request_data = (object) $request_data; + $request_data = (object) $request_data; - $updateRes = $this->contract->updateline( - $lineid, - $request_data->desc, - $request_data->subprice, - $request_data->qty, - $request_data->remise_percent, - $request_data->date_ouveture_prevue, - $request_data->date_fin_validite, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - $request_data->date_ouverture, - $request_data->date_cloture, - 'HT', - $request_data->info_bits, - $request_data->fk_fourn_price, - $request_data->pa_ht, - $request_data->array_options, - $request_data->fk_unit - ); + $updateRes = $this->contract->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->date_ouveture_prevue, + $request_data->date_fin_validite, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->date_ouverture, + $request_data->date_cloture, + 'HT', + $request_data->info_bits, + $request_data->fk_fourn_price, + $request_data->pa_ht, + $request_data->array_options, + $request_data->fk_unit + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; - } + return false; + } - /** - * Activate a service line of a given contract - * - * @param int $id Id of contract to activate - * @param int $lineid Id of line to activate - * @param string $datestart {@from body} Date start {@type timestamp} - * @param string $dateend {@from body} Date end {@type timestamp} - * @param string $comment {@from body} Comment - * - * @url PUT {id}/lines/{lineid}/activate - * - * @return array|bool - */ - public function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) - { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + /** + * Activate a service line of a given contract + * + * @param int $id Id of contract to activate + * @param int $lineid Id of line to activate + * @param string $datestart {@from body} Date start {@type timestamp} + * @param string $dateend {@from body} Date end {@type timestamp} + * @param string $comment {@from body} Comment + * + * @url PUT {id}/lines/{lineid}/activate + * + * @return array|bool + */ + public function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) + { + if (!DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contrat not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment); + $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; - } + return false; + } - /** - * Unactivate a service line of a given contract - * - * @param int $id Id of contract to activate - * @param int $lineid Id of line to activate - * @param string $datestart {@from body} Date start {@type timestamp} - * @param string $comment {@from body} Comment - * - * @url PUT {id}/lines/{lineid}/unactivate - * - * @return array|bool - */ - public function unactivateLine($id, $lineid, $datestart, $comment = null) - { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + /** + * Unactivate a service line of a given contract + * + * @param int $id Id of contract to activate + * @param int $lineid Id of line to activate + * @param string $datestart {@from body} Date start {@type timestamp} + * @param string $comment {@from body} Comment + * + * @url PUT {id}/lines/{lineid}/unactivate + * + * @return array|bool + */ + public function unactivateLine($id, $lineid, $datestart, $comment = null) + { + if (!DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contrat not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $request_data = (object) $request_data; + // $request_data = (object) $request_data; - $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); + $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; - } + return false; + } - /** - * Delete a line to given contract - * - * - * @param int $id Id of contract to update - * @param int $lineid Id of line to delete - * - * @url DELETE {id}/lines/{lineid} - * - * @return int - * - * @throws RestException 401 - * @throws RestException 404 - */ - public function deleteLine($id, $lineid) - { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + /** + * Delete a line to given contract + * + * + * @param int $id Id of contract to update + * @param int $lineid Id of line to delete + * + * @url DELETE {id}/lines/{lineid} + * + * @return array|mixed + * + * @throws RestException 401 + * @throws RestException 404 + */ + public function deleteLine($id, $lineid) + { + if (!DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contrat not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - // TODO Check the lineid $lineid is a line of object + // TODO Check the lineid $lineid is a line of object - $updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user); - if ($updateRes > 0) { - return $this->get($id); - } else { - throw new RestException(405, $this->contract->error); - } - } + $updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user); + if ($updateRes > 0) { + return $this->get($id); + } else { + throw new RestException(405, $this->contract->error); + } + } - /** - * Update contract general fields (won't touch lines of contract) - * - * @param int $id Id of contract to update - * @param array $request_data Datas - * - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + /** + * Update contract general fields (won't touch lines of contract) + * + * @param int $id Id of contract to update + * @param array $request_data Datas + * + * @return array|mixed + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contrat not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - $this->contract->$field = $value; - } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + $this->contract->$field = $value; + } - if ($this->contract->update(DolibarrApiAccess::$user) > 0) - { - return $this->get($id); - } else { - throw new RestException(500, $this->contract->error); - } - } + if ($this->contract->update(DolibarrApiAccess::$user) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $this->contract->error); + } + } - /** - * Delete contract - * - * @param int $id Contract ID - * - * @return array - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->contrat->supprimer) { - throw new RestException(401); - } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contract not found'); - } + /** + * Delete contract + * + * @param int $id Contract ID + * + * @return array + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->contrat->supprimer) { + throw new RestException(401); + } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contract not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!$this->contract->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when delete contract : '.$this->contract->error); - } + if (!$this->contract->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when delete contract : '.$this->contract->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Contract deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contract deleted' + ) + ); + } - /** - * Validate a contract - * - * @param int $id Contract ID - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * - * @url POST {id}/validate - * - * @return array - * FIXME An error 403 is returned if the request has an empty body. - * Error message: "Forbidden: Content type `text/plain` is not supported." - * Workaround: send this in the body - * { - * "notrigger": 0 - * } - */ - public function validate($id, $notrigger = 0) - { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contract not found'); - } + /** + * Validate a contract + * + * @param int $id Contract ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * + * @url POST {id}/validate + * + * @return array + * FIXME An error 403 is returned if the request has an empty body. + * Error message: "Forbidden: Content type `text/plain` is not supported." + * Workaround: send this in the body + * { + * "notrigger": 0 + * } + */ + public function validate($id, $notrigger = 0) + { + if (!DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contract not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); - } + $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Contract validated (Ref='.$this->contract->ref.')' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contract validated (Ref='.$this->contract->ref.')' + ) + ); + } - /** - * Close all services of a contract - * - * @param int $id Contract ID - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * - * @url POST {id}/close - * - * @return array - * FIXME An error 403 is returned if the request has an empty body. - * Error message: "Forbidden: Content type `text/plain` is not supported." - * Workaround: send this in the body - * { - * "notrigger": 0 - * } - */ - public function close($id, $notrigger = 0) - { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } - $result = $this->contract->fetch($id); - if (!$result) { - throw new RestException(404, 'Contract not found'); - } + /** + * Close all services of a contract + * + * @param int $id Contract ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * + * @url POST {id}/close + * + * @return array + * FIXME An error 403 is returned if the request has an empty body. + * Error message: "Forbidden: Content type `text/plain` is not supported." + * Workaround: send this in the body + * { + * "notrigger": 0 + * } + */ + public function close($id, $notrigger = 0) + { + if (!DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } + $result = $this->contract->fetch($id); + if (!$result) { + throw new RestException(404, 'Contract not found'); + } - if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already close'); - } - if ($result < 0) { - throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); - } + $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already close'); + } + if ($result < 0) { + throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.' + ) + ); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param object $object Object to clean - * @return array Array of cleaned object properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - unset($object->address); + unset($object->address); - unset($object->date_ouverture_prevue); - unset($object->date_ouverture); - unset($object->date_fin_validite); - unset($object->date_cloture); - unset($object->date_debut_prevue); - unset($object->date_debut_reel); - unset($object->date_fin_prevue); - unset($object->date_fin_reel); - unset($object->civility_id); + unset($object->date_ouverture_prevue); + unset($object->date_ouverture); + unset($object->date_fin_validite); + unset($object->date_cloture); + unset($object->date_debut_prevue); + unset($object->date_debut_reel); + unset($object->date_fin_prevue); + unset($object->date_fin_reel); + unset($object->civility_id); - return $object; - } + return $object; + } - /** - * Validate fields before create or update object - * - * @param array $data Array with data to verify - * @return array - * @throws RestException - */ - private function _validate($data) - { - $contrat = array(); - foreach (Contracts::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $contrat[$field] = $data[$field]; - } - return $contrat; - } + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + private function _validate($data) + { + $contrat = array(); + foreach (Contracts::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $contrat[$field] = $data[$field]; + } + return $contrat; + } } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 0b62146b080..99544b1037d 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -62,27 +62,27 @@ class Contrat extends CommonObject */ public $fk_element = 'fk_contrat'; - /** + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'contract'; - /** - * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - * @var int - */ - public $ismultientitymanaged = 1; + /** + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int + */ + public $ismultientitymanaged = 1; - /** - * @var int Does object support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; - /** - * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user - * @var integer - */ - public $restrictiononfksoc = 1; + /** + * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user + * @var integer + */ + public $restrictiononfksoc = 1; /** * {@inheritdoc} @@ -101,11 +101,11 @@ class Contrat extends CommonObject */ public $ref_supplier; - /** - * Entity of the contract - * @var int - */ - public $entity; + /** + * Entity of the contract + * @var int + */ + public $entity; /** * Client id linked to the contract @@ -310,7 +310,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -323,7 +323,7 @@ class Contrat extends CommonObject */ public function active_line($user, $line_id, $date, $date_end = '', $comment = '') { - // phpcs:enable + // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); if ($result < 0) { @@ -334,7 +334,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * @@ -346,7 +346,7 @@ class Contrat extends CommonObject */ public function close_line($user, $line_id, $date_end, $comment = '') { - // phpcs:enable + // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); if ($result < 0) { @@ -362,8 +362,8 @@ class Contrat extends CommonObject * * @param User $user Object User making action * @param int|string $date_start Date start (now if empty) - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @param string $comment Comment + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $comment Comment * @return int <0 if KO, >0 if OK * @see () */ @@ -416,8 +416,8 @@ class Contrat extends CommonObject * Close all lines of a contract * * @param User $user Object User making action - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @param string $comment Comment + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $comment Comment * @return int <0 if KO, >0 if OK * @see activateAll() */ @@ -436,7 +436,7 @@ class Contrat extends CommonObject { // Close lines not already closed if ($contratline->statut != ContratLigne::STATUS_CLOSED) - { + { $contratline->date_cloture = $now; $contratline->fk_user_cloture = $user->id; $contratline->statut = ContratLigne::STATUS_CLOSED; @@ -448,7 +448,7 @@ class Contrat extends CommonObject $this->errors = $contratline->errors; break; } - } + } } if (!$error && $this->statut == 0) @@ -457,14 +457,14 @@ class Contrat extends CommonObject if ($result < 0) $error++; } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } } /** @@ -472,7 +472,7 @@ class Contrat extends CommonObject * * @param User $user Objet User * @param string $force_number Reference to force on contract (not implemented yet) - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ public function validate(User $user, $force_number = '', $notrigger = 0) @@ -506,7 +506,7 @@ class Contrat extends CommonObject } else { $num = $this->ref; } - $this->newref = dol_sanitizeFileName($num); + $this->newref = dol_sanitizeFileName($num); if ($num) { @@ -526,15 +526,15 @@ class Contrat extends CommonObject // Trigger calls if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTRACT_VALIDATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTRACT_VALIDATE', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) { - $this->oldref = $this->ref; + $this->oldref = $this->ref; // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) @@ -557,16 +557,16 @@ class Contrat extends CommonObject if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource = $fileentry['path'].'/'.$dirsource; - $dirdest = $fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) + { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } } } } @@ -598,7 +598,7 @@ class Contrat extends CommonObject * Unvalidate a contract * * @param User $user Object User - * @param int $notrigger 1=Does not execute triggers, 0=execute triggers + * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @return int <0 if KO, >0 if OK */ public function reopen($user, $notrigger = 0) @@ -671,7 +671,7 @@ class Contrat extends CommonObject $sql = "SELECT rowid, statut, ref, fk_soc,"; $sql .= " ref_supplier, ref_customer,"; $sql .= " ref_ext,"; - $sql .= " entity,"; + $sql .= " entity,"; $sql .= " date_contrat as datecontrat,"; $sql .= " fk_user_author,"; $sql .= " fk_projet as fk_project,"; @@ -713,7 +713,7 @@ class Contrat extends CommonObject $this->ref_customer = $obj->ref_customer; $this->ref_supplier = $obj->ref_supplier; $this->ref_ext = $obj->ref_ext; - $this->entity = $obj->entity; + $this->entity = $obj->entity; $this->statut = $obj->statut; $this->date_contrat = $this->db->jdate($obj->datecontrat); @@ -727,7 +727,7 @@ class Contrat extends CommonObject $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; + $this->modelpdf = $obj->model_pdf; // deprecated $this->fk_projet = $obj->fk_project; // deprecated $this->fk_project = $obj->fk_project; @@ -765,7 +765,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines array into this->lines. * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed @@ -801,10 +801,10 @@ class Contrat extends CommonObject $extrafields->fetch_name_optionals_label($line->table_element, true); $this->lines = array(); - $pos = 0; + $pos = 0; // Selects contract lines related to a product - $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,"; + $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref, p.fk_product_type as product_type,"; $sql .= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; $sql .= " d.total_ht,"; $sql .= " d.total_tva,"; @@ -817,7 +817,8 @@ class Contrat extends CommonObject $sql .= " d.fk_user_author,"; $sql .= " d.fk_user_ouverture,"; $sql .= " d.fk_user_cloture,"; - $sql .= " d.fk_unit"; + $sql .= " d.fk_unit,"; + $sql .= " d.product_type as type"; $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql .= " WHERE d.fk_contrat = ".$this->id; $sql .= " ORDER by d.rowid ASC"; @@ -857,6 +858,7 @@ class Contrat extends CommonObject $line->total_ttc = $objp->total_ttc; $line->fk_product = (($objp->fk_product > 0) ? $objp->fk_product : 0); $line->info_bits = $objp->info_bits; + $line->type = $objp->type; $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); @@ -869,6 +871,7 @@ class Contrat extends CommonObject $line->ref = $objp->product_ref; // deprecated $line->product_ref = $objp->product_ref; // Product Ref + $line->product_type = $objp->product_type; // Product Type $line->product_desc = $objp->product_desc; // Product Description $line->product_label = $objp->product_label; // Product Label @@ -888,16 +891,16 @@ 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); - // Retreive all extrafields for contract + // Retrieve all extrafields for contract // 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(); - } + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); + } $this->lines[$pos] = $line; $this->lines_id_index_mapper[$line->id] = $pos; @@ -911,8 +914,8 @@ class Contrat extends CommonObject if ($line->statut == ContratLigne::STATUS_CLOSED) $this->nbofservicesclosed++; $total_ttc += $objp->total_ttc; // TODO Not saved into database - $total_vat += $objp->total_tva; - $total_ht += $objp->total_ht; + $total_vat += $objp->total_tva; + $total_ht += $objp->total_ht; $i++; $pos++; @@ -924,9 +927,9 @@ class Contrat extends CommonObject } $this->nbofservices = count($this->lines); - $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_vat = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_tva = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products return $this->lines; } @@ -1024,15 +1027,15 @@ class Contrat extends CommonObject // Insert business contacts ('SALESREPSIGN','contrat') if (!$error) { - $result = $this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); - if ($result < 0) $error++; + $result = $this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); + if ($result < 0) $error++; } // Insert business contacts ('SALESREPFOLL','contrat') if (!$error) { - $result = $this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); - if ($result < 0) $error++; + $result = $this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); + if ($result < 0) $error++; } if (!$error) @@ -1043,78 +1046,78 @@ class Contrat extends CommonObject } // Add object linked - if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - { - $origin_id = $tmp_origin_id; - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } - } + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) + { + foreach ($this->linked_objects as $origin => $tmp_origin_id) + { + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach ($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + { + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } + } - if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object - { - $originforcontact = $this->origin; - $originidforcontact = $this->origin_id; - if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order - { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - $exp = new Expedition($this->db); - $exp->fetch($this->origin_id); - $exp->fetchObjectLinked(); - if (count($exp->linkedObjectsIds['commande']) > 0) - { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value) - { - $originforcontact = 'commande'; - $originidforcontact = $value->id; - break; // We take first one - } - } - } + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object + { + $originforcontact = $this->origin; + $originidforcontact = $this->origin_id; + if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order + { + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + $exp = new Expedition($this->db); + $exp->fetch($this->origin_id); + $exp->fetchObjectLinked(); + if (count($exp->linkedObjectsIds['commande']) > 0) + { + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) + { + $originforcontact = 'commande'; + $originidforcontact = $value->id; + break; // We take first one + } + } + } - $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; + $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; - $resqlcontact = $this->db->query($sqlcontact); - if ($resqlcontact) - { - while ($objcontact = $this->db->fetch_object($resqlcontact)) - { - if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously + $resqlcontact = $this->db->query($sqlcontact); + if ($resqlcontact) + { + while ($objcontact = $this->db->fetch_object($resqlcontact)) + { + if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously - //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object - } - } else dol_print_error($resqlcontact); - } + //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + } + } else dol_print_error($resqlcontact); + } } if (!$error) { - // Call trigger - $result = $this->call_trigger('CONTRACT_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTRACT_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers if (!$error) { @@ -1155,10 +1158,10 @@ class Contrat extends CommonObject $this->db->begin(); - // Call trigger - $result = $this->call_trigger('CONTRACT_DELETE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTRACT_DELETE', $user); + if ($result < 0) { $error++; } + // End call triggers if (!$error) { @@ -1221,8 +1224,8 @@ class Contrat extends CommonObject } } - if (!$error) - { + // Delete lines + if (!$error) { // Delete contratdet extrafields $main = MAIN_DB_PREFIX.'contratdet'; $ef = $main."_extrafields"; @@ -1252,9 +1255,21 @@ class Contrat extends CommonObject } } + // Delete llx_ecm_files + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + $error++; + } + } + + // Delete contract if (!$error) { - // Delete contrat $sql = "DELETE FROM ".MAIN_DB_PREFIX."contrat"; $sql .= " WHERE rowid=".$this->id; @@ -1343,7 +1358,7 @@ class Contrat extends CommonObject // Put here code to add a control on parameters values // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; $sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").","; $sql .= " ref_supplier=".(isset($this->ref_supplier) ? "'".$this->db->escape($this->ref_supplier)."'" : "null").","; @@ -1465,7 +1480,7 @@ class Contrat extends CommonObject if (empty($pu_ttc)) $pu_ttc = 0; if (empty($txtva) || !is_numeric($txtva)) $txtva = 0; if (empty($txlocaltax1) || !is_numeric($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2) || !is_numeric($txlocaltax2)) $txlocaltax2 = 0; + if (empty($txlocaltax2) || !is_numeric($txlocaltax2)) $txlocaltax2 = 0; if ($price_base_type == 'HT') { @@ -1512,7 +1527,7 @@ class Contrat extends CommonObject $price = $pu_ht - $remise; } - if (empty($pa_ht)) $pa_ht = 0; + if (empty($pa_ht)) $pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin @@ -1579,13 +1594,13 @@ class Contrat extends CommonObject } if (empty($error)) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_INSERT', $user); - if ($result < 0) - { - $error++; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_INSERT', $user); + if ($result < 0) + { + $error++; + } + // End call triggers } if ($error) @@ -1691,11 +1706,11 @@ class Contrat extends CommonObject $price = price2num(round($pu, 2)); if (dol_strlen($remise_percent) > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; + $remise = round(($pu * $remise_percent / 100), 2); + $price = $pu - $remise; } - if (empty($pa_ht)) $pa_ht = 0; + if (empty($pa_ht)) $pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) @@ -1760,14 +1775,14 @@ class Contrat extends CommonObject } if (empty($error)) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -3; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -3; + } + // End call triggers $this->db->commit(); return 1; @@ -1800,14 +1815,14 @@ class Contrat extends CommonObject if ($this->statut >= 0) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_DELETE', $user); - if ($result < 0) return -1; - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_DELETE', $user); + if ($result < 0) return -1; + // End call triggers - $this->db->begin(); + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; $sql .= " WHERE rowid=".$idline; dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); @@ -1845,7 +1860,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update statut of contract according to services * @@ -1855,7 +1870,7 @@ class Contrat extends CommonObject */ public function update_statut($user) { - // phpcs:enable + // phpcs:enable dol_syslog(__METHOD__." is deprecated", LOG_WARNING); // If draft, we keep it (should not happen) @@ -1864,11 +1879,11 @@ class Contrat extends CommonObject // Load $this->lines array // $this->fetch_lines(); - // $newstatut=1; - // foreach($this->lines as $key => $contractline) - // { - // // if ($contractline) // Loop on each service - // } + // $newstatut=1; + // foreach($this->lines as $key => $contractline) + // { + // // if ($contractline) // Loop on each service + // } return 1; } @@ -1885,7 +1900,7 @@ class Contrat extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi label of a given contrat status * @@ -1895,19 +1910,19 @@ class Contrat extends CommonObject */ public function LibStatut($status, $mode) { - // phpcs:enable + // phpcs:enable global $langs; if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; $langs->load("contracts"); - $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('ContractStatusDraft'); - $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('ContractStatusValidated'); - $this->labelStatus[self::STATUS_CLOSED] = $langs->trans('ContractStatusClosed'); - $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('ContractStatusDraft'); - $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('ContractStatusValidated'); - $this->labelStatusShort[self::STATUS_CLOSED] = $langs->trans('ContractStatusClosed'); + $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('ContractStatusDraft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('ContractStatusValidated'); + $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('ContractStatusClosed'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('ContractStatusDraft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('ContractStatusValidated'); + $this->labelStatusShort[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('ContractStatusClosed'); } $statusType = 'status'.$status; @@ -1944,11 +1959,11 @@ class Contrat extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $maxlength Max length of ref - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user, $hookmanager; @@ -1964,35 +1979,39 @@ class Contrat extends CommonObject if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; //} - $label = ''; + $label = ''; - if ($user->rights->contrat->lire) { - $label = img_picto('', $this->picto).' '.$langs->trans("Contract").''; - $label .= '
    '.$langs->trans('Ref').': '.($this->ref ? $this->ref : $this->id); - $label .= '
    '.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); - $label .= '
    '.$langs->trans('RefSupplier').': '.$this->ref_supplier; - if (!empty($this->total_ht)) { - $label .= '
    '.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
    '.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
    '.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } - } + if ($user->rights->contrat->lire) { + $label = img_picto('', $this->picto).' '.$langs->trans("Contract").''; + /* Status of a contract is status of all services, so disabled + if (isset($this->statut)) { + $label .= ' '.$this->getLibStatut(5); + }*/ + $label .= '
    '.$langs->trans('Ref').': '.($this->ref ? $this->ref : $this->id); + $label .= '
    '.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); + $label .= '
    '.$langs->trans('RefSupplier').': '.$this->ref_supplier; + if (!empty($this->total_ht)) { + $label .= '
    '.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $label .= '
    '.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $label .= '
    '.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + } - $linkclose = ''; - if (empty($notooltip) && $user->rights->contrat->lire) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowOrder"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose = ''; + if (empty($notooltip) && $user->rights->contrat->lire) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowOrder"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } $linkstart = ''; @@ -2056,7 +2075,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of line rowid * @@ -2065,7 +2084,7 @@ class Contrat extends CommonObject */ public function array_detail($status = -1) { - // phpcs:enable + // phpcs:enable $tab = array(); $sql = "SELECT cd.rowid"; @@ -2129,17 +2148,17 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @param User $user Objet user - * @param string $mode "inactive" pour services a activer, "expired" pour services expires - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Objet user + * @param string $mode "inactive" pour services a activer, "expired" pour services expires + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - public function load_board($user, $mode) + public function load_board($user, $mode) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $this->from = " FROM ".MAIN_DB_PREFIX."contrat as c"; @@ -2164,13 +2183,13 @@ class Contrat extends CommonObject $sql .= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'"; } elseif ($mode == 'active') { - $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; - $sql .= $this->from; - $sql .= " WHERE c.statut = 1"; - $sql .= " AND c.rowid = cd.fk_contrat"; - $sql .= " AND cd.statut = 4"; - //$datetouse = dol_now(); - //$sql.= " AND cd.date_fin_validite < '".$this->db->idate($datetouse)."'"; + $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; + $sql .= $this->from; + $sql .= " WHERE c.statut = 1"; + $sql .= " AND c.rowid = cd.fk_contrat"; + $sql .= " AND cd.statut = 4"; + //$datetouse = dol_now(); + //$sql.= " AND cd.date_fin_validite < '".$this->db->idate($datetouse)."'"; } $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.entity = ".$conf->entity; @@ -2189,10 +2208,10 @@ class Contrat extends CommonObject $labelShort = $langs->trans("BoardNotActivatedServicesShort"); $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=0&sortfield=cd.date_fin_validite&sortorder=asc'; } elseif ($mode == 'expired') { - $warning_delay = $conf->contrat->services->expires->warning_delay; - $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; - $label = $langs->trans("BoardExpiredServices"); - $labelShort = $langs->trans("BoardExpiredServicesShort"); + $warning_delay = $conf->contrat->services->expires->warning_delay; + $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; + $label = $langs->trans("BoardExpiredServices"); + $labelShort = $langs->trans("BoardExpiredServicesShort"); } else { $warning_delay = $conf->contrat->services->expires->warning_delay; $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&sortfield=cd.date_fin_validite&sortorder=asc'; @@ -2226,7 +2245,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * @@ -2234,7 +2253,7 @@ class Contrat extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable global $conf, $user; $this->nb = array(); @@ -2258,7 +2277,7 @@ class Contrat extends CommonObject { $this->nb["contracts"] = $obj->nb; } - $this->db->free($resql); + $this->db->free($resql); return 1; } else { dol_print_error($this->db); @@ -2292,17 +2311,17 @@ class Contrat extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { global $user, $langs, $conf; - // Load array of products prodids + // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; @@ -2359,10 +2378,10 @@ class Contrat extends CommonObject $line->date_end = dol_now() + 500000; $line->date_end_real = dol_now() - 100000; if ($num_prods > 0) - { + { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; - } + } $this->lines[$xnbp] = $line; $xnbp++; } @@ -2387,7 +2406,7 @@ class Contrat extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -2400,7 +2419,7 @@ class Contrat extends CommonObject if (!dol_strlen($modele)) { $modele = 'strato'; - if ($this->modelpdf) { + if (!empty($this->modelpdf)) { $modele = $this->modelpdf; } elseif (!empty($conf->global->CONTRACT_ADDON_PDF)) { $modele = $conf->global->CONTRACT_ADDON_PDF; @@ -2437,8 +2456,8 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int New id of clone */ - public function createFromClone(User $user, $socid = 0, $notrigger = 0) - { + public function createFromClone(User $user, $socid = 0, $notrigger = 0) + { global $db, $langs, $conf, $hookmanager, $extrafields; dol_include_once('/projet/class/project.class.php'); @@ -2449,7 +2468,7 @@ class Contrat extends CommonObject // Load dest object $clonedObj = clone $this; - $clonedObj->socid = $socid; + $clonedObj->socid = $socid; $this->db->begin(); @@ -2500,13 +2519,13 @@ class Contrat extends CommonObject $this->error = $clonedObj->error; $this->errors[] = $clonedObj->error; } else { - // copy external contacts if same company - if ($this->socid == $clonedObj->socid) { - if ($clonedObj->copy_linked_contact($this, 'external') < 0) { - $error++; - } - } - } + // copy external contacts if same company + if ($this->socid == $clonedObj->socid) { + if ($clonedObj->copy_linked_contact($this, 'external') < 0) { + $error++; + } + } + } if (!$error) { foreach ($this->lines as $line) { @@ -2552,12 +2571,12 @@ class Contrat extends CommonObject */ class ContratLigne extends CommonObjectLine { - /** + /** * @var string ID to identify managed object */ public $element = 'contratdet'; - /** + /** * @var string Name of table without prefix where object is stored */ public $table_element = 'contratdet'; @@ -2575,13 +2594,13 @@ class ContratLigne extends CommonObjectLine public $tms; /** - * @var int ID - */ + * @var int ID + */ public $fk_contrat; /** - * @var int ID - */ + * @var int ID + */ public $fk_product; public $statut; // 0 inactive, 4 active, 5 closed @@ -2604,6 +2623,7 @@ class ContratLigne extends CommonObjectLine */ public $description; + public $product_type; // 0 for product, 1 for service public $product_ref; public $product_label; @@ -2628,8 +2648,8 @@ class ContratLigne extends CommonObjectLine public $remise; /** - * @var int ID - */ + * @var int ID + */ public $fk_remise_except; public $subprice; // Unit price HT @@ -2650,8 +2670,8 @@ class ContratLigne extends CommonObjectLine public $total_ttc; /** - * @var int ID - */ + * @var int ID + */ public $fk_fournprice; public $pa_ht; @@ -2659,18 +2679,18 @@ class ContratLigne extends CommonObjectLine public $info_bits; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_ouverture; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_cloture; public $commentaire; @@ -2682,9 +2702,9 @@ class ContratLigne extends CommonObjectLine /** - * Constructor - * - * @param DoliDb $db Database handler + * Constructor + * + * @param DoliDb $db Database handler */ public function __construct($db) { @@ -2703,7 +2723,7 @@ class ContratLigne extends CommonObjectLine return $this->LibStatut($this->statut, $mode, ((!empty($this->date_fin_validite)) ? ($this->date_fin_validite < dol_now() ? 1 : 0) : -1)); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a contract line status * @@ -2715,26 +2735,26 @@ class ContratLigne extends CommonObjectLine */ public static function LibStatut($status, $mode, $expired = -1, $moreatt = '') { - // phpcs:enable + // phpcs:enable global $langs; $langs->load("contracts"); - if ($status == self::STATUS_INITIAL) { - $labelStatus = $langs->trans("ServiceStatusInitial"); - $labelStatusShort = $langs->trans("ServiceStatusInitial"); - } elseif ($status == self::STATUS_OPEN && $expired == -1) { - $labelStatus = $langs->trans("ServiceStatusRunning"); - $labelStatusShort = $langs->trans("ServiceStatusRunning"); - } elseif ($status == self::STATUS_OPEN && $expired == 0) { - $labelStatus = $langs->trans("ServiceStatusNotLate"); - $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); - } elseif ($status == self::STATUS_OPEN && $expired == 1) { - $labelStatus = $langs->trans("ServiceStatusLate"); - $labelStatusShort = $langs->trans("ServiceStatusLateShort"); - } elseif ($status == self::STATUS_CLOSED) { - $labelStatus = $langs->trans("ServiceStatusClosed"); - $labelStatusShort = $langs->trans("ServiceStatusClosed"); - } + if ($status == self::STATUS_INITIAL) { + $labelStatus = $langs->trans("ServiceStatusInitial"); + $labelStatusShort = $langs->trans("ServiceStatusInitial"); + } elseif ($status == self::STATUS_OPEN && $expired == -1) { + $labelStatus = $langs->trans("ServiceStatusRunning"); + $labelStatusShort = $langs->trans("ServiceStatusRunning"); + } elseif ($status == self::STATUS_OPEN && $expired == 0) { + $labelStatus = $langs->trans("ServiceStatusNotLate"); + $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); + } elseif ($status == self::STATUS_OPEN && $expired == 1) { + $labelStatus = $langs->trans("ServiceStatusLate"); + $labelStatusShort = $langs->trans("ServiceStatusLateShort"); + } elseif ($status == self::STATUS_CLOSED) { + $labelStatus = $langs->trans("ServiceStatusClosed"); + $labelStatusShort = $langs->trans("ServiceStatusClosed"); + } $statusType = 'status'.$status; if ($status == self::STATUS_OPEN && $expired == 1) $statusType = 'status1'; @@ -2754,22 +2774,22 @@ class ContratLigne extends CommonObjectLine * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $maxlength Max length * @return string Chaine avec URL - */ - public function getNomUrl($withpicto = 0, $maxlength = 0) + */ + public function getNomUrl($withpicto = 0, $maxlength = 0) { global $langs; $result = ''; - $label = $langs->trans("ShowContractOfService").': '.$this->label; - if (empty($label)) $label = $this->description; + $label = $langs->trans("ShowContractOfService").': '.$this->label; + if (empty($label)) $label = $this->description; - $link = ''; + $link = ''; $linkend = ''; $picto = 'service'; if ($this->type == 0) $picto = 'product'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $link.($this->product_ref ? $this->product_ref.' ' : '').($this->label ? $this->label : $this->description).$linkend; return $result; @@ -2782,7 +2802,7 @@ class ContratLigne extends CommonObjectLine * @param string $ref Ref of contract line * @return int <0 if KO, >0 if OK */ - public function fetch($id, $ref = '') + public function fetch($id, $ref = '') { // Check parameters if (empty($id) && empty($ref)) return -1; @@ -2977,7 +2997,7 @@ class ContratLigne extends CommonObjectLine $this->total_localtax1 = $tabprice[9]; $this->total_localtax2 = $tabprice[10]; - if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->pa_ht)) $this->pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) @@ -2995,7 +3015,7 @@ class ContratLigne extends CommonObjectLine $this->oldcopy = new ContratLigne($this->db); $this->oldcopy->fetch($this->id); - $this->oldcopy->fetch_optionals(); + $this->oldcopy->fetch_optionals(); // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; @@ -3083,18 +3103,18 @@ class ContratLigne extends CommonObjectLine } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); - if ($result < 0) { - $error++; - $this->db->rollback(); - } - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); + if ($result < 0) { + $error++; + $this->db->rollback(); + } + // End call triggers } if (!$error) { - $this->db->commit(); + $this->db->commit(); return 1; } else { $this->db->rollback(); @@ -3104,7 +3124,7 @@ class ContratLigne extends CommonObjectLine } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base des champs total_xxx de ligne * Used by migration process @@ -3113,7 +3133,7 @@ class ContratLigne extends CommonObjectLine */ public function update_total() { - // phpcs:enable + // phpcs:enable $this->db->begin(); // Mise a jour ligne en base @@ -3220,7 +3240,7 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -3232,7 +3252,7 @@ class ContratLigne extends CommonObjectLine */ public function active_line($user, $date, $date_end = '', $comment = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; $error = 0; @@ -3277,19 +3297,19 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * * @param User $user Objet User who close contract * @param int $date_end Date end * @param string $comment A comment typed by user - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ public function close_line($user, $date_end, $comment = '', $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $langs, $conf; // Update object diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 38a97d0aaa8..24b0ff54bf6 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -60,11 +60,11 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) { $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } + } if ($result >= 0) { @@ -87,7 +87,7 @@ if ($action == 'swapstatut' && $user->rights->contrat->creer) { if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db, $object->error); } @@ -130,21 +130,21 @@ if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); - $head = contract_prepare_head($object); + $head = contract_prepare_head($object); $hselected = 1; - dol_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); + print dol_get_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); // Contract card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = ''; - //if (! empty($modCodeContract->code_auto)) { - $morehtmlref .= $object->ref; - /*} else { + $morehtmlref = ''; + //if (! empty($modCodeContract->code_auto)) { + $morehtmlref .= $object->ref; + /*} else { $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3); $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2); }*/ @@ -158,67 +158,67 @@ if ($id > 0 || !empty($ref)) $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); // Thirdparty - $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - // Project - if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
    '.$langs->trans('Project').' '; - if ($user->rights->contrat->creer) { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
    '; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $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->thirdparty->id, $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 .= '
    '; + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + // Project + if (!empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
    '.$langs->trans('Project').' '; + if ($user->rights->contrat->creer) { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $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->thirdparty->id, $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 .= ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); - print '
    '; - print '
    '; + print '
    '; + print '
    '; print ''; - // Ligne info remises tiers - print ''; + // Ligne info remises tiers + print ''; - // Date - print ''; + // Date + print ''; print ''; - print ''; - print ''; - print "\n"; - } - if ($status == 4 && !$bool) $bool = true; - else $bool = false; + if (empty($conf->use_javascript_ajax)) + { + print ''; + print ''; + print ''; + print "\n"; + } + if ($status == 4 && !$bool) $bool = true; + else $bool = false; } if (!empty($conf->use_javascript_ajax)) { - print ''; + print ''; } $listofstatus = array(0, 4, 4, 5); $bool = false; foreach ($listofstatus as $status) { - if (empty($conf->use_javascript_ajax)) - { - print ''; - print ''; - print ''; - if ($status == 4 && !$bool) $bool = true; - else $bool = false; - print "\n"; - } + if (empty($conf->use_javascript_ajax)) + { + print ''; + print ''; + print ''; + if ($status == 4 && !$bool) $bool = true; + else $bool = false; + print "\n"; + } } //if ($totalinprocess != $total) //print ''; @@ -424,15 +424,15 @@ if ($resql) print ''; print ''; + print ''; print ''; print ''; + print ''; } if (!empty($arrayfields['c.ref_supplier']['checked'])) { diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index d9eb8e3ccdc..c9000c4fb0d 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -72,101 +72,101 @@ $form = new Form($db); if ($id > 0 || !empty($ref)) { - $object->fetch_thirdparty(); + $object->fetch_thirdparty(); - $head = contract_prepare_head($object); + $head = contract_prepare_head($object); - $hselected = 2; + $hselected = 2; - dol_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract'); + print dol_get_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract'); - // Contract card + // Contract card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = ''; - //if (! empty($modCodeContract->code_auto)) { - $morehtmlref .= $object->ref; - /*} else { + $morehtmlref = ''; + //if (! empty($modCodeContract->code_auto)) { + $morehtmlref .= $object->ref; + /*} else { $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3); $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2); }*/ - $morehtmlref .= '
    '; - // Ref customer - $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); - // Ref supplier - $morehtmlref .= '
    '; - $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); - // Thirdparty - $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
    '.$langs->trans('Project').' '; - if ($user->rights->contrat->creer) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
    '; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $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->thirdparty->id, $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 .= '
    '; + $morehtmlref .= '
    '; + // Ref customer + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); + // Ref supplier + $morehtmlref .= '
    '; + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); + // Thirdparty + $morehtmlref .= '
    '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
    '.$langs->trans('Project').' '; + if ($user->rights->contrat->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $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->thirdparty->id, $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 .= '
    '; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); - print '
    '; - print '
    '; + print '
    '; + print '
    '; - print '
    '.$langs->trans('Discount').''; - if ($object->thirdparty->remise_percent) { - print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); - } else { - print $langs->trans("CompanyHasNoRelativeDiscount"); - } - $absolute_discount = $object->thirdparty->getAvailableDiscounts(); - print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print '
    '.$langs->trans('Discount').''; + if ($object->thirdparty->remise_percent) { + print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); + } else { + print $langs->trans("CompanyHasNoRelativeDiscount"); + } + $absolute_discount = $object->thirdparty->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
    '; print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0); print ''; @@ -230,7 +230,7 @@ if ($id > 0 || !empty($ref)) print ''; - dol_fiche_end(); + print dol_get_fiche_end(); print '
    '; diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index d60d54258bb..b68da3170ed 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -101,7 +101,7 @@ if ($object->id) { $head = contract_prepare_head($object); - dol_fiche_head($head, 'documents', $langs->trans("Contract"), -1, 'contract'); + print dol_get_fiche_head($head, 'documents', $langs->trans("Contract"), -1, 'contract'); // Build file list @@ -179,20 +179,20 @@ if ($object->id) print '
    '; print '
    '; - print ''; - print ''; - print ''; - print '
    '.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
    '.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
    '; + print ''; + print ''; + print ''; + print '
    '.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
    '.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
    '; - print '
    '; + print ''; - dol_fiche_end(); + print dol_get_fiche_end(); - $modulepart = 'contract'; - $permission = $user->rights->contrat->creer; - $permtoedit = $user->rights->contrat->creer; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $modulepart = 'contract'; + $permission = $user->rights->contrat->creer; + $permtoedit = $user->rights->contrat->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 7fe88d03c3d..5ea558c9689 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -80,21 +80,21 @@ print '
    '; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { - // Search contract - if (!empty($conf->contrat->enabled)) - { - print '
    '; - print ''; + // Search contract + if (!empty($conf->contrat->enabled)) + { + print ''; + print ''; print '
    '; - print ''; - print ''; - print ''; - print ''; - print ''; - print "
    '.$langs->trans("Search").'
    '.$langs->trans("Contract").':
    \n"; - print "
    "; - } + print ''; + print ''; + print ''; + print ''; + print ''; + print "
    '.$langs->trans("Search").'
    '.$langs->trans("Contract").':
    \n"; + print "
    "; + } } @@ -131,11 +131,11 @@ if ($resql) { $nb[$obj->status] = $obj->nb; if ($obj->status != 5) - { - $vals[$obj->status] = $obj->nb; - $totalinprocess += $obj->nb; - } - $total += $obj->nb; + { + $vals[$obj->status] = $obj->nb; + $totalinprocess += $obj->nb; + } + $total += $obj->nb; } $i++; } @@ -159,24 +159,24 @@ if ($resql) { $num = $db->num_rows($resql); - // 0 inactive, 4 active, 5 closed - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj) - { - $nb[$obj->status.true] = $obj->nb; - if ($obj->status != 5) - { - $vals[$obj->status.true] = $obj->nb; - $totalinprocess += $obj->nb; - } - $total += $obj->nb; - } - $i++; - } - $db->free($resql); + // 0 inactive, 4 active, 5 closed + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $nb[$obj->status.true] = $obj->nb; + if ($obj->status != 5) + { + $vals[$obj->status.true] = $obj->nb; + $totalinprocess += $obj->nb; + } + $total += $obj->nb; + } + $i++; + } + $db->free($resql); } else { dol_print_error($db); } @@ -191,51 +191,51 @@ print '
    '.$langs->trans("Statistics").' - $listofstatus = array(0, 4, 4, 5); $bool = false; foreach ($listofstatus as $status) { - $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0)); - if ($status == ContratLigne::STATUS_INITIAL) $colorseries[$status.$bool] = '-'.$badgeStatus0; - if ($status == ContratLigne::STATUS_OPEN && !$bool) $colorseries[$status.$bool] = $badgeStatus4; - if ($status == ContratLigne::STATUS_OPEN && $bool) $colorseries[$status.$bool] = $badgeStatus1; - if ($status == ContratLigne::STATUS_CLOSED) $colorseries[$status.$bool] = $badgeStatus6; + $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0)); + if ($status == ContratLigne::STATUS_INITIAL) $colorseries[$status.$bool] = '-'.$badgeStatus0; + if ($status == ContratLigne::STATUS_OPEN && !$bool) $colorseries[$status.$bool] = $badgeStatus4; + if ($status == ContratLigne::STATUS_OPEN && $bool) $colorseries[$status.$bool] = $badgeStatus1; + if ($status == ContratLigne::STATUS_CLOSED) $colorseries[$status.$bool] = $badgeStatus6; - if (empty($conf->use_javascript_ajax)) - { - print '
    '.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
    '.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
    '; + print '
    '; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); - print '
    '.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
    '.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
    '.$langs->trans("Total").' ('.$langs->trans("ServicesRunning").')'.$totalinprocess.'
    '; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; - print $productstatic->getNomUrl(1, '', 20); + print $productstatic->getNomUrl(1, '', 20); } else { - print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + print ''.img_object($langs->trans("ShowService"), "service"); + if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; + else print ' '.dol_trunc($obj->note, 20); } print ''; @@ -500,17 +500,17 @@ if ($resql) print ''; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; - print $productstatic->getNomUrl(1, '', 20); + print $productstatic->getNomUrl(1, '', 20); } else { - print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + print ''.img_object($langs->trans("ShowService"), "service"); + if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; + else print ' '.dol_trunc($obj->note, 20); } - print ''; $staticcompany->id = $obj->fk_soc; $staticcompany->name = $obj->name; @@ -576,15 +576,15 @@ if ($resql) print ''; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; - print $productstatic->getNomUrl(1, '', 20); + print $productstatic->getNomUrl(1, '', 20); } else { - print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + print ''.img_object($langs->trans("ShowService"), "service"); + if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; + else print ' '.dol_trunc($obj->note, 20); } print ''; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 04329a63145..18b47b7102a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -363,7 +363,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), - 'presend'=>$langs->trans("SendByMail"), + 'presend'=>$langs->trans("SendByMail"), ); if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -579,13 +579,13 @@ $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$ $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['c.datec']['checked'])) { - print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['c.tms']['checked'])) { - print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['lower_planned_end_date']['checked'])) { - print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['status']['checked'])) { print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); @@ -634,7 +634,7 @@ while ($i < min($num, $limit)) if (!empty($arrayfields['c.ref_customer']['checked'])) { - print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).'
    '; + print '
    '; - // Ligne info remises tiers - print ''; + // Ligne info remises tiers + print ''; - // Date - print ''; - print ''; - print ''; + // Date + print ''; + print ''; + print ''; print "
    '.$langs->trans('Discount').''; - if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount = $object->thirdparty->getAvailableDiscounts(); - print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print '
    '.$langs->trans('Discount').''; + if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + $absolute_discount = $object->thirdparty->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
    '; - print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0); - print ''; - print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, 0, 'datehourpicker'); - print '
    '; + print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0); + print ''; + print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, 0, 'datehourpicker'); + print '
    "; @@ -176,7 +176,7 @@ if ($id > 0 || !empty($ref)) include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); + print dol_get_fiche_end(); } diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 7279ab98781..67b605d657f 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -245,30 +245,30 @@ if ($search_contract) $sql .= " AND c.ref LIKE '%".$db->escape($search_contract) if ($search_service) $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; if ($socid > 0) $sql .= " AND s.rowid = ".$socid; -$filter_dateouvertureprevue_start=dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); -$filter_dateouvertureprevue_end=dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); +$filter_dateouvertureprevue_start = dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); +$filter_dateouvertureprevue_end = dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); if ($filter_dateouvertureprevue_start != '' && $filter_opouvertureprevue == -1) $filter_opouvertureprevue = ' BETWEEN '; -$filter_date1_start =dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); -$filter_date1_end =dol_mktime(23, 59, 59, $op1month, $op1day, $op1year); +$filter_date1_start = dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); +$filter_date1_end = dol_mktime(23, 59, 59, $op1month, $op1day, $op1year); if ($filter_date1_start != '' && $filter_op1 == -1) $filter_op1 = ' BETWEEN '; -$filter_date2_start=dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); -$filter_date2_end=dol_mktime(23, 59, 59, $op2month, $op2day, $op2year); +$filter_date2_start = dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); +$filter_date2_end = dol_mktime(23, 59, 59, $op2month, $op2day, $op2year); if ($filter_date2_start != '' && $filter_op2 == -1) $filter_op2 = ' BETWEEN '; -$filter_datecloture_start=dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); -$filter_datecloture_end=dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear); +$filter_datecloture_start = dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); +$filter_datecloture_end = dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear); if ($filter_datecloture_start != '' && $filter_opcloture == -1) $filter_opcloture = ' BETWEEN '; -if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') $sql.= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'"; -if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') $sql.= " AND '".$db->idate($filter_dateouvertureprevue_end)."'"; -if (! empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') $sql.= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'"; -if (! empty($filter_op1) && $filter_op1==' BETWEEN ') $sql.= " AND '".$db->idate($filter_date1_end)."'"; -if (! empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') $sql.= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'"; -if (! empty($filter_op2) && $filter_op2==' BETWEEN ') $sql.= " AND '".$db->idate($filter_date2_end)."'"; -if (! empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') $sql.= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'"; -if (! empty($filter_opcloture) && $filter_opcloture==' BETWEEN ') $sql.= " AND '".$db->idate($filter_datecloture_end)."'"; +if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') $sql .= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'"; +if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_dateouvertureprevue_end)."'"; +if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') $sql .= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'"; +if (!empty($filter_op1) && $filter_op1 == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_date1_end)."'"; +if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') $sql .= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'"; +if (!empty($filter_op2) && $filter_op2 == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_date2_end)."'"; +if (!empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') $sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'"; +if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_datecloture_end)."'"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $sql .= $db->order($sortfield, $sortorder); @@ -581,7 +581,7 @@ while ($i < min($num, $limit)) print ''; print $contractstatic->getNomUrl(1, 16); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Service if (!empty($arrayfields['p.description']['checked'])) @@ -601,7 +601,7 @@ while ($i < min($num, $limit)) if ($obj->type == 1) print img_object($obj->description, 'service').' '.dol_trunc($obj->description, 24); } print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.qty']['checked'])) @@ -609,39 +609,39 @@ while ($i < min($num, $limit)) print ''; print $obj->qty; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.total_ht']['checked'])) { print ''; print price($obj->total_ht); print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht'; - $totalarray['val']['cd.total_ht'] += $obj->total_ht; - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht'; + $totalarray['val']['cd.total_ht'] += $obj->total_ht; + } if (!empty($arrayfields['cd.total_tva']['checked'])) { print ''; print price($obj->total_tva); print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva'; - $totalarray['val']['cd.total_tva'] += $obj->total_tva; - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva'; + $totalarray['val']['cd.total_tva'] += $obj->total_tva; + } if (!empty($arrayfields['cd.tva_tx']['checked'])) { print ''; print price2num($obj->tva_tx).'%'; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.subprice']['checked'])) { print ''; print price($obj->subprice); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } @@ -651,7 +651,7 @@ while ($i < min($num, $limit)) print ''; print $companystatic->getNomUrl(1, 'customer', 28); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Start date @@ -663,12 +663,12 @@ while ($i < min($num, $limit)) print ' '.img_picto($langs->trans("Late"), "warning"); else print '    '; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.date_ouverture']['checked'])) { print ''.($obj->date_ouverture ?dol_print_date($db->jdate($obj->date_ouverture), 'dayhour') : ' ').''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // End date if (!empty($arrayfields['cd.date_fin_validite']['checked'])) @@ -681,13 +681,13 @@ while ($i < min($num, $limit)) print img_warning($textlate); } else print '    '; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Close date (real end date) if (!empty($arrayfields['cd.date_cloture']['checked'])) { print ''.dol_print_date($db->jdate($obj->date_cloture), 'dayhour').''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields @@ -715,16 +715,16 @@ while ($i < min($num, $limit)) // Status if (!empty($arrayfields['status']['checked'])) { - print ''; - if ($obj->cstatut == 0) - { + print ''; + if ($obj->cstatut == 0) + { // If contract is draft, we say line is also draft - print $contractstatic->LibStatut(0, 5); - } else { - print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0); - } - print ''; - if (!$i) $totalarray['nbfield']++; + print $contractstatic->LibStatut(0, 5); + } else { + print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0); + } + print ''; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index 57b885f24d2..339f51db22c 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -39,10 +39,10 @@ $langs->load("contracts"); $total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - $ilink++; + $ilink++; - $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; ?> trans("Contract"); ?> @@ -58,7 +58,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) $totalcontrat = 0; foreach ($objectlink->lines as $linecontrat) { $totalcontrat = $totalcontrat + $linecontrat->total_ht; - $total = $total + $linecontrat->total_ht; + $total = $total + $linecontrat->total_ht; } echo price($totalcontrat); } ?> diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 219d35e46fb..ad36a6e5ee7 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -60,7 +60,10 @@ if ($action == 'add' && !empty($permissiontoadd)) if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited } // Ignore special fields - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; + if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; + if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { + if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create + } // Set value to insert if (in_array($object->fields[$key]['type'], array('text', 'html'))) { @@ -75,6 +78,9 @@ if ($action == 'add' && !empty($permissiontoadd)) $value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup } elseif ($object->fields[$key]['type'] == 'boolean') { $value = ((GETPOST($key) == '1' || GETPOST($key) == 'on') ? 1 : 0); + } elseif ($object->fields[$key]['type'] == 'reference') { + $tmparraykey = array_keys($object->param_list); + $value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2'); } else { $value = GETPOST($key, 'alphanohtml'); } @@ -138,7 +144,10 @@ if ($action == 'update' && !empty($permissiontoadd)) if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited } // Ignore special fields - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; + if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; + if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { + if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update + } // Set value to update if (preg_match('/^(text|html)/', $object->fields[$key]['type'])) { @@ -162,6 +171,8 @@ if ($action == 'update' && !empty($permissiontoadd)) $value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup } elseif ($object->fields[$key]['type'] == 'boolean') { $value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0); + } elseif ($object->fields[$key]['type'] == 'reference') { + $value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2'); } else { $value = GETPOST($key, 'alpha'); } @@ -305,6 +316,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) $outputlangs->setDefaultLang($newlang); } $model = $object->model_pdf; + $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 20bd19625cc..4ae83829fa4 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -34,102 +34,102 @@ if (!empty($permissioncreate) && empty($permissiontoadd)) $permissiontoadd = $pe // Build doc if ($action == 'builddoc' && $permissiontoadd) { - if (is_numeric(GETPOST('model', 'alpha'))) - { - $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); - } else { + if (is_numeric(GETPOST('model', 'alpha'))) + { + $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); + } else { // Reload to get all modified line records and be ready for hooks - $ret = $object->fetch($id); - $ret = $object->fetch_thirdparty(); - /*if (empty($object->id) || ! $object->id > 0) + $ret = $object->fetch($id); + $ret = $object->fetch_thirdparty(); + /*if (empty($object->id) || ! $object->id > 0) { dol_print_error('Object must have been loaded by a fetch'); exit; }*/ - // Save last template used to generate document - if (GETPOST('model', 'alpha')) - { - $object->setDocModel($user, GETPOST('model', 'alpha')); - } + // Save last template used to generate document + if (GETPOST('model', 'alpha')) + { + $object->setDocModel($user, GETPOST('model', 'alpha')); + } - // Special case to force bank account - //if (property_exists($object, 'fk_bank')) - //{ - if (GETPOST('fk_bank', 'int')) { - // this field may come from an external module - $object->fk_bank = GETPOST('fk_bank', 'int'); - } elseif (!empty($object->fk_account)) { - $object->fk_bank = $object->fk_account; - } - //} + // Special case to force bank account + //if (property_exists($object, 'fk_bank')) + //{ + if (GETPOST('fk_bank', 'int')) { + // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank', 'int'); + } elseif (!empty($object->fk_account)) { + $object->fk_bank = $object->fk_account; + } + //} - $outputlangs = $langs; - $newlang = ''; + $outputlangs = $langs; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty - if (!empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + // To be sure vars is defined + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; - $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } else { - if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders" - { - setEventMessages($langs->trans("FileGenerated"), null); + $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } else { + if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders" + { + setEventMessages($langs->trans("FileGenerated"), null); - $urltoredirect = $_SERVER['REQUEST_URI']; - $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); - $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop + $urltoredirect = $_SERVER['REQUEST_URI']; + $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); + $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop - header('Location: '.$urltoredirect.'#builddoc'); - exit; - } - } - } + header('Location: '.$urltoredirect.'#builddoc'); + exit; + } + } + } } // Delete file in doc form if ($action == 'remove_file' && $permissiontoadd) { if (!empty($upload_dir)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (empty($object->id) || !$object->id > 0) - { - // Reload to get all modified line records and be ready for hooks - $ret = $object->fetch($id); - $ret = $object->fetch_thirdparty(); - } + if (empty($object->id) || !$object->id > 0) + { + // Reload to get all modified line records and be ready for hooks + $ret = $object->fetch($id); + $ret = $object->fetch_thirdparty(); + } - $langs->load("other"); - $filetodelete = GETPOST('file', 'alpha'); - $file = $upload_dir.'/'.$filetodelete; - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); + $langs->load("other"); + $filetodelete = GETPOST('file', 'alpha'); + $file = $upload_dir.'/'.$filetodelete; + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); - // Make a redirect to avoid to keep the remove_file into the url that create side effects - $urltoredirect = $_SERVER['REQUEST_URI']; - $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); - $urltoredirect = preg_replace('/action=remove_file&?/', '', $urltoredirect); + // Make a redirect to avoid to keep the remove_file into the url that create side effects + $urltoredirect = $_SERVER['REQUEST_URI']; + $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); + $urltoredirect = preg_replace('/action=remove_file&?/', '', $urltoredirect); - header('Location: '.$urltoredirect); - exit; + header('Location: '.$urltoredirect); + exit; } else { setEventMessages('BugFoundVarUploaddirnotDefined', null, 'errors'); } diff --git a/htdocs/core/actions_changeselectedfields.inc.php b/htdocs/core/actions_changeselectedfields.inc.php index f4e7f01d234..4daf53891cf 100644 --- a/htdocs/core/actions_changeselectedfields.inc.php +++ b/htdocs/core/actions_changeselectedfields.inc.php @@ -30,17 +30,17 @@ // Save selection if (GETPOST('formfilteraction', 'alphanohtml') == 'listafterchangingselectedfields') { - $tabparam = array(); + $tabparam = array(); - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); - else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; + if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); + else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $result = dol_set_user_param($db, $conf, $user, $tabparam); + $result = dol_set_user_param($db, $conf, $user, $tabparam); - //$action='list'; - //var_dump($tabparam);exit; + //$action='list'; + //var_dump($tabparam);exit; } diff --git a/htdocs/core/actions_comments.inc.php b/htdocs/core/actions_comments.inc.php index 079f207b4a4..f590adee197 100644 --- a/htdocs/core/actions_comments.inc.php +++ b/htdocs/core/actions_comments.inc.php @@ -57,19 +57,19 @@ if ($action == 'addcomment') } if ($action === 'updatecomment') { - if ($comment->fetch($idcomment) >= 0) - { - $comment->description = GETPOST('comment_description', 'restricthtml'); - if ($comment->update($user) > 0) - { - setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); - header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1#comment' : '')); - exit; - } else { - setEventMessages($comment->error, $comment->errors, 'errors'); - $action = ''; - } - } + if ($comment->fetch($idcomment) >= 0) + { + $comment->description = GETPOST('comment_description', 'restricthtml'); + if ($comment->update($user) > 0) + { + setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); + header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1#comment' : '')); + exit; + } else { + setEventMessages($comment->error, $comment->errors, 'errors'); + $action = ''; + } + } } if ($action == 'deletecomment') { diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 46a6a31c202..c8c4f4db5d0 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -42,7 +42,7 @@ if ($action == 'add') { if ($_POST["button"] != $langs->trans("Cancel")) { - // Check values + // Check values if (!$type) { $error++; @@ -52,156 +52,156 @@ if ($action == 'add') } if ($type == 'varchar' && $extrasize <= 0) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); - $action = 'edit'; + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $action = 'edit'; + } + if ($type == 'varchar' && $extrasize > $maxsizestring) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $action = 'create'; + } + if ($type == 'int' && $extrasize > $maxsizeint) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $action = 'create'; + } + if ($type == 'select' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); + $action = 'create'; + } + if ($type == 'sellist' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); + $action = 'create'; + } + if ($type == 'checkbox' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); + $action = 'create'; + } + if ($type == 'link' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForLinkType"); + $action = 'create'; + } + if ($type == 'radio' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); + $action = 'create'; + } + if ((($type == 'radio') || ($type == 'checkbox')) && $param) + { + // Construct array for parameter (value of select list) + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + foreach ($parameters_array as $param_ligne) + { + if (!empty($param_ligne)) { + if (preg_match_all('/,/', $param_ligne, $matches)) + { + if (count($matches[0]) > 1) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'create'; + } + } else { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'create'; + } + } + } } - if ($type == 'varchar' && $extrasize > $maxsizestring) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); - $action = 'create'; - } - if ($type == 'int' && $extrasize > $maxsizeint) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); - $action = 'create'; - } - if ($type == 'select' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectType"); - $action = 'create'; - } - if ($type == 'sellist' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); - $action = 'create'; - } - if ($type == 'checkbox' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); - $action = 'create'; - } - if ($type == 'link' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForLinkType"); - $action = 'create'; - } - if ($type == 'radio' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForRadioType"); - $action = 'create'; - } - if ((($type == 'radio') || ($type == 'checkbox')) && $param) - { - // Construct array for parameter (value of select list) - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - foreach ($parameters_array as $param_ligne) - { - if (!empty($param_ligne)) { - if (preg_match_all('/,/', $param_ligne, $matches)) - { - if (count($matches[0]) > 1) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'create'; - } - } else { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'create'; - } - } - } - } - if (!$error) - { - // attrname must be alphabetical and lower case only - if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) - { - // Construct array for parameter (value of select list) - $default_value = GETPOST('default_value', 'alpha'); - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - //In sellist we have only one line and it can have come to do SQL expression - if ($type == 'sellist') { - foreach ($parameters_array as $param_ligne) - { - $params['options'] = array($parameters=>null); - } - } else { - //Esle it's separated key/value and coma list - foreach ($parameters_array as $param_ligne) - { - list($key, $value) = explode(',', $param_ligne); - $params['options'][$key] = $value; - } - } + if (!$error) + { + // attrname must be alphabetical and lower case only + if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) + { + // Construct array for parameter (value of select list) + $default_value = GETPOST('default_value', 'alpha'); + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + //In sellist we have only one line and it can have come to do SQL expression + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) + { + $params['options'] = array($parameters=>null); + } + } else { + //Esle it's separated key/value and coma list + foreach ($parameters_array as $param_ligne) + { + list($key, $value) = explode(',', $param_ligne); + $params['options'][$key] = $value; + } + } - // Visibility: -1=not visible by default in list, 1=visible, 0=hidden - $visibility = GETPOST('list', 'alpha'); + // Visibility: -1=not visible by default in list, 1=visible, 0=hidden + $visibility = GETPOST('list', 'alpha'); if ($type == 'separate') $visibility = 3; - $result = $extrafields->addExtraField( - GETPOST('attrname', 'alpha'), - GETPOST('label', 'alpha'), - $type, - GETPOST('pos', 'int'), - $extrasize, - $elementtype, - (GETPOST('unique', 'alpha') ? 1 : 0), - (GETPOST('required', 'alpha') ? 1 : 0), - $default_value, - $params, - (GETPOST('alwayseditable', 'alpha') ? 1 : 0), - (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), - $visibility, + $result = $extrafields->addExtraField( + GETPOST('attrname', 'alpha'), + GETPOST('label', 'alpha'), + $type, + GETPOST('pos', 'int'), + $extrasize, + $elementtype, + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), + $default_value, + $params, + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), + $visibility, GETPOST('help', 'alpha'), - GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), - GETPOST('langfile', 'alpha'), - 1, - (GETPOST('totalizable', 'alpha') ? 1 : 0), - GETPOST('printable', 'alpha') - ); - if ($result > 0) - { - setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - $error++; - $mesg = $extrafields->error; - setEventMessages($mesg, null, 'errors'); - } - } else { - $error++; - $langs->load("errors"); - $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); - setEventMessages($mesg, null, 'errors'); - $action = 'create'; - } - } else { - setEventMessages($mesg, null, 'errors'); - } + GETPOST('computed_value', 'alpha'), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), + GETPOST('langfile', 'alpha'), + 1, + (GETPOST('totalizable', 'alpha') ? 1 : 0), + GETPOST('printable', 'alpha') + ); + if ($result > 0) + { + setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + $error++; + $mesg = $extrafields->error; + setEventMessages($mesg, null, 'errors'); + } + } else { + $error++; + $langs->load("errors"); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); + setEventMessages($mesg, null, 'errors'); + $action = 'create'; + } + } else { + setEventMessages($mesg, null, 'errors'); + } } } @@ -210,7 +210,7 @@ if ($action == 'update') { if ($_POST["button"] != $langs->trans("Cancel")) { - // Check values + // Check values if (!$type) { $error++; @@ -220,147 +220,147 @@ if ($action == 'update') } if ($type == 'varchar' && $extrasize <= 0) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); - $action = 'edit'; + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $action = 'edit'; } if ($type == 'varchar' && $extrasize > $maxsizestring) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); - $action = 'edit'; - } - if ($type == 'int' && $extrasize > $maxsizeint) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); - $action = 'edit'; - } - if ($type == 'select' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectType"); - $action = 'edit'; - } - if ($type == 'sellist' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); - $action = 'edit'; - } - if ($type == 'checkbox' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); - $action = 'edit'; - } - if ($type == 'radio' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForRadioType"); - $action = 'edit'; - } - if ((($type == 'radio') || ($type == 'checkbox')) && $param) - { - // Construct array for parameter (value of select list) - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - foreach ($parameters_array as $param_ligne) - { - if (!empty($param_ligne)) { - if (preg_match_all('/,/', $param_ligne, $matches)) - { - if (count($matches[0]) > 1) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'edit'; - } - } else { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'edit'; - } - } - } - } + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $action = 'edit'; + } + if ($type == 'int' && $extrasize > $maxsizeint) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $action = 'edit'; + } + if ($type == 'select' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); + $action = 'edit'; + } + if ($type == 'sellist' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); + $action = 'edit'; + } + if ($type == 'checkbox' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); + $action = 'edit'; + } + if ($type == 'radio' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); + $action = 'edit'; + } + if ((($type == 'radio') || ($type == 'checkbox')) && $param) + { + // Construct array for parameter (value of select list) + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + foreach ($parameters_array as $param_ligne) + { + if (!empty($param_ligne)) { + if (preg_match_all('/,/', $param_ligne, $matches)) + { + if (count($matches[0]) > 1) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'edit'; + } + } else { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'edit'; + } + } + } + } - if (!$error) - { - if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) - { - $pos = GETPOST('pos', 'int'); - // Construct array for parameter (value of select list) - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - //In sellist we have only one line and it can have come to do SQL expression - if ($type == 'sellist') { - foreach ($parameters_array as $param_ligne) - { - $params['options'] = array($parameters=>null); - } - } else { - //Esle it's separated key/value and coma list - foreach ($parameters_array as $param_ligne) - { - list($key, $value) = explode(',', $param_ligne); - $params['options'][$key] = $value; - } - } + if (!$error) + { + if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) + { + $pos = GETPOST('pos', 'int'); + // Construct array for parameter (value of select list) + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + //In sellist we have only one line and it can have come to do SQL expression + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) + { + $params['options'] = array($parameters=>null); + } + } else { + //Esle it's separated key/value and coma list + foreach ($parameters_array as $param_ligne) + { + list($key, $value) = explode(',', $param_ligne); + $params['options'][$key] = $value; + } + } - // Visibility: -1=not visible by default in list, 1=visible, 0=hidden - $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility = 3; + // Visibility: -1=not visible by default in list, 1=visible, 0=hidden + $visibility = GETPOST('list', 'alpha'); + if ($type == 'separate') $visibility = 3; - $result = $extrafields->update( - GETPOST('attrname', 'alpha'), - GETPOST('label', 'alpha'), - $type, - $extrasize, - $elementtype, - (GETPOST('unique', 'alpha') ? 1 : 0), - (GETPOST('required', 'alpha') ? 1 : 0), - $pos, - $params, - (GETPOST('alwayseditable', 'alpha') ? 1 : 0), - (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), - $visibility, + $result = $extrafields->update( + GETPOST('attrname', 'alpha'), + GETPOST('label', 'alpha'), + $type, + $extrasize, + $elementtype, + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), + $pos, + $params, + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), + $visibility, GETPOST('help', 'alpha'), - GETPOST('default_value', 'alpha'), - GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), - GETPOST('langfile'), - 1, - (GETPOST('totalizable', 'alpha') ? 1 : 0), - GETPOST('printable', 'alpha') - ); - if ($result > 0) - { - setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - $error++; - $mesg = $extrafields->error; - setEventMessages($mesg, null, 'errors'); - } - } else { - $error++; - $langs->load("errors"); - $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); - setEventMessages($mesg, null, 'errors'); - } - } else { - setEventMessages($mesg, null, 'errors'); - } + GETPOST('default_value', 'alpha'), + GETPOST('computed_value', 'alpha'), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), + GETPOST('langfile'), + 1, + (GETPOST('totalizable', 'alpha') ? 1 : 0), + GETPOST('printable', 'alpha') + ); + if ($result > 0) + { + setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + $error++; + $mesg = $extrafields->error; + setEventMessages($mesg, null, 'errors'); + } + } else { + $error++; + $langs->load("errors"); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); + setEventMessages($mesg, null, 'errors'); + } + } else { + setEventMessages($mesg, null, 'errors'); + } } } @@ -369,14 +369,14 @@ if ($action == 'delete') { if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) { - $result = $extrafields->delete($_GET["attrname"], $elementtype); - if ($result >= 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else $mesg = $extrafields->error; + $result = $extrafields->delete($_GET["attrname"], $elementtype); + if ($result >= 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else $mesg = $extrafields->error; } else { - $error++; + $error++; $langs->load("errors"); $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); } diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index d4cdbb66a21..c881b335f18 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -34,20 +34,20 @@ if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask' { $ret = $object->fetch($id, $ref); if ($ret > 0) - { - $object->fetch_thirdparty(); - $id = $object->id; - } else { - if (empty($object->error) && !count($object->errors)) - { - if ($ret < 0) // if $ret == 0, it means not found. - { - setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors'); - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - $action = ''; - } + { + $object->fetch_thirdparty(); + $id = $object->id; + } else { + if (empty($object->error) && !count($object->errors)) + { + if ($ret < 0) // if $ret == 0, it means not found. + { + setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + $action = ''; + } } } diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 75633c75585..b0671bbf555 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -29,7 +29,7 @@ // Submit file/link if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) { - if (!empty($_FILES)) + if (!empty($_FILES)) { if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; else $userfiles = array($_FILES['userfile']['tmp_name']); @@ -65,112 +65,112 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) } } elseif (GETPOST('linkit', 'restricthtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) { - $link = GETPOST('link', 'alpha'); - if ($link) - { - if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') { - $link = 'http://'.$link; - } - dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link, '', 0); - } + $link = GETPOST('link', 'alpha'); + if ($link) + { + if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') { + $link = 'http://'.$link; + } + dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link, '', 0); + } } // Delete file/link if ($action == 'confirm_deletefile' && $confirm == 'yes') { - $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - if (GETPOST('section', 'alpha')) { - // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir - $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; - } else // For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. + $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + if (GETPOST('section', 'alpha')) { + // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir + $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; + } else // For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. { - $urlfile = basename($urlfile); - $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; + $urlfile = basename($urlfile); + $file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile; if (!empty($upload_dirold)) $fileold = $upload_dirold."/".$urlfile; } - $linkid = GETPOST('linkid', 'int'); + $linkid = GETPOST('linkid', 'int'); - if ($urlfile) { - // delete of a file - $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine - $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image) + if ($urlfile) { + // delete of a file + $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine + $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image) - $ret = dol_delete_file($file, 0, 0, 0, (is_object($object) ? $object : null)); - if (!empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path + $ret = dol_delete_file($file, 0, 0, 0, (is_object($object) ? $object : null)); + if (!empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path - // Si elle existe, on efface la vignette - if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) - { - $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) - { - dol_delete_file($dirthumb.$photo_vignette); - } + // If it exists, remove thumb. + $regs = array(); + if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) + { + $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) + { + dol_delete_file($dirthumb.$photo_vignette); + } - $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) - { - dol_delete_file($dirthumb.$photo_vignette); - } - } + $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) + { + dol_delete_file($dirthumb.$photo_vignette); + } + } - if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); - } - } elseif ($linkid) // delete of external link - { - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $link = new Link($db); - $link->fetch($linkid); - $res = $link->delete($user); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); + } + } elseif ($linkid) { // delete of external link + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $link = new Link($db); + $link->fetch($linkid); + $res = $link->delete($user); - $langs->load('link'); - if ($res > 0) { - setEventMessages($langs->trans("LinkRemoved", $link->label), null, 'mesgs'); - } else { - if (count($link->errors)) { - setEventMessages('', $link->errors, 'errors'); - } else { - setEventMessages($langs->trans("ErrorFailedToDeleteLink", $link->label), null, 'errors'); - } - } - } + $langs->load('link'); + if ($res > 0) { + setEventMessages($langs->trans("LinkRemoved", $link->label), null, 'mesgs'); + } else { + if (count($link->errors)) { + setEventMessages('', $link->errors, 'errors'); + } else { + setEventMessages($langs->trans("ErrorFailedToDeleteLink", $link->label), null, 'errors'); + } + } + } - if (is_object($object) && $object->id > 0) { - if ($backtopage) { - header('Location: '.$backtopage); - exit; - } else { - $tmpurl = $_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha') ? '§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')) : '').(!empty($withproject) ? '&withproject=1' : ''); - header('Location: '.$tmpurl); - exit; - } - } + if (is_object($object) && $object->id > 0) { + if ($backtopage) { + header('Location: '.$backtopage); + exit; + } else { + $tmpurl = $_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha') ? '§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')) : '').(!empty($withproject) ? '&withproject=1' : ''); + header('Location: '.$tmpurl); + exit; + } + } } elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha')) { - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $langs->load('link'); - $link = new Link($db); - $f = $link->fetch(GETPOST('linkid', 'int')); - if ($f) - { - $link->url = GETPOST('link', 'alpha'); - if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://') - { - $link->url = 'http://'.$link->url; - } - $link->label = GETPOST('label', 'alphanohtml'); - $res = $link->update($user); - if (!$res) - { - setEventMessages($langs->trans("ErrorFailedToUpdateLink", $link->label), null, 'mesgs'); - } - } else { - //error fetching - } + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $langs->load('link'); + $link = new Link($db); + $f = $link->fetch(GETPOST('linkid', 'int')); + if ($f) + { + $link->url = GETPOST('link', 'alpha'); + if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://') + { + $link->url = 'http://'.$link->url; + } + $link->label = GETPOST('label', 'alphanohtml'); + $res = $link->update($user); + if (!$res) + { + setEventMessages($langs->trans("ErrorFailedToUpdateLink", $link->label), null, 'mesgs'); + } + } else { + //error fetching + } } elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha')) { // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. @@ -179,97 +179,101 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $filenamefrom = dol_sanitizeFileName(GETPOST('renamefilefrom', 'alpha'), '_', 0); // Do not remove accents $filenameto = dol_sanitizeFileName(GETPOST('renamefileto', 'alpha'), '_', 0); // Do not remove accents - if ($filenamefrom != $filenameto) - { - // Security: - // Disallow file with some extensions. We rename them. - // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. - if (isAFileWithExecutableContent($filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) - { - // $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too. - $publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity]; - if (! preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash.='/'; + // We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because + // this function is also applied when we upload and when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). + $filenameto = dol_string_nohtmltag($filenameto); - if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) { // We never add .noexe on files into media directory - $filenameto .= '.noexe'; - } - } + if ($filenamefrom != $filenameto) + { + // Security: + // Disallow file with some extensions. We rename them. + // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. + if (isAFileWithExecutableContent($filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) + { + // $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too. + $publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity]; + if (!preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash .= '/'; - if ($filenamefrom && $filenameto) - { - $srcpath = $upload_dir.'/'.$filenamefrom; - $destpath = $upload_dir.'/'.$filenameto; + if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) { // We never add .noexe on files into media directory + $filenameto .= '.noexe'; + } + } - $reshook = $hookmanager->initHooks(array('actionlinkedfiles')); - $parameters = array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir); - $reshook = $hookmanager->executeHooks('renameUploadedFile', $parameters, $object); + if ($filenamefrom && $filenameto) + { + $srcpath = $upload_dir.'/'.$filenamefrom; + $destpath = $upload_dir.'/'.$filenameto; - if (empty($reshook)) - { - if (preg_match('/^\./', $filenameto)) { - $langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now. - setEventMessages($langs->trans("ErrorFilenameCantStartWithDot", $filenameto), null, 'errors'); - } elseif (!file_exists($destpath)) { - $result = dol_move($srcpath, $destpath); - if ($result) - { - // Define if we have to generate thumbs or not - $generatethumbs = 1; - // When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here) - // When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case) - // but when we rename from a tab "Documents", we must regenerate thumbs - if (GETPOST('modulepart') == 'medias') $generatethumbs = 0; + $reshook = $hookmanager->initHooks(array('actionlinkedfiles')); + $parameters = array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir); + $reshook = $hookmanager->executeHooks('renameUploadedFile', $parameters, $object); - if ($generatethumbs) - { - if ($object->id) - { - $object->addThumbs($destpath); - } + if (empty($reshook)) + { + if (preg_match('/^\./', $filenameto)) { + $langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorFilenameCantStartWithDot", $filenameto), null, 'errors'); + } elseif (!file_exists($destpath)) { + $result = dol_move($srcpath, $destpath); + if ($result) + { + // Define if we have to generate thumbs or not + $generatethumbs = 1; + // When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here) + // When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case) + // but when we rename from a tab "Documents", we must regenerate thumbs + if (GETPOST('modulepart') == 'medias') $generatethumbs = 0; - // TODO Add revert function of addThumbs to remove thumbs with old name - //$object->delThumbs($srcpath); - } + if ($generatethumbs) + { + if ($object->id) + { + $object->addThumbs($destpath); + } - setEventMessages($langs->trans("FileRenamed"), null); - } else { - $langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now. - setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors'); - } - } else { - $langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now. - setEventMessages($langs->trans("ErrorDestinationAlreadyExists", $filenameto), null, 'errors'); - } - } - } - } - } + // TODO Add revert function of addThumbs to remove thumbs with old name + //$object->delThumbs($srcpath); + } - // Update properties in ECM table - if (GETPOST('ecmfileid', 'int') > 0) - { - $shareenabled = GETPOST('shareenabled', 'alpha'); + setEventMessages($langs->trans("FileRenamed"), null); + } else { + $langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors'); + } + } else { + $langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorDestinationAlreadyExists", $filenameto), null, 'errors'); + } + } + } + } + } - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile = new EcmFiles($db); - $result = $ecmfile->fetch(GETPOST('ecmfileid', 'int')); - if ($result > 0) - { - if ($shareenabled) - { - if (empty($ecmfile->share)) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $ecmfile->share = getRandomPassword(true); - } - } else { - $ecmfile->share = ''; - } - $result = $ecmfile->update($user); - if ($result < 0) - { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } - } - } + // Update properties in ECM table + if (GETPOST('ecmfileid', 'int') > 0) + { + $shareenabled = GETPOST('shareenabled', 'alpha'); + + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile = new EcmFiles($db); + $result = $ecmfile->fetch(GETPOST('ecmfileid', 'int')); + if ($result > 0) + { + if ($shareenabled) + { + if (empty($ecmfile->share)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $ecmfile->share = getRandomPassword(true); + } + } else { + $ecmfile->share = ''; + } + $result = $ecmfile->update($user); + if ($result < 0) + { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } + } } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c2f0a314445..356eb36a04b 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -114,11 +114,11 @@ if (!$error && $massaction == 'confirm_presend') } } - $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; - $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp; - } - } - } + $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; + $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp; + } + } + } // Check mandatory parameters if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) @@ -261,9 +261,9 @@ if (!$error && $massaction == 'confirm_presend') $sendto = $fuser->email; } elseif ($objectobj->element == 'holiday') { - $fuser = new User($db); - $fuser->fetch($objectobj->fk_user); - $sendto = $fuser->email; + $fuser = new User($db); + $fuser->fetch($objectobj->fk_user); + $sendto = $fuser->email; } elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid])) { $emails_to_sends = array(); @@ -396,7 +396,7 @@ if (!$error && $massaction == 'confirm_presend') $looparray = $listofqualifiedobj; foreach ($looparray as $key => $objecttmp) { - $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object + $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object } } else { $objectforloop = new $objectclass($db); @@ -404,9 +404,9 @@ if (!$error && $massaction == 'confirm_presend') $looparray[0] = $objectforloop; } //var_dump($looparray);exit; - dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient); - //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 + dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient); + //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)) @@ -430,10 +430,10 @@ if (!$error && $massaction == 'confirm_presend') complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); - $subjectreplaced = make_substitutions($subject, $substitutionarray); - $messagereplaced = make_substitutions($message, $substitutionarray); + $subjectreplaced = make_substitutions($subject, $substitutionarray); + $messagereplaced = make_substitutions($message, $substitutionarray); - $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); + $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); if ($oneemailperrecipient) { // if "one email per recipient" is check we must collate $attachedfiles by thirdparty @@ -461,20 +461,20 @@ if (!$error && $massaction == 'confirm_presend') // Define the trackid when emails sent from the mass action if ($oneemailperrecipient) { - $trackid = 'thi'.$thirdparty->id; - if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; - if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; + $trackid = 'thi'.$thirdparty->id; + if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; + if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; } else { - $trackid = strtolower(get_class($objecttmp)); - if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; - if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; - if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; - if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; - if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; - if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; - if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; + $trackid = strtolower(get_class($objecttmp)); + if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; + if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; + if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; + if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; + if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; + if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; + if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; - $trackid .= $objecttmp->id; + $trackid .= $objecttmp->id; } //var_dump($filepath); //var_dump($trackid);exit; @@ -483,8 +483,8 @@ if (!$error && $massaction == 'confirm_presend') if (empty($sendcontext)) $sendcontext = 'standard'; // Send mail (substitutionarray must be done just before this) - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext); + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext); if ($mailfile->error) { $resaction .= '
    '.$mailfile->error.'
    '; @@ -497,11 +497,11 @@ if (!$error && $massaction == 'confirm_presend') $error = 0; // Insert logs into agenda - foreach ($listofqualifiedobj as $objid2 => $objectobj2) + foreach ($listofqualifiedobj as $objid2 => $objectobj2) { - if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level + if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level - dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2)); + dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2)); /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; if ($objectclass == 'Commande') $actiontypecode='AC_COM'; @@ -514,18 +514,18 @@ if (!$error && $massaction == 'confirm_presend') if ($message) { if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg = dol_concatdesc($actionmsg, $messagereplaced); + $actionmsg = dol_concatdesc($actionmsg, $messagereplaced); } $actionmsg2 = ''; - // Initialisation donnees - $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend); - $objectobj2->actionmsg = $actionmsg; // Long text - $objectobj2->actionmsg2 = $actionmsg2; // Short text - $objectobj2->fk_element = $objid2; - $objectobj2->elementtype = $objectobj2->element; + // Initialisation donnees + $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend); + $objectobj2->actionmsg = $actionmsg; // Long text + $objectobj2->actionmsg2 = $actionmsg2; // Short text + $objectobj2->fk_element = $objid2; + $objectobj2->elementtype = $objectobj2->element; $triggername = strtoupper(get_class($objectobj2)).'_SENTBYMAIL'; if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYMAIL'; @@ -619,13 +619,13 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; $objecttmp->fk_project = $cmd->fk_project; - $objecttmp->multicurrency_code = $cmd->multicurrency_code; - if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; + $objecttmp->multicurrency_code = $cmd->multicurrency_code; + if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; - $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($datefacture)) + $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + if (empty($datefacture)) { - $datefacture = dol_now(); + $datefacture = dol_now(); } $objecttmp->date = $datefacture; @@ -676,7 +676,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders // If we build one invoice for several order, we must put the invoice of order on the line if (!empty($createbills_onebythird)) { - $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); + $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); } if ($lines[$i]->subprice < 0) @@ -807,7 +807,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders // Call action to build doc $savobject = $object; - $object = $objecttmp; + $object = $objecttmp; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; $object = $savobject; } @@ -818,7 +818,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders if (!$error) { $db->commit(); - setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); + setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); // Make a redirect to avoid to bill twice if we make a refresh or back $param = ''; @@ -1063,7 +1063,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); } else { - setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); + setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); } } } @@ -1143,34 +1143,34 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) // Closed records if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissiontoclose) { - $db->begin(); + $db->begin(); - $objecttmp = new $objectclass($db); - $nbok = 0; - foreach ($toselect as $toselectid) { - $result = $objecttmp->fetch($toselectid); - if ($result > 0) { - $result = $objecttmp->cloture($user, 3); - if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } else $nbok++; - } else { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } - } + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) { + $result = $objecttmp->cloture($user, 3); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } - if (!$error) { - if ($nbok > 1) - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } + if (!$error) { + if ($nbok > 1) + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + } } //var_dump($_POST);var_dump($massaction);exit; @@ -1213,9 +1213,9 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; } else $nbok++; } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); @@ -1239,56 +1239,56 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' // @todo : propose model selection if (!$error && $massaction == 'generate_doc' && $permissiontoread) { - $db->begin(); + $db->begin(); - $objecttmp = new $objectclass($db); - $nbok = 0; - foreach ($toselect as $toselectid) - { - $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { - $outputlangs = $langs; - $newlang = ''; + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) + { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) + { + $outputlangs = $langs; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty - if (!empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + // To be sure vars is defined + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; - $result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) - { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } else $nbok++; - } else { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } - } + if ($result <= 0) + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } + if (!$error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + } } $parameters['toselect'] = $toselect; diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index e88fc937e38..3838e6963ab 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -33,18 +33,24 @@ if ($action == 'print_file' && $user->rights->printing->read) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; $objectprint = new PrintingDriver($db); $list = $objectprint->listDrivers($db, 10); + $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); if (!empty($list)) { $errorprint = 0; $printerfound = 0; foreach ($list as $driver) { - require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; - $langs->load($driver); + foreach ($dirmodels as $dir) { + if (file_exists(dol_buildpath($dir, 0).$driver.'.modules.php')) { + $classfile = dol_buildpath($dir, 0).$driver.'.modules.php'; + break; + } + } + require_once $classfile; $classname = 'printing_'.$driver; $printer = new $classname($db); + $langs->load($printer::LANGFILE); //print '
    '.print_r($printer, true).'
    '; - if (!empty($conf->global->{$printer->active})) - { + if (!empty($conf->global->{$printer->active})) { $printerfound++; $subdir = ''; diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 5be25002079..0be919de0dd 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -321,7 +321,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST if ($action == 'send' || $action == 'relance') { - $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1); + $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('at').' '.CMailFile::getValidAddress($sendto, 4, 0, 1); if ($message) { $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); @@ -473,12 +473,16 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST } else { $langs->load("other"); $mesg = '
    '; - if ($mailfile->error) - { + if ($mailfile->error) { $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto)); $mesg .= '
    '.$mailfile->error; } else { - $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto)); + if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { + $mesg .= '
    Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } else { + $mesg .= '
    Unkown Error, please refers to your administrator'; + } } $mesg .= '
    '; diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 05be4a31d18..24220f79f8c 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -38,11 +38,11 @@ if ($action == 'update' && is_array($arrayofparameters)) if (GETPOSTISSET($key)) { $result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result < 0) - { - $ok = false; - break; - } + if ($result < 0) + { + $ok = false; + break; + } } } @@ -59,58 +59,58 @@ if ($action == 'update' && is_array($arrayofparameters)) // Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) if ($action == 'setModuleOptions') { - $db->begin(); + $db->begin(); - // Process common param fields - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { - $reg = array(); - if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... - { - $param = GETPOST("param".$reg[1], 'alpha'); - $value = GETPOST("value".$reg[1], 'alpha'); - if ($param) - { - $res = dolibarr_set_const($db, $param, $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; - } - } - } - } + // Process common param fields + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + $reg = array(); + if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... + { + $param = GETPOST("param".$reg[1], 'alpha'); + $value = GETPOST("value".$reg[1], 'alpha'); + if ($param) + { + $res = dolibarr_set_const($db, $param, $value, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + } + } + } + } - // Process upload fields - if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); - $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir))); - foreach ($listofdir as $key=>$tmpdir) - { - $tmpdir = trim($tmpdir); - $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (!$tmpdir) { - unset($listofdir[$key]); continue; - } - if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); - else { - $upload_dir = $tmpdir; - } - } - if ($upload_dir) - { - $result = dol_add_file_process($upload_dir, 0, 1, 'uploadfile', ''); - if ($result <= 0) $error++; - } - } + // Process upload fields + if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir))); + foreach ($listofdir as $key=>$tmpdir) + { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { + unset($listofdir[$key]); continue; + } + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + else { + $upload_dir = $tmpdir; + } + } + if ($upload_dir) + { + $result = dol_add_file_process($upload_dir, 1, 1, 'uploadfile', ''); + if ($result <= 0) $error++; + } + } - if (!$error) - { - $db->commit(); - if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); - } + if (!$error) + { + $db->commit(); + if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + } } diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index 61db9b9fc55..b9dd4194268 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -33,7 +33,7 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done - $result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'restricthtml'), ENT_QUOTES, 'UTF-8', 1), '_public'); + $result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'restricthtml'), ENT_QUOTES | ENT_HTML5, 'UTF-8', 1), '_public'); if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) @@ -63,6 +63,6 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', // Set public note if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done - $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES), '_private'); + $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES | ENT_HTML5), '_private'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 620643da8f2..e6fd1e000cb 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -83,10 +83,10 @@ if ($modulepart == 'ecm') // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpathselecteddir)) { - dol_syslog("Refused to deliver file ".$original_file); - // Do no show plain path in shown error message - dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file"))); - exit; + dol_syslog("Refused to deliver file ".$original_file); + // Do no show plain path in shown error message + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file"))); + exit; } // Check permissions @@ -120,11 +120,11 @@ if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); $current_ecmdir_id = -1; foreach ($sqltree as $keycursor => $val) { - //print $val['fullrelativename']." == ".$selecteddir; - if ($val['fullrelativename'] == $selecteddir) - { - $current_ecmdir_id = $keycursor; - } + //print $val['fullrelativename']." == ".$selecteddir; + if ($val['fullrelativename'] == $selecteddir) + { + $current_ecmdir_id = $keycursor; + } } if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php index 2b03eb858e1..cc27ca11844 100644 --- a/htdocs/core/ajax/box.php +++ b/htdocs/core/ajax/box.php @@ -58,7 +58,7 @@ if ($boxid > 0 && $zone != '' && $userid > 0) $nbboxonright = substr_count($tmp[1], ','); print $nbboxonleft.'-'.$nbboxonright; if ($nbboxonleft > $nbboxonright) $boxorder = preg_replace('/B:/', 'B:'.$boxid.',', $boxorder); // Insert id of new box into list - else $boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list + else $boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list } // Registering the location of boxes after a move @@ -70,10 +70,10 @@ if ($boxorder && $zone != '' && $userid > 0) $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); if ($result > 0) { - $langs->load("boxes"); - if (!GETPOST('closing')) - { - setEventMessages($langs->trans("BoxAdded"), null); - } + $langs->load("boxes"); + if (!GETPOST('closing')) + { + setEventMessages($langs->trans("BoxAdded"), null); + } } } diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index 01cb85008bd..a6134b05bdc 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -18,7 +18,7 @@ */ if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); @@ -47,7 +47,7 @@ if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); require '../../main.inc.php'; //$time = (int) GETPOST('time', 'int'); // Use the time parameter that is always increased by time_update, even if call is late -$time=dol_now(); +$time = dol_now(); $action = GETPOST('action', 'aZ09'); $listofreminderids = GETPOST('listofreminderids', 'aZ09'); @@ -105,7 +105,7 @@ $eventfound = array(); // This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate. if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto_check_events_not_before'] || GETPOST('forcechecknow', 'int')) { - /*$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined + /*$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined if (!empty($_SESSION['auto_check_events_not_before'])) { // We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer), @@ -124,51 +124,51 @@ if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto $_SESSION['auto_check_events_not_before'] = $time + $time_update; */ - // Force save of the session change we did. - // WARNING: Any change in sessions after that will not be saved ! - session_write_close(); + // Force save of the session change we did. + // WARNING: Any change in sessions after that will not be saved ! + session_write_close(); - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']); + dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.(empty($_SESSION['auto_check_events_not_before']) ? '' : $_SESSION['auto_check_events_not_before'])); - $sql = 'SELECT a.id as id_agenda, a.code, a.datep, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user as id_user_reminder'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - if (!empty($user->conf->MAIN_USER_WANT_ALL_EVENTS_NOTIFICATIONS)) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; - $sql .= ' WHERE a.code <> "AC_OTH_AUTO"'; - $sql .= ' AND ('; - $sql .= " (ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; - $sql .= ' )'; - } else { - $sql .= ' JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; - $sql .= " AND ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; - } - $sql .= $db->order('datep', 'ASC'); - $sql .= ' LIMIT 10'; // Avoid too many notification at once + $sql = 'SELECT a.id as id_agenda, a.code, a.datep, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user as id_user_reminder'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + if (!empty($user->conf->MAIN_USER_WANT_ALL_EVENTS_NOTIFICATIONS)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; + $sql .= ' WHERE a.code <> "AC_OTH_AUTO"'; + $sql .= ' AND ('; + $sql .= " (ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; + $sql .= ' )'; + } else { + $sql .= ' JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; + $sql .= " AND ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; + } + $sql .= $db->order('datep', 'ASC'); + $sql .= ' LIMIT 10'; // Avoid too many notification at once - $resql = $db->query($sql); - if ($resql) { - while ($obj = $db->fetch_object($resql)) - { - // Message must be formated and translated to be used with javascript directly - $event = array(); - $event['type'] = 'agenda'; - $event['id_reminder'] = $obj->id_reminder; - $event['id_agenda'] = $obj->id_agenda; - $event['id_user'] = $obj->id_user_reminder; - $event['code'] = $obj->code; - $event['label'] = $obj->label; - $event['location'] = $obj->location; - $event['reminder_date_formated'] = dol_print_date($db->jdate($obj->dateremind), 'standard'); - $event['event_date_start_formated'] = dol_print_date($db->jdate($obj->datep), 'standard'); + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) + { + // Message must be formated and translated to be used with javascript directly + $event = array(); + $event['type'] = 'agenda'; + $event['id_reminder'] = $obj->id_reminder; + $event['id_agenda'] = $obj->id_agenda; + $event['id_user'] = $obj->id_user_reminder; + $event['code'] = $obj->code; + $event['label'] = $obj->label; + $event['location'] = $obj->location; + $event['reminder_date_formated'] = dol_print_date($db->jdate($obj->dateremind), 'standard'); + $event['event_date_start_formated'] = dol_print_date($db->jdate($obj->datep), 'standard'); - $eventfound[$obj->id_agenda] = $event; - } - } else { - dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR); - } + $eventfound[$obj->id_agenda] = $event; + } + } else { + dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR); + } } print json_encode(array('pastreminders'=>$eventfound, 'nextreminder'=>'')); diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index 710759e10bb..a530bea092f 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -31,7 +31,7 @@ if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // T require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -$action = GETPOST('action', 'aZ09'); // set or del +$action = GETPOST('action', 'aZ09'); // set or del $name = GETPOST('name', 'alpha'); diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php index 6b476a8f59a..e56b8689e0d 100644 --- a/htdocs/core/ajax/contacts.php +++ b/htdocs/core/ajax/contacts.php @@ -27,7 +27,7 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../../main.inc.php'; -$id = GETPOST('id', 'int'); // id of thirdparty +$id = GETPOST('id', 'int'); // id of thirdparty $action = GETPOST('action', 'aZ09'); $htmlname = GETPOST('htmlname', 'alpha'); $showempty = GETPOST('showempty', 'int'); diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 87b3a903343..877379b54ad 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -26,21 +26,21 @@ if (!isset($usedbyinclude) || empty($usedbyinclude)) { - 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('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN', '1'); + 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('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN', '1'); - $res = @include '../../main.inc.php'; - if ($res == 'ERROR_NOT_LOGGED') - { - $langs->load("other"); - $arrayresult['jumptologin'] = array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>' '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); - print json_encode($arrayresult); - if (is_object($db)) $db->close(); - exit; - } + $res = @include '../../main.inc.php'; + if ($res == 'ERROR_NOT_LOGGED') + { + $langs->load("other"); + $arrayresult['jumptologin'] = array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>' '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); + print json_encode($arrayresult); + if (is_object($db)) $db->close(); + exit; + } } include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; @@ -82,7 +82,7 @@ if (!empty($conf->mrp->enabled) && $user->rights->mrp->read && empty($conf->glob if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) { - $arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_projectpub', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_project').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_project', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_project').' '.$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) { @@ -110,11 +110,11 @@ if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARC { $arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if ((! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) || ! empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { $arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if ((! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || ! empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } @@ -131,7 +131,7 @@ if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUST } // Vendor payments -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || ! empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $arrayresult['searchintovendorpayments'] = array( 'position'=>175, @@ -189,8 +189,8 @@ if (empty($reshook)) // This pushes a search entry to the top if (!empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) { - $key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE; - if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -1000; + $key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE; + if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -1000; } // Sort on position @@ -199,6 +199,6 @@ $arrayresult = dol_sort_array($arrayresult, 'position'); // Print output if called by ajax or do nothing (var $arrayresult will be used) if called by an include if (!isset($usedbyinclude) || empty($usedbyinclude)) { - print json_encode($arrayresult); - if (is_object($db)) $db->close(); + print json_encode($arrayresult); + if (is_object($db)) $db->close(); } diff --git a/htdocs/core/boxes/box_accountancy_last_manual_entries.php b/htdocs/core/boxes/box_accountancy_last_manual_entries.php index 76c3fa5eb47..cbd6a16b62e 100644 --- a/htdocs/core/boxes/box_accountancy_last_manual_entries.php +++ b/htdocs/core/boxes/box_accountancy_last_manual_entries.php @@ -32,77 +32,77 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_accountancy_last_manual_entries extends ModeleBoxes { - public $boxcode = "accountancy_last_manual_entries"; - public $boximg = "object_invoice"; - public $boxlabel = "BoxLastManualEntries"; - public $depends = array("accounting"); + public $boxcode = "accountancy_last_manual_entries"; + public $boximg = "object_invoice"; + public $boxlabel = "BoxLastManualEntries"; + public $depends = array("accounting"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->accounting->mouvements->lire); - } + $this->hidden = !($user->rights->accounting->mouvements->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - $bookkeepingstatic = new BookKeeping($this->db); + $bookkeepingstatic = new BookKeeping($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); - if ($user->rights->accounting->mouvements->lire) - { - $sql = "SELECT DISTINCT b.piece_num"; - $sql .= ", b.doc_date as date_movement"; - $sql .= ", b.label_operation"; - $sql .= ", b.montant as amount"; - $sql .= ", b.code_journal"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " WHERE b.fk_doc = 0"; - $sql .= " AND b.entity = ".$conf->entity; - $sql .= " ORDER BY b.piece_num DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->accounting->mouvements->lire) + { + $sql = "SELECT DISTINCT b.piece_num"; + $sql .= ", b.doc_date as date_movement"; + $sql .= ", b.label_operation"; + $sql .= ", b.montant as amount"; + $sql .= ", b.code_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql .= " WHERE b.fk_doc = 0"; + $sql .= " AND b.entity = ".$conf->entity; + $sql .= " ORDER BY b.piece_num DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_movement); + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_movement); $journal = $objp->code_journal; - $label = $objp->label_operation; + $label = $objp->label_operation; $amount = $objp->amount; $bookkeepingstatic->id = $objp->id; @@ -114,11 +114,11 @@ class box_accountancy_last_manual_entries extends ModeleBoxes 'asis' => 1, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + 'asis' => 1, + ); $this->info_box_contents[$line][] = array( 'td' => 'class="center"', @@ -132,34 +132,34 @@ class box_accountancy_last_manual_entries extends ModeleBoxes 'asis' => 1, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedManualEntries") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedManualEntries") + ); - $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") - ); - } - } + $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 @@ -169,8 +169,8 @@ class box_accountancy_last_manual_entries extends ModeleBoxes * @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); - } + 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_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index 639ce1ebc23..653f49d2bd9 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -32,57 +32,57 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_accountancy_suspense_account extends ModeleBoxes { - public $boxcode = "accountancy_suspense_account"; - public $boximg = "object_invoice"; - public $boxlabel = "BoxSuspenseAccount"; - public $depends = array("accounting"); + public $boxcode = "accountancy_suspense_account"; + public $boximg = "object_invoice"; + public $boxlabel = "BoxSuspenseAccount"; + public $depends = array("accounting"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->accounting->mouvements->lire); - } + $this->hidden = !($user->rights->accounting->mouvements->lire); + } - /** - * Load data for box to show them later - * - * @return void - */ - public function loadBox() - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @return void + */ + public function loadBox() + { + global $user, $langs, $conf; - include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - //$bookkeepingstatic = new BookKeeping($this->db); + //$bookkeepingstatic = new BookKeeping($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); - if ($user->rights->accounting->mouvements->lire) - { + if ($user->rights->accounting->mouvements->lire) + { $suspenseAccount = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; - if (!empty($suspenseAccount) && $suspenseAccount > 0) - { + if (!empty($suspenseAccount) && $suspenseAccount > 0) + { $sql = "SELECT COUNT(*) as nb_suspense_account"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; $sql .= " WHERE b.numero_compte = ".$suspenseAccount; @@ -112,13 +112,13 @@ class box_accountancy_suspense_account extends ModeleBoxes 'text' => ''.$langs->trans("SuspenseAccountNotDefined").'' ); } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover"', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' - ); - } - } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover"', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' + ); + } + } /** * Method to show box @@ -128,8 +128,8 @@ class box_accountancy_suspense_account extends ModeleBoxes * @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); - } + 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_actions.php b/htdocs/core/boxes/box_actions.php index a951402fd7b..0f3b65b651d 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_actions extends ModeleBoxes { - public $boxcode = "lastactions"; - public $boximg = "object_action"; - public $boxlabel = "BoxLastActions"; - public $depends = array("agenda"); + public $boxcode = "lastactions"; + public $boximg = "object_action"; + public $boxlabel = "BoxLastActions"; + public $depends = array("agenda"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,20 +54,22 @@ class box_actions extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - public function __construct($db, $param = '') + public function __construct($db, $param) { - global $user; + global $conf, $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->agenda->myactions->read); + $this->enabled = $conf->agenda->enabled; + + $this->hidden = !($user->rights->agenda->myactions->read); } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -75,25 +77,25 @@ class box_actions extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $societestatic = new Societe($this->db); - $actionstatic = new ActionComm($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + $societestatic = new Societe($this->db); + $actionstatic = new ActionComm($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastActionsToDo", $max)); - if ($user->rights->agenda->myactions->read) { + if ($user->rights->agenda->myactions->read) { $sql = "SELECT a.id, a.label, a.datep as dp, a.percent as percentage"; - $sql .= ", ta.code"; - $sql .= ", ta.libelle as type_label"; - $sql .= ", s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client"; + $sql .= ", ta.code"; + $sql .= ", ta.libelle as type_label"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql .= " WHERE a.fk_action = ta.id"; - $sql .= " AND a.entity = ".$conf->entity; + $sql .= " AND a.entity IN (".getEntity('actioncomm').")"; $sql .= " AND a.percent >= 0 AND a.percent < 100"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; @@ -101,82 +103,86 @@ class box_actions extends ModeleBoxes $sql .= " ORDER BY a.datec DESC"; $sql .= $this->db->plimit($max, 0); - dol_syslog("Box_actions::loadBox", LOG_DEBUG); + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) { + if ($result) { $now = dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; $num = $this->db->num_rows($result); + $line = 0; - while ($line < $num) { + while ($line < $num) { $late = ''; $objp = $this->db->fetch_object($result); $datelimite = $this->db->jdate($objp->dp); - $actionstatic->id = $objp->id; - $actionstatic->label = $objp->label; - $actionstatic->type_label = $objp->type_label; - $actionstatic->code = $objp->code; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->code_client = $objp->code_client; + $actionstatic->id = $objp->id; + $actionstatic->label = $objp->label; + $actionstatic->type_label = $objp->type_label; + $actionstatic->code = $objp->code; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->code_client = $objp->code_client; - if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) - $late = img_warning($langs->trans("Late")); + if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) + $late = img_warning($langs->trans("Late")); //($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label) $label = empty($objp->label) ? $objp->type_label : $objp->label; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $actionstatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][0] = array( + 'td' => '', + 'text' => $actionstatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) : ''), - 'asis' => 1, - ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) : ''), + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowrap left"', - 'text' => dol_print_date($datelimite, "dayhour"), - ); + $this->info_box_contents[$line][2] = array( + 'td' => 'class="nowrap left"', + 'text' => dol_print_date($datelimite, "dayhour"), + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => ($objp->percentage >= 0 ? $objp->percentage.'%' : ''), - ); + $this->info_box_contents[$line][3] = array( + 'td' => 'class="right"', + 'text' => ($objp->percentage >= 0 ? $objp->percentage.'%' : ''), + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $actionstatic->LibStatut($objp->percentage, 3), - ); + $this->info_box_contents[$line][4] = array( + 'td' => 'class="right" width="18"', + 'text' => $actionstatic->LibStatut($objp->percentage, 3), + 'asis' => 1 + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoActionsToDo"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoActionsToDo") + ); - $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") - ); + $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") + ); } } @@ -188,13 +194,13 @@ class box_actions extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { global $langs, $conf; - $out = parent::showBox($this->info_box_head, $this->info_box_contents); + $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1); - if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) - { + if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) + { $actioncejour = false; $contents = $this->info_box_contents; $nblines = count($contents); @@ -255,5 +261,5 @@ class box_actions extends ModeleBoxes else print $out; return ''; - } + } } diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index e6d032d41f8..7c33ace20ab 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -32,27 +32,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_birthdays extends ModeleBoxes { - public $boxcode = "birthdays"; - public $boximg = "object_user"; - public $boxlabel = "BoxTitleUserBirthdaysOfMonth"; - public $depends = array("user"); + public $boxcode = "birthdays"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleUserBirthdaysOfMonth"; + public $depends = array("user"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -64,10 +64,10 @@ class box_birthdays extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 20) { @@ -78,9 +78,9 @@ class box_birthdays extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $userstatic = new User($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); if ($user->rights->user->user->lire) { @@ -89,6 +89,7 @@ class box_birthdays extends ModeleBoxes $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.entity IN (".getEntity('user').")"; + $sql.= " AND u.statut = 1"; $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); $sql .= " ORDER BY u.birth ASC"; $sql .= $this->db->plimit($max, 0); @@ -103,25 +104,25 @@ class box_birthdays extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $userstatic->id = $objp->rowid; - $userstatic->firstname = $objp->firstname; - $userstatic->lastname = $objp->lastname; - $userstatic->email = $objp->email; - $dateb = $this->db->jdate($objp->birth); - $age = date('Y', dol_now()) - date('Y', $dateb); + $userstatic->id = $objp->rowid; + $userstatic->firstname = $objp->firstname; + $userstatic->lastname = $objp->lastname; + $userstatic->email = $objp->email; + $dateb = $this->db->jdate($objp->birth); + $age = date('Y', dol_now()) - date('Y', $dateb); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $userstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $userstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') + ); - /*$this->info_box_contents[$line][] = array( + /*$this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $userstatic->LibStatut($objp->status, 3) );*/ @@ -134,15 +135,15 @@ class box_birthdays extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + '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") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -155,8 +156,8 @@ class box_birthdays extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index e49d21ba387..02a315ea836 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -32,27 +32,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_birthdays_members extends ModeleBoxes { - public $boxcode = "birthdays_members"; - public $boximg = "object_user"; - public $boxlabel = "BoxTitleMemberNextBirthdays"; - public $depends = array("adherent"); + public $boxcode = "birthdays_members"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleMemberNextBirthdays"; + public $depends = array("adherent"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -64,10 +64,10 @@ class box_birthdays_members extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 20) { @@ -78,9 +78,9 @@ class box_birthdays_members extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic = new Adherent($this->db); + $memberstatic = new Adherent($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); if ($user->rights->adherent->lire) { @@ -89,8 +89,8 @@ class box_birthdays_members extends ModeleBoxes $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as u"; $sql .= " WHERE u.entity IN (".getEntity('adherent').")"; - $sql .= " AND u.statut = 1"; - $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); + $sql .= " AND u.statut = 1"; + $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); $sql .= " ORDER BY u.birth ASC"; $sql .= $this->db->plimit($max, 0); @@ -104,25 +104,25 @@ class box_birthdays_members extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $memberstatic->id = $objp->rowid; - $memberstatic->firstname = $objp->firstname; - $memberstatic->lastname = $objp->lastname; - $memberstatic->email = $objp->email; - $dateb = $this->db->jdate($objp->birth); - $age = date('Y', dol_now()) - date('Y', $dateb); + $memberstatic->id = $objp->rowid; + $memberstatic->firstname = $objp->firstname; + $memberstatic->lastname = $objp->lastname; + $memberstatic->email = $objp->email; + $dateb = $this->db->jdate($objp->birth); + $age = date('Y', dol_now()) - date('Y', $dateb); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $memberstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $memberstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') + ); - /*$this->info_box_contents[$line][] = array( + /*$this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $memberstatic->LibStatut($objp->status, 3) );*/ @@ -135,15 +135,15 @@ class box_birthdays_members extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + '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") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -156,8 +156,8 @@ class box_birthdays_members extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_boms.php b/htdocs/core/boxes/box_boms.php index c75c4c24e8f..6a2554bcde0 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -32,147 +32,147 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_boms extends ModeleBoxes { - public $boxcode = "lastboms"; - public $boximg = "object_bom"; - public $boxlabel = "BoxTitleLatestModifiedBoms"; - public $depends = array("bom"); + public $boxcode = "lastboms"; + public $boximg = "object_bom"; + public $boxlabel = "BoxTitleLatestModifiedBoms"; + public $depends = array("bom"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bom->read); - } + $this->hidden = !($user->rights->bom->read); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $bomstatic = new Bom($this->db); - $productstatic = new Product($this->db); - $userstatic = new User($this->db); + $bomstatic = new Bom($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max)); - if ($user->rights->bom->read) - { - $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; - $sql .= ", c.rowid"; - $sql .= ", c.date_creation"; - $sql .= ", c.tms"; - $sql .= ", c.ref"; - $sql .= ", c.status"; - $sql .= ", c.fk_user_valid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; - $sql .= " WHERE c.fk_product = p.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " ORDER BY c.tms DESC, c.ref DESC"; - $sql .= " ".$this->db->plimit($max, 0); + if ($user->rights->bom->read) + { + $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; + $sql .= ", c.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datem = $this->db->jdate($objp->tms); + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem = $this->db->jdate($objp->tms); - $bomstatic->id = $objp->rowid; - $bomstatic->ref = $objp->ref; - $bomstatic->id = $objp->socid; - $bomstatic->status = $objp->status; + $bomstatic->id = $objp->rowid; + $bomstatic->ref = $objp->ref; + $bomstatic->id = $objp->socid; + $bomstatic->status = $objp->status; - $productstatic->ref = $objp->product_ref; - $productstatic->status = $objp->tobuy; - $productstatic->status_buy = $objp->tosell; + $productstatic->ref = $objp->product_ref; + $productstatic->status = $objp->tobuy; + $productstatic->status_buy = $objp->tosell; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $bomstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $bomstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $bomstatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $bomstatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $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") - ); - } - } + $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 @@ -182,8 +182,8 @@ class box_boms extends ModeleBoxes * @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); - } + 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_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index c81e226decb..795eaeccf36 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -28,20 +28,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_bookmarks extends ModeleBoxes { - public $boxcode = "bookmarks"; - public $boximg = "bookmark"; - public $boxlabel = "BoxMyLastBookmarks"; - public $depends = array("bookmark"); + public $boxcode = "bookmarks"; + public $boximg = "bookmark"; + public $boxlabel = "BoxMyLastBookmarks"; + public $depends = array("bookmark"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,18 +52,18 @@ class box_bookmarks extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bookmark->lire); + $this->hidden = !($user->rights->bookmark->lire); } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -73,10 +73,10 @@ class box_bookmarks extends ModeleBoxes $this->max = $max; $this->info_box_head = array( - 'text' => $langs->trans("BoxMyLastBookmarks", $max), - 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php', - ); - if ($user->rights->bookmark->creer) { + 'text' => $langs->trans("BoxMyLastBookmarks", $max), + 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php', + ); + if ($user->rights->bookmark->creer) { $this->info_box_head['subpicto'] = 'bookmark'; $this->info_box_head['subtext'] = $langs->trans("BookmarksManagement"); } else { @@ -89,7 +89,7 @@ class box_bookmarks extends ModeleBoxes $sql = "SELECT b.title, b.url, b.target, b.favicon"; $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b"; $sql .= " WHERE fk_user = ".$user->id; - $sql .= " AND b.entity = ".$conf->entity; + $sql .= " AND b.entity = ".$conf->entity; $sql .= $this->db->order("position", "ASC"); $sql .= $this->db->plimit($max, 0); @@ -100,63 +100,63 @@ class box_bookmarks extends ModeleBoxes $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'logo' => $this->boximg, - 'url' => $objp->url, - 'tooltip' => $objp->title, - 'target' => $objp->target ? 'newtab' : '', - ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $objp->title, - 'url' => $objp->url, - 'tooltip' => $objp->title, - 'target' => $objp->target ? 'newtab' : '', - ); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'logo' => $this->boximg, + 'url' => $objp->url, + 'tooltip' => $objp->title, + 'target' => $objp->target ? 'newtab' : '', + ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $objp->title, + 'url' => $objp->url, + 'tooltip' => $objp->title, + 'target' => $objp->target ? 'newtab' : '', + ); - $line++; - } + $line++; + } - if ($num == 0) { - $mytxt = $langs->trans("NoRecordedBookmarks"); - if ($user->rights->bookmark->creer) $mytxt .= ' '.$langs->trans("ClickToAdd"); - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center" colspan="2"', - 'tooltip' => $mytxt, - 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt, - ); - } + if ($num == 0) { + $mytxt = $langs->trans("NoRecordedBookmarks"); + if ($user->rights->bookmark->creer) $mytxt .= ' '.$langs->trans("ClickToAdd"); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center" colspan="2"', + 'tooltip' => $mytxt, + 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt, + ); + } - $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") - ); - } - } + $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); - } + /** + * 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_clients.php b/htdocs/core/boxes/box_clients.php index 00cad787e0b..816facc3ee4 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -32,27 +32,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_clients extends ModeleBoxes { - public $boxcode = "lastcustomers"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastCustomers"; - public $depends = array("societe"); + public $boxcode = "lastcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastCustomers"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -67,10 +67,10 @@ class box_clients extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -79,23 +79,23 @@ class box_clients extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.nom as name, s.rowid as socid"; - $sql .= ", s.code_client"; - $sql .= ", s.client"; - $sql .= ", s.code_fournisseur"; - $sql .= ", s.fournisseur"; - $sql .= ", s.code_compta"; - $sql .= ", s.code_compta_fournisseur"; - $sql .= ", s.logo"; - $sql .= ", s.email"; - $sql .= ", s.datec, s.tms, s.status, s.entity"; + $sql .= ", s.code_client"; + $sql .= ", s.client"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.code_compta"; + $sql .= ", s.code_compta_fournisseur"; + $sql .= ", s.logo"; + $sql .= ", s.email"; + $sql .= ", s.datec, s.tms, s.status, s.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.client IN (1, 3)"; @@ -117,33 +117,33 @@ class box_clients extends ModeleBoxes $objp = $this->db->fetch_object($result); $datec = $this->db->jdate($objp->datec); $datem = $this->db->jdate($objp->tms); - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta = $objp->code_compta; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta = $objp->code_compta; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; + $thirdpartystatic->email = $objp->email; $thirdpartystatic->entity = $objp->entity; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day") - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day") + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3) - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) + ); $line++; } @@ -156,15 +156,15 @@ class box_clients extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + '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") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -177,8 +177,8 @@ class box_clients extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_commandes.php b/htdocs/core/boxes/box_commandes.php index 90729b96017..c94353f1d5c 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -32,168 +32,168 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_commandes extends ModeleBoxes { - public $boxcode = "lastcustomerorders"; - public $boximg = "object_order"; - public $boxlabel = "BoxLastCustomerOrders"; - public $depends = array("commande"); + public $boxcode = "lastcustomerorders"; + public $boximg = "object_order"; + public $boxlabel = "BoxLastCustomerOrders"; + public $depends = array("commande"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->commande->lire); - } + $this->hidden = !($user->rights->commande->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; - $langs->load('orders'); + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load('orders'); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $commandestatic = new Commande($this->db); - $societestatic = new Societe($this->db); - $userstatic = new User($this->db); + $commandestatic = new Commande($this->db); + $societestatic = new Societe($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerOrders", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerOrders", $max)); - if ($user->rights->commande->lire) - { - $sql = "SELECT s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client"; - $sql .= ", s.logo, s.email"; - $sql .= ", c.ref, c.tms"; - $sql .= ", c.rowid"; - $sql .= ", c.date_commande"; - $sql .= ", c.ref_client"; - $sql .= ", c.fk_statut"; - $sql .= ", c.fk_user_valid"; - $sql .= ", c.facture"; - $sql .= ", c.total_ht"; - $sql .= ", c.tva as total_tva"; - $sql .= ", c.total_ttc"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('commande').")"; - if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->commande->lire) + { + $sql = "SELECT s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", c.ref, c.tms"; + $sql .= ", c.rowid"; + $sql .= ", c.date_commande"; + $sql .= ", c.ref_client"; + $sql .= ", c.fk_statut"; + $sql .= ", c.fk_user_valid"; + $sql .= ", c.facture"; + $sql .= ", c.total_ht"; + $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_ttc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_commande); - $datem = $this->db->jdate($objp->tms); - $commandestatic->id = $objp->rowid; - $commandestatic->ref = $objp->ref; - $commandestatic->ref_client = $objp->ref_client; - $commandestatic->total_ht = $objp->total_ht; - $commandestatic->total_tva = $objp->total_tva; - $commandestatic->total_ttc = $objp->total_ttc; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->email = $objp->email; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_commande); + $datem = $this->db->jdate($objp->tms); + $commandestatic->id = $objp->rowid; + $commandestatic->ref = $objp->ref; + $commandestatic->ref_client = $objp->ref_client; + $commandestatic->total_ht = $objp->total_ht; + $commandestatic->total_tva = $objp->total_tva; + $commandestatic->total_ttc = $objp->total_ttc; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $commandestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $commandestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $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") - ); - } - } + $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 @@ -203,8 +203,8 @@ class box_commandes extends ModeleBoxes * @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); - } + 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_comptes.php b/htdocs/core/boxes/box_comptes.php index b3f23817712..53be2725680 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -33,28 +33,28 @@ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; */ class box_comptes extends ModeleBoxes { - public $boxcode = "currentaccounts"; - public $boximg = "object_bill"; - public $boxlabel = "BoxCurrentAccounts"; - public $depends = array("banque"); // Box active if module banque active + public $boxcode = "currentaccounts"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCurrentAccounts"; + public $depends = array("banque"); // Box active if module banque active - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -73,7 +73,7 @@ class box_comptes extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -83,109 +83,109 @@ class box_comptes extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); - if ($user->rights->banque->lire) { + if ($user->rights->banque->lire) { $sql = "SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url"; $sql .= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban"; $sql .= ", b.domiciliation, b.proprio, b.owner_address"; $sql .= ", b.account_number, b.currency_code"; $sql .= ", b.min_allowed, b.min_desired, comment"; - $sql .= ', b.fk_accountancy_journal'; - $sql .= ', aj.code as accountancy_journal'; - $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; - $sql .= " WHERE b.entity = ".$conf->entity; + $sql .= ', b.fk_accountancy_journal'; + $sql .= ', aj.code as accountancy_journal'; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; + $sql .= " WHERE b.entity = ".$conf->entity; $sql .= " AND clos = 0"; //$sql.= " AND courant = 1"; $sql .= " ORDER BY label"; $sql .= $this->db->plimit($max, 0); - dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; - $solde_total = array(); + $line = 0; + $solde_total = array(); - $account_static = new Account($this->db); - while ($line < $num) { - $objp = $this->db->fetch_object($result); + $account_static = new Account($this->db); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $account_static->id = $objp->rowid; + $account_static->id = $objp->rowid; $account_static->ref = $objp->ref; - $account_static->label = $objp->label; - $account_static->number = $objp->number; - $account_static->account_number = $objp->account_number; - $account_static->currency_code = $objp->currency_code; - $account_static->accountancy_journal = $objp->accountancy_journal; - $solde = $account_static->solde(0); + $account_static->label = $objp->label; + $account_static->number = $objp->number; + $account_static->account_number = $objp->account_number; + $account_static->currency_code = $objp->currency_code; + $account_static->accountancy_journal = $objp->accountancy_journal; + $solde = $account_static->solde(0); - $solde_total[$objp->currency_code] += $solde; + $solde_total[$objp->currency_code] += $solde; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $account_static->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $account_static->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $objp->number, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $objp->number, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code) - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code) + ); - $line++; - } + $line++; + } - // Total - foreach ($solde_total as $key=>$solde) { - $this->info_box_contents[$line][] = array( - 'tr' => 'class="liste_total"', - 'td' => 'class="liste_total left"', - 'text' => $langs->trans('Total').' '.$key, - ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="liste_total right"', - 'text' => ' ' - ); + // Total + foreach ($solde_total as $key=>$solde) { + $this->info_box_contents[$line][] = array( + 'tr' => 'class="liste_total"', + 'td' => 'class="liste_total left"', + 'text' => $langs->trans('Total').' '.$key, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => ' ' + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="liste_total right nowraponall"', - 'text' => price($solde, 0, $langs, 0, -1, -1, $key) - ); - $line++; - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right nowraponall"', + 'text' => price($solde, 0, $langs, 0, -1, -1, $key) + ); + $line++; + } - $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") - ); - } + $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); - } + /** + * 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_contacts.php b/htdocs/core/boxes/box_contacts.php index 7141728c23d..c3756bfd86c 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -35,20 +35,20 @@ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; */ class box_contacts extends ModeleBoxes { - public $boxcode = "lastcontacts"; - public $boximg = "object_contact"; - public $boxlabel = "BoxLastContacts"; - public $depends = array("societe"); + public $boxcode = "lastcontacts"; + public $boximg = "object_contact"; + public $boxlabel = "BoxLastContacts"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -59,18 +59,18 @@ class box_contacts extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); + $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -121,7 +121,7 @@ class box_contacts extends ModeleBoxes $contactstatic->phone_pro = $objp->phone; $contactstatic->phone_perso = $objp->phone_perso; $contactstatic->phone_mobile = $objp->phone_mobile; - $contactstatic->email = $objp->spemail; + $contactstatic->email = $objp->spemail; $contactstatic->address = $objp->address; $contactstatic->zip = $objp->zip; $contactstatic->town = $objp->town; @@ -130,7 +130,7 @@ class box_contacts extends ModeleBoxes $societestatic->id = $objp->fk_soc; $societestatic->name = $objp->socname; - $societestatic->email = $objp->semail; + $societestatic->email = $objp->semail; $societestatic->name_alias = $objp->name_alias; $societestatic->code_client = $objp->code_client; $societestatic->code_fournisseur = $objp->code_fournisseur; diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 75fbc207134..9350bae2da9 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -31,158 +31,158 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_contracts extends ModeleBoxes { - public $boxcode = "lastcontracts"; - public $boximg = "object_contract"; - public $boxlabel = "BoxLastContracts"; - public $depends = array("contrat"); // conf->contrat->enabled + public $boxcode = "lastcontracts"; + public $boximg = "object_contract"; + public $boxlabel = "BoxLastContracts"; + public $depends = array("contrat"); // conf->contrat->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->contrat->lire); - } + $this->hidden = !($user->rights->contrat->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max)); - if ($user->rights->contrat->lire) - { - $contractstatic = new Contrat($this->db); - $thirdpartytmp = new Societe($this->db); + if ($user->rights->contrat->lire) + { + $contractstatic = new Contrat($this->db); + $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 .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC "; - else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; - $sql .= $this->db->plimit($max, 0); + $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 .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $now = dol_now(); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $now = dol_now(); - $line = 0; + $line = 0; - $langs->load("contracts"); + $langs->load("contracts"); - while ($line < $num) - { - $objp = $this->db->fetch_object($resql); + while ($line < $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_cloture); - $late = ''; + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); + $late = ''; - $contractstatic->statut = $objp->fk_statut; - $contractstatic->id = $objp->rowid; - $contractstatic->ref = $objp->ref; - $contractstatic->ref_customer = $objp->ref_customer; - $contractstatic->ref_supplier = $objp->ref_supplier; - $result = $contractstatic->fetch_lines(); + $contractstatic->statut = $objp->fk_statut; + $contractstatic->id = $objp->rowid; + $contractstatic->ref = $objp->ref; + $contractstatic->ref_customer = $objp->ref_customer; + $contractstatic->ref_supplier = $objp->ref_supplier; + $result = $contractstatic->fetch_lines(); - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->client = $objp->client; - $thirdpartytmp->fournisseur = $objp->fournisseur; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->code_compta = $objp->code_compta; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - // fin_validite is no more on contract but on services - // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } + // fin_validite is no more on contract but on services + // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contractstatic->getNomUrl(1), - 'text2'=> $late, - 'asis'=>1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $contractstatic->getNomUrl(1), + 'text2'=> $late, + 'asis'=>1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1), - 'asis'=>1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1), + 'asis'=>1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => $contractstatic->getLibStatut(7), - 'asis'=>1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => $contractstatic->getLibStatut(7), + 'asis'=>1, + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedContracts"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedContracts"), + ); - $this->db->free($resql); - } 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") - ); - } - } + $this->db->free($resql); + } 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 @@ -192,8 +192,8 @@ class box_contracts extends ModeleBoxes * @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); - } + 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_external_rss.php b/htdocs/core/boxes/box_external_rss.php index d5cc859eaa7..949f6ac1382 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -34,45 +34,45 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_external_rss extends ModeleBoxes { - public $boxcode = "lastrssinfos"; - public $boximg = "object_rss"; - public $boxlabel = "BoxLastRssInfos"; - public $depends = array("externalrss"); + public $boxcode = "lastrssinfos"; + public $boximg = "object_rss"; + public $boxlabel = "BoxLastRssInfos"; + public $depends = array("externalrss"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $paramdef; // Params of box definition (not user params) + public $paramdef; // Params of box definition (not user params) - public $info_box_head = array(); - public $info_box_contents = array(); + 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) - { + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { $this->db = $db; $this->paramdef = $param; - } + } - /** + /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @param int $cachedelay Delay we accept for cache file - * @return void - */ - public function loadBox($max = 5, $cachedelay = 3600) - { - global $user, $langs, $conf; - $langs->load("boxes"); + * @param int $cachedelay Delay we accept for cache file + * @return void + */ + public function loadBox($max = 5, $cachedelay = 3600) + { + global $user, $langs, $conf; + $langs->load("boxes"); $this->max = $max; @@ -90,42 +90,42 @@ class box_external_rss extends ModeleBoxes // Get RSS feed $url = $conf->global->$keyforparamurl; - $rssparser = new RssParser($this->db); + $rssparser = new RssParser($this->db); $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); // INFO on channel $description = $rssparser->getDescription(); $link = $rssparser->getLink(); - $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); - if ($result < 0 || !empty($rssparser->error)) - { - // Show warning - $errormessage = $langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown"))); - if ($rssparser->error) $errormessage .= " - ".$rssparser->error; - $title .= " ".img_error($errormessage); - $this->info_box_head = array('text' => $title, 'limit' => 0); - } else { - $this->info_box_head = array( - 'text' => $title, - 'sublink' => $link, - 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), - 'subpicto'=>'globe', - 'target'=>'_blank', - ); + $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); + if ($result < 0 || !empty($rssparser->error)) + { + // Show warning + $errormessage = $langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown"))); + if ($rssparser->error) $errormessage .= " - ".$rssparser->error; + $title .= " ".img_error($errormessage); + $this->info_box_head = array('text' => $title, 'limit' => 0); + } else { + $this->info_box_head = array( + 'text' => $title, + 'sublink' => $link, + 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), + 'subpicto'=>'globe', + 'target'=>'_blank', + ); } // INFO on items $items = $rssparser->getItems(); - //print '
    '.print_r($items,true).'
    '; + //print '
    '.print_r($items,true).'
    '; $nbitems = count($items); - for ($line = 0; $line < $max && $line < $nbitems; $line++) - { - $item = $items[$line]; + for ($line = 0; $line < $max && $line < $nbitems; $line++) + { + $item = $items[$line]; // Feed common fields - $href = $item['link']; - $title = urldecode($item['title']); + $href = $item['link']; + $title = urldecode($item['title']); $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed if ($rssparser->getFormat() == 'rss') // If RSS { @@ -145,46 +145,46 @@ class box_external_rss extends ModeleBoxes if (is_numeric($date)) $date = dol_print_date($date, "dayhour"); $isutf8 = utf8_check($title); - if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); - $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 - $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut - $this->info_box_contents["$href"] = "$title"; + $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 + $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut + $this->info_box_contents["$href"] = "$title"; - $tooltip = $title; - $description = !empty($item['description']) ? $item['description'] : ''; - $isutf8 = utf8_check($description); - if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); - $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); - $description = preg_replace("/^\s+/", "", $description); - $description = str_replace("\r\n", "", $description); - $tooltip .= '
    '.$description; + $tooltip = $title; + $description = !empty($item['description']) ? $item['description'] : ''; + $isutf8 = utf8_check($description); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); + $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); + $description = preg_replace("/^\s+/", "", $description); + $description = str_replace("\r\n", "", $description); + $tooltip .= '
    '.$description; - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'logo' => $this->boximg, - 'url' => $href, - 'tooltip' => $tooltip, - 'target' => 'newrss', - ); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'logo' => $this->boximg, + 'url' => $href, + 'tooltip' => $tooltip, + 'target' => 'newrss', + ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $title, - 'url' => $href, - 'tooltip' => $tooltip, - 'maxlength' => 64, - 'target' => 'newrss', - ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $title, + 'url' => $href, + 'tooltip' => $tooltip, + 'maxlength' => 64, + 'target' => 'newrss', + ); - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right nowrap"', - 'text' => $date, - ); - } - } + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right nowrap"', + 'text' => $date, + ); + } + } /** @@ -195,8 +195,8 @@ class box_external_rss extends ModeleBoxes * @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); - } + 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_factures.php b/htdocs/core/boxes/box_factures.php index ebaff31268d..6a824849212 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures extends ModeleBoxes { - public $boxcode = "lastcustomerbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxLastCustomerBills"; - public $depends = array("facture"); + public $boxcode = "lastcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastCustomerBills"; + public $depends = array("facture"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,18 +54,18 @@ class box_factures extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -73,13 +73,13 @@ class box_factures extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $facturestatic = new Facture($this->db); - $societestatic = new Societe($this->db); + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); - $langs->load("bills"); + $langs->load("bills"); $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerBills", $max); $this->info_box_head = array( @@ -87,14 +87,14 @@ class box_factures extends ModeleBoxes 'limit'=> dol_strlen($text) ); - if ($user->rights->facture->lire) { - $sql = "SELECT f.rowid as facid"; - $sql .= ", f.ref, f.type, f.total as total_ht"; - $sql .= ", f.tva as total_tva"; - $sql .= ", f.total_ttc"; - $sql .= ", f.datef as df"; + if ($user->rights->facture->lire) { + $sql = "SELECT f.rowid as facid"; + $sql .= ", f.ref, f.type, f.total as total_ht"; + $sql .= ", f.tva as total_tva"; + $sql .= ", f.total_ttc"; + $sql .= ", f.datef as df"; $sql .= ", f.paye, f.fk_statut, f.datec, f.tms"; - $sql .= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; + $sql .= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql .= ", f.date_lim_reglement as datelimite"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -103,8 +103,8 @@ class box_factures extends ModeleBoxes $sql .= " AND f.entity IN (".getEntity('invoice').")"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; - else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); @@ -116,90 +116,90 @@ class box_factures extends ModeleBoxes $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datelimite = $this->db->jdate($objp->datelimite); - $date = $this->db->jdate($objp->df); - $datem = $this->db->jdate($objp->tms); + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datelimite = $this->db->jdate($objp->datelimite); + $date = $this->db->jdate($objp->df); + $datem = $this->db->jdate($objp->tms); - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - $facturestatic->type = $objp->type; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->statut = $objp->fk_statut; - $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->type = $objp->type; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->statut = $objp->fk_statut; + $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->code_client = $objp->code_client; - $societestatic->tva_intra = $objp->tva_intra; - $societestatic->email = $objp->email; - $societestatic->idprof1 = $objp->idprof1; - $societestatic->idprof2 = $objp->idprof2; - $societestatic->idprof3 = $objp->idprof3; - $societestatic->idprof4 = $objp->idprof4; - $societestatic->idprof5 = $objp->idprof5; - $societestatic->idprof6 = $objp->idprof6; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->code_client = $objp->code_client; + $societestatic->tva_intra = $objp->tva_intra; + $societestatic->email = $objp->email; + $societestatic->idprof1 = $objp->idprof1; + $societestatic->idprof2 = $objp->idprof2; + $societestatic->idprof3 = $objp->idprof3; + $societestatic->idprof4 = $objp->idprof4; + $societestatic->idprof5 = $objp->idprof5; + $societestatic->idprof6 = $objp->idprof6; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax200"', - 'text' => $societestatic->getNomUrl(1, '', 40), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax200"', + 'text' => $societestatic->getNomUrl(1, '', 40), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); - $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") - ); - } - } + $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 @@ -209,8 +209,8 @@ class box_factures extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 30f3cd503c2..7053acb9e97 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn extends ModeleBoxes { - public $boxcode = "lastsupplierbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxLastSupplierBills"; - public $depends = array("facture", "fournisseur"); + public $boxcode = "lastsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastSupplierBills"; + public $depends = array("facture", "fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,18 +55,18 @@ class box_factures_fourn extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -75,10 +75,10 @@ class box_factures_fourn extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $facturestatic = new FactureFournisseur($this->db); - $thirdpartytmp = new Fournisseur($this->db); + $facturestatic = new FactureFournisseur($this->db); + $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array( 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierBills", $max) @@ -87,12 +87,12 @@ class box_factures_fourn extends ModeleBoxes if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql .= " s.code_fournisseur, s.email,"; - $sql .= " s.logo,"; + $sql .= " s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier,"; - $sql .= " f.total_ht,"; - $sql .= " f.total_tva,"; - $sql .= " f.total_ttc,"; + $sql .= " f.total_ht,"; + $sql .= " f.total_tva,"; + $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut,"; $sql .= ' f.datef as df,'; $sql .= ' f.datec as datec,'; @@ -104,8 +104,8 @@ class box_factures_fourn extends ModeleBoxes $sql .= " AND f.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; - else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); @@ -116,96 +116,96 @@ class box_factures_fourn extends ModeleBoxes $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - while ($line < $num) { + while ($line < $num) { $objp = $this->db->fetch_object($result); $datelimite = $this->db->jdate($objp->datelimite); $date = $this->db->jdate($objp->df); $datem = $this->db->jdate($objp->tms); - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->date_echeance = $datelimite; - $facturestatic->statut = $objp->fk_statut; - $facturestatic->ref_supplier = $objp->ref_supplier; + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->date_echeance = $datelimite; + $facturestatic->statut = $objp->fk_statut; + $facturestatic->ref_supplier = $objp->ref_supplier; - $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->fournisseur = 1; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150"', - 'text' => $objp->ref_supplier, - 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
    '.$langs->trans('RefSupplier').': '.$objp->ref_supplier, - 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150"', + 'text' => $objp->ref_supplier, + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
    '.$langs->trans('RefSupplier').': '.$objp->ref_supplier, + 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150"', - 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $fac = new FactureFournisseur($this->db); - $fac->fetch($objp->facid); - $alreadypaid = $fac->getSommePaiement(); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), - ); + $fac = new FactureFournisseur($this->db); + $fac->fetch($objp->facid); + $alreadypaid = $fac->getSommePaiement(); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoModifiedSupplierBills"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoModifiedSupplierBills"), + ); - $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->transnoentities("ReadPermissionNotAllowed") - ); - } - } + $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->transnoentities("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -215,8 +215,8 @@ class box_factures_fourn extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index c2b5e7c705e..938505caab4 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn_imp extends ModeleBoxes { - public $boxcode = "oldestunpaidsupplierbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxOldestUnpaidSupplierBills"; - public $depends = array("facture", "fournisseur"); + public $boxcode = "oldestunpaidsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidSupplierBills"; + public $depends = array("facture", "fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,18 +54,18 @@ class box_factures_fourn_imp extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -85,9 +85,9 @@ class box_factures_fourn_imp extends ModeleBoxes $sql = "SELECT s.nom as name, s.rowid as socid,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; $sql .= " f.datef as df,"; - $sql .= " f.total_ht as total_ht,"; - $sql .= " f.tva as total_tva,"; - $sql .= " f.total_ttc,"; + $sql .= " f.total_ht as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut, f.type"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ",".MAIN_DB_PREFIX."facture_fourn as f"; @@ -109,7 +109,7 @@ class box_factures_fourn_imp extends ModeleBoxes $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - $facturestatic = new FactureFournisseur($this->db); + $facturestatic = new FactureFournisseur($this->db); while ($line < $num) { @@ -127,71 +127,71 @@ class box_factures_fourn_imp extends ModeleBoxes $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; $thirdpartytmp->fournisseur = 1; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } - $tooltip = $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
    '.$langs->trans('RefSupplier').': '.$objp->ref_supplier; + $tooltip = $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
    '.$langs->trans('RefSupplier').': '.$objp->ref_supplier; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1, '', 40), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datelimite, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datelimite, 'day'), + ); $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); $alreadypaid = $fac->getSommePaiement(); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoUnpaidSupplierBills"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoUnpaidSupplierBills"), + ); - $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") - ); - } - } + $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 @@ -201,8 +201,8 @@ class box_factures_fourn_imp extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index f5fe3e76dde..e1b6a39b529 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -33,20 +33,20 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; */ class box_factures_imp extends ModeleBoxes { - public $boxcode = "oldestunpaidcustomerbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxOldestUnpaidCustomerBills"; - public $depends = array("facture"); + public $boxcode = "oldestunpaidcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidCustomerBills"; + public $depends = array("facture"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -57,18 +57,18 @@ class box_factures_imp extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -77,10 +77,10 @@ class box_factures_imp extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $facturestatic = new Facture($this->db); - $societestatic = new Societe($this->db); + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); $langs->load("bills"); @@ -89,14 +89,14 @@ class box_factures_imp extends ModeleBoxes if ($user->rights->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.email,"; - $sql .= " s.code_client,"; - $sql .= " s.logo,"; + $sql .= " s.code_client,"; + $sql .= " s.logo,"; $sql .= " f.ref, f.date_lim_reglement as datelimite,"; - $sql .= " f.type,"; + $sql .= " f.type,"; $sql .= " f.datef as df,"; - $sql .= " f.total as total_ht,"; - $sql .= " f.tva as total_tva,"; - $sql .= " f.total_ttc,"; + $sql .= " f.total as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut, f.rowid as facid"; $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -128,54 +128,54 @@ class box_factures_imp extends ModeleBoxes { $objp = $this->db->fetch_object($result); $datelimite = $this->db->jdate($objp->datelimite); - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - $facturestatic->type = $objp->type; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->type = $objp->type; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->fk_statut; $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->client = 1; - $societestatic->email = $objp->email; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->client = 1; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1, '', 44), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1, '', 44), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datelimite, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datelimite, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $objp->am), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $objp->am), + ); $line++; } @@ -187,17 +187,17 @@ class box_factures_imp extends ModeleBoxes $this->db->free($result); } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + $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") - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -209,8 +209,8 @@ class box_factures_imp extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 2c104bea729..fc9fcc9fc17 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_ficheinter extends ModeleBoxes { - public $boxcode = "ficheinter"; - public $boximg = "object_intervention"; - public $boxlabel = "BoxFicheInter"; - public $depends = array("ficheinter"); // conf->contrat->enabled + public $boxcode = "ficheinter"; + public $boximg = "object_intervention"; + public $boxlabel = "BoxFicheInter"; + public $depends = array("ficheinter"); // conf->contrat->enabled /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,11 +55,11 @@ class box_ficheinter extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->ficheinter->lire); + $this->hidden = !($user->rights->ficheinter->lire); } /** @@ -67,7 +67,7 @@ class box_ficheinter extends ModeleBoxes * * @param int $max Maximum number of records to load * @return void - */ + */ public function loadBox($max = 10) { global $user, $langs, $conf; @@ -120,26 +120,26 @@ class box_ficheinter extends ModeleBoxes $companystatic->email = $objp->semail; $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $ficheinterstatic->getNomUrl(1), - 'asis' => 1, + 'td' => 'class="nowraponall"', + 'text' => $ficheinterstatic->getNomUrl(1), + 'asis' => 1, ); $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $companystatic->getNomUrl(1), - 'asis' => 1, - ); + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $companystatic->getNomUrl(1), + 'asis' => 1, + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day'), - ); + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'day'), + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="nowrap right"', - 'text' => $ficheinterstatic->getLibStatut(3), - 'asis' => 1, + 'td' => 'class="nowrap right"', + 'text' => $ficheinterstatic->getLibStatut(3), + 'asis' => 1, ); $i++; @@ -153,15 +153,15 @@ class box_ficheinter extends ModeleBoxes $this->db->free($resql); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + '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") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -174,8 +174,8 @@ class box_ficheinter extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 44dd891bfb8..4be895f769c 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -32,129 +32,129 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_fournisseurs extends ModeleBoxes { - public $boxcode = "lastsuppliers"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastSuppliers"; - public $depends = array("fournisseur"); + public $boxcode = "lastsuppliers"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastSuppliers"; + public $depends = array("fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->societe->lire && empty($user->socid)); - } + $this->hidden = !($user->rights->societe->lire && empty($user->socid)); + } - /** + /** * 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 $conf, $user, $langs; - $langs->load("boxes"); + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + $langs->load("boxes"); $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); - if ($user->rights->societe->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; - $sql .= " s.code_fournisseur, s.email as semail,"; - $sql .= " s.logo, s.code_compta_fournisseur, s.entity"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE s.fournisseur = 1"; - $sql .= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - $sql .= " ORDER BY s.tms DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->societe->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; + $sql .= " s.code_fournisseur, s.email as semail,"; + $sql .= " s.logo, s.code_compta_fournisseur, s.entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.fournisseur = 1"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " ORDER BY s.tms DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $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); + $line = 0; + while ($line < $num) + { + $objp = $this->db->fetch_object($result); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->email = $objp->semail; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->logo = $objp->logo; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartytmp->entity = $objp->entity; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->semail; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->entity = $objp->entity; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartytmp->getNomUrl(1, '', 40), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedSuppliers"), - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedSuppliers"), + ); - $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") - ); - } - } + $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 @@ -164,8 +164,8 @@ class box_fournisseurs extends ModeleBoxes * @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); - } + 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_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 66497c2e94f..7efecc4001c 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -33,27 +33,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_goodcustomers extends ModeleBoxes { - public $boxcode = "goodcustomers"; - public $boximg = "object_company"; - public $boxlabel = "BoxGoodCustomers"; - public $depends = array("societe"); + public $boxcode = "goodcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxGoodCustomers"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -69,10 +69,10 @@ class box_goodcustomers extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -81,10 +81,10 @@ class box_goodcustomers extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); if ($user->rights->societe->lire) { @@ -119,24 +119,24 @@ class box_goodcustomers extends ModeleBoxes $nbimpaye = $objp->nbfact - $objp->nbfactpaye; $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day") + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day") ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') + 'td' => 'class="right"', + 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3) + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) ); $line++; @@ -150,14 +150,14 @@ class box_goodcustomers extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', + 'td' => 'class="nohover opacitymedium left"', 'text' => $langs->trans("ReadPermissionNotAllowed") ); } @@ -171,8 +171,8 @@ class box_goodcustomers extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 9d5aeda7b36..d1fb6dd4114 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_permonth extends ModeleBoxes { - public $boxcode = "invoicespermonth"; - public $boximg = "object_bill"; - public $boxlabel = "BoxCustomersInvoicesPerMonth"; - public $depends = array("facture"); + public $boxcode = "invoicespermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCustomersInvoicesPerMonth"; + public $depends = array("facture"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_invoices_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -141,9 +141,9 @@ class box_graph_invoices_permonth extends ModeleBoxes $mesg = $px1->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); - $px1->SetData($data1); + $px1->SetData($data1); unset($data1); $i = $startyear; $legend = array(); while ($i <= $endyear) @@ -186,7 +186,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $mesg = $px2->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); $px2->SetData($data2); unset($data2); @@ -269,8 +269,8 @@ class box_graph_invoices_permonth extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -283,8 +283,8 @@ class box_graph_invoices_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index b9fde24b759..1490f5ea6e9 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_supplier_permonth extends ModeleBoxes { - public $boxcode = "invoicessupplierpermonth"; - public $boximg = "object_bill"; - public $boxlabel = "BoxSuppliersInvoicesPerMonth"; - public $depends = array("fournisseur"); + public $boxcode = "invoicessupplierpermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxSuppliersInvoicesPerMonth"; + public $depends = array("fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -130,7 +130,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$year.'.png'; @@ -138,12 +138,12 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $mesg = $px1->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); - $px1->SetData($data1); + $px1->SetData($data1); unset($data1); $i = $startyear; - $legend = array(); + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) @@ -183,7 +183,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $mesg = $px2->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); $px2->SetData($data2); unset($data2); @@ -263,16 +263,16 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -285,8 +285,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 2ff1a579798..d9c26620553 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_permonth extends ModeleBoxes { - public $boxcode = "orderspermonth"; - public $boximg = "object_order"; - public $boxlabel = "BoxCustomersOrdersPerMonth"; - public $depends = array("commande"); + public $boxcode = "orderspermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxCustomersOrdersPerMonth"; + public $depends = array("commande"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_orders_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -97,9 +97,9 @@ class box_graph_orders_permonth extends ModeleBoxes if ($user->rights->commande->lire) { - $langs->load("orders"); + $langs->load("orders"); - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; @@ -133,7 +133,7 @@ class box_graph_orders_permonth extends ModeleBoxes $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$endyear.'.png'; @@ -144,7 +144,7 @@ class box_graph_orders_permonth extends ModeleBoxes $px1->SetData($data1); unset($data1); $i = $startyear; - $legend = array(); + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) @@ -176,7 +176,7 @@ class box_graph_orders_permonth extends ModeleBoxes $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$endyear.'.png'; @@ -260,22 +260,22 @@ class box_graph_orders_permonth extends ModeleBoxes $stringtoshow .= '
    '; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -288,8 +288,8 @@ class box_graph_orders_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index fb40ee1f68f..765c6324516 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_supplier_permonth extends ModeleBoxes { - public $boxcode = "orderssupplierpermonth"; - public $boximg = "object_order"; - public $boxlabel = "BoxSuppliersOrdersPerMonth"; - public $depends = array("fournisseur"); + public $boxcode = "orderssupplierpermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxSuppliersOrdersPerMonth"; + public $depends = array("fournisseur"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -96,9 +96,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if ($user->rights->fournisseur->commande->lire) { - $langs->load("orders"); + $langs->load("orders"); - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; @@ -259,22 +259,22 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $stringtoshow .= '
    '; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -287,8 +287,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 957277005e7..407c66177b5 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -29,20 +29,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; */ class box_graph_product_distribution extends ModeleBoxes { - public $boxcode = "productdistribution"; - public $boximg = "object_product"; - public $boxlabel = "BoxProductDistribution"; - public $depends = array("product|service", "facture|propal|commande"); + public $boxcode = "productdistribution"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductDistribution"; + public $depends = array("product|service", "facture|propal|commande"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -58,7 +58,7 @@ class box_graph_product_distribution extends ModeleBoxes $this->db = $db; $this->hidden = !( - (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) + (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) || (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) || (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) ); @@ -68,7 +68,7 @@ class box_graph_product_distribution extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -138,7 +138,7 @@ class box_graph_product_distribution extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showpropalnb) { - $langs->load("propal"); + $langs->load("propal"); include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; $showpointvalue = 1; $nocolor = 0; @@ -197,7 +197,7 @@ class box_graph_product_distribution extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showordernb) { - $langs->load("orders"); + $langs->load("orders"); include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; $showpointvalue = 1; $nocolor = 0; @@ -315,8 +315,8 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($nbofgraph)) { - $langs->load("errors"); - $mesg = $langs->trans("ReadPermissionNotAllowed"); + $langs->load("errors"); + $mesg = $langs->trans("ReadPermissionNotAllowed"); } if (empty($conf->use_javascript_ajax)) { @@ -388,13 +388,13 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', + 'td' => 'class="nohover opacitymedium left"', 'maxlength'=>500, 'text' => $mesg ); @@ -409,8 +409,8 @@ class box_graph_product_distribution extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 4231638948a..de1a1f8de83 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_propales_permonth extends ModeleBoxes { - public $boxcode = "propalpermonth"; - public $boximg = "object_propal"; - public $boxlabel = "BoxProposalsPerMonth"; - public $depends = array("propal"); + public $boxcode = "propalpermonth"; + public $boximg = "object_propal"; + public $boxlabel = "BoxProposalsPerMonth"; + public $depends = array("propal"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_propales_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -191,7 +191,7 @@ class box_graph_propales_permonth extends ModeleBoxes { if ($startmonth != 1) { - $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { $legend[] = $i; } @@ -260,22 +260,22 @@ class box_graph_propales_permonth extends ModeleBoxes $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength' => 500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength' => 500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -288,8 +288,8 @@ class box_graph_propales_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index f6bbbb76854..2950eb9cfd8 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -31,179 +31,179 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; class box_last_modified_ticket extends ModeleBoxes { - public $boxcode = "box_last_modified_ticket"; - public $boximg = "ticket"; - public $boxlabel; - public $depends = array("ticket"); + public $boxcode = "box_last_modified_ticket"; + public $boximg = "ticket"; + public $boxlabel; + public $depends = array("ticket"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + 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 $langs; + /** + * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $langs; $langs->load("boxes"); $this->db = $db; - $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedTicket"); - } + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedTicket"); + } - /** - * 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 $conf, $user, $langs; + /** + * 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 $conf, $user, $langs; - $this->max = $max; + $this->max = $max; - require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; + require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; - $text = $langs->trans("BoxLastModifiedTicketDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text) - ); + $text = $langs->trans("BoxLastModifiedTicketDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text) + ); - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("BoxLastModifiedTicketContent"), - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("BoxLastModifiedTicketContent"), + ); - 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 .= " 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"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + 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 .= " 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"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - $sql .= " WHERE t.entity = ".$conf->entity; - // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) { - $sql .= " AND t.fk_soc= ".$user->socid; - } + $sql .= " WHERE t.entity = ".$conf->entity; + // $sql.= " AND e.rowid = er.fk_event"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) { + $sql .= " AND t.fk_soc= ".$user->socid; + } - $sql .= " ORDER BY t.tms DESC, t.rowid DESC "; - $sql .= $this->db->plimit($max, 0); + $sql .= " ORDER BY t.tms DESC, t.rowid DESC "; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); - $i = 0; + $i = 0; - 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_cloture); - $late = ''; + 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_cloture); + $late = ''; - $ticket = new Ticket($this->db); - $ticket->id = $objp->id; - $ticket->track_id = $objp->track_id; - $ticket->ref = $objp->ref; - $ticket->fk_statut = $objp->fk_statut; - $ticket->subject = $objp->subject; - if ($objp->fk_soc > 0) { - $thirdparty = new Societe($this->db); - $thirdparty->id = $objp->fk_soc; - $thirdparty->email = $objp->socemail; - $thirdparty->client = $objp->client; - $thirdparty->fournisseur = $objp->fournisseur; - $thirdparty->name = $objp->company_name; - $link = $thirdparty->getNomUrl(1); - } else { - $link = dol_print_email($objp->origin_email); - } + $ticket = new Ticket($this->db); + $ticket->id = $objp->id; + $ticket->track_id = $objp->track_id; + $ticket->ref = $objp->ref; + $ticket->fk_statut = $objp->fk_statut; + $ticket->subject = $objp->subject; + if ($objp->fk_soc > 0) { + $thirdparty = new Societe($this->db); + $thirdparty->id = $objp->fk_soc; + $thirdparty->email = $objp->socemail; + $thirdparty->client = $objp->client; + $thirdparty->fournisseur = $objp->fournisseur; + $thirdparty->name = $objp->company_name; + $link = $thirdparty->getNomUrl(1); + } else { + $link = dol_print_email($objp->origin_email); + } - $r = 0; + $r = 0; - // Ticket - $this->info_box_contents[$i][0] = array( - 'td' => 'class="nowraponall"', - 'text' => $ticket->getNomUrl(1), - 'asis' => 1, - ); - $r++; + // Ticket + $this->info_box_contents[$i][0] = array( + 'td' => 'class="nowraponall"', + 'text' => $ticket->getNomUrl(1), + 'asis' => 1, + ); + $r++; - // Subject - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="nowrap"', - 'text' => $objp->subject, // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, - ); - $r++; + // Subject + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="nowrap"', + 'text' => $objp->subject, // Some event have no ref + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, + ); + $r++; - // Customer - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="tdoverflowmax150 maxwidth300onsmartphone"', - 'text' => $link, - 'asis' => 1, - ); - $r++; + // Customer + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="tdoverflowmax150 maxwidth300onsmartphone"', + 'text' => $link, + 'asis' => 1, + ); + $r++; - // Date creation - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'dayhour') - ); - $r++; + // Date creation + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'dayhour') + ); + $r++; - // Statut - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right nowraponall"', - 'text' => $ticket->getLibStatut(3) - ); - $r++; + // Statut + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right nowraponall"', + 'text' => $ticket->getLibStatut(3) + ); + $r++; - $i++; - } + $i++; + } - if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', '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"), - ); - } - } + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => 'class="center"', '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"), + ); + } + } - /** - * 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) - { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * 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) + { + parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 252141db9eb..9ada300901c 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -31,177 +31,177 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; class box_last_ticket extends ModeleBoxes { - public $boxcode = "box_last_ticket"; - public $boximg = "ticket"; - public $boxlabel; - public $depends = array("ticket"); + public $boxcode = "box_last_ticket"; + public $boximg = "ticket"; + public $boxlabel; + public $depends = array("ticket"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + 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 $langs; - $langs->load("boxes"); - $this->db = $db; + /** + * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $langs; + $langs->load("boxes"); + $this->db = $db; - $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastTicket"); - } + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastTicket"); + } - /** - * 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 $conf, $user, $langs; + /** + * 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 $conf, $user, $langs; - $this->max = $max; + $this->max = $max; - require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; + require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; - $text = $langs->trans("BoxLastTicketDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text), - ); + $text = $langs->trans("BoxLastTicketDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text), + ); - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("BoxLastTicketContent"), - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("BoxLastTicketContent"), + ); - 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 .= " 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"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + 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 .= " 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"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - $sql .= " WHERE t.entity = ".$conf->entity; - // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) { - $sql .= " AND t.fk_soc= ".$user->socid; - } + $sql .= " WHERE t.entity = ".$conf->entity; + // $sql.= " AND e.rowid = er.fk_event"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) { + $sql .= " AND t.fk_soc= ".$user->socid; + } - //$sql.= " AND t.fk_statut > 9"; + //$sql.= " AND t.fk_statut > 9"; - $sql .= " ORDER BY t.datec DESC, t.rowid DESC "; - $sql .= $this->db->plimit($max, 0); + $sql .= " ORDER BY t.datec DESC, t.rowid DESC "; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); - $i = 0; + $i = 0; - 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_cloture); - $late = ''; + 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_cloture); + $late = ''; - $ticket = new Ticket($this->db); - $ticket->id = $objp->id; - $ticket->track_id = $objp->track_id; - $ticket->ref = $objp->ref; - $ticket->fk_statut = $objp->fk_statut; - $ticket->subject = $objp->subject; - if ($objp->fk_soc > 0) { - $thirdparty = new Societe($this->db); - $thirdparty->id = $objp->fk_soc; - $thirdparty->email = $objp->socemail; - $thirdparty->client = $objp->client; - $thirdparty->fournisseur = $objp->fournisseur; - $thirdparty->name = $objp->company_name; - $link = $thirdparty->getNomUrl(1); - } else { - $link = dol_print_email($objp->origin_email); - } + $ticket = new Ticket($this->db); + $ticket->id = $objp->id; + $ticket->track_id = $objp->track_id; + $ticket->ref = $objp->ref; + $ticket->fk_statut = $objp->fk_statut; + $ticket->subject = $objp->subject; + if ($objp->fk_soc > 0) { + $thirdparty = new Societe($this->db); + $thirdparty->id = $objp->fk_soc; + $thirdparty->email = $objp->socemail; + $thirdparty->client = $objp->client; + $thirdparty->fournisseur = $objp->fournisseur; + $thirdparty->name = $objp->company_name; + $link = $thirdparty->getNomUrl(1); + } else { + $link = dol_print_email($objp->origin_email); + } - $r = 0; + $r = 0; - // Ticket - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="nowraponall"', - 'text' => $ticket->getNomUrl(1), - 'asis' => 1 - ); - $r++; + // Ticket + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="nowraponall"', + 'text' => $ticket->getNomUrl(1), + 'asis' => 1 + ); + $r++; - // Subject - $this->info_box_contents[$i][$r] = array( - 'td' => '', - 'text' => $objp->subject, // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, - ); - $r++; + // Subject + $this->info_box_contents[$i][$r] = array( + 'td' => '', + 'text' => $objp->subject, // Some event have no ref + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, + ); + $r++; - // Customer - $this->info_box_contents[$i][$r] = array( - 'td' => '', - 'text' => $link, - 'asis' => 1, - ); - $r++; + // Customer + $this->info_box_contents[$i][$r] = array( + 'td' => '', + 'text' => $link, + 'asis' => 1, + ); + $r++; - // Date creation - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'dayhour'), - ); - $r++; + // Date creation + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'dayhour'), + ); + $r++; - // Statut - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right nowraponall"', - 'text' => $ticket->getLibStatut(3), - ); - $r++; + // Statut + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right nowraponall"', + 'text' => $ticket->getLibStatut(3), + ); + $r++; - $i++; - } + $i++; + } - if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', '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")); - } - } + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => 'class="center"', '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")); + } + } - /** - * 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) - { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * 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) + { + parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index 6af4468c669..b45986387a8 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -30,75 +30,75 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_lastlogin extends ModeleBoxes { - public $boxcode = "lastlogin"; - public $boximg = "object_user"; - public $boxlabel = 'BoxLoginInformation'; - public $depends = array("user"); + public $boxcode = "lastlogin"; + public $boximg = "object_user"; + public $boxlabel = 'BoxLoginInformation'; + public $depends = array("user"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + 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; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $conf; - $this->db = $db; - } + $this->db = $db; + } - /** - * Charge les donnees en memoire pour affichage ulterieur - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Charge les donnees en memoire pour affichage ulterieur + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $textHead = $langs->trans("BoxLoginInformation"); - $this->info_box_head = array( - 'text' => $textHead, - 'limit'=> dol_strlen($textHead), - ); + $textHead = $langs->trans("BoxLoginInformation"); + $this->info_box_head = array( + 'text' => $textHead, + 'limit'=> dol_strlen($textHead), + ); - $line = 0; - $this->info_box_contents[$line][0] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $langs->trans("User"), - ); - $this->info_box_contents[$line][1] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $user->getNomUrl(-1), - 'asis' => 1 - ); + $line = 0; + $this->info_box_contents[$line][0] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $langs->trans("User"), + ); + $this->info_box_contents[$line][1] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $user->getNomUrl(-1), + 'asis' => 1 + ); - $line = 1; - $this->info_box_contents[$line][0] = array( - 'td' => '', - 'text' => $langs->trans("PreviousConnexion"), - ); - if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); - else $tmp = $langs->trans("Unknown"); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $tmp, - ); - } + $line = 1; + $this->info_box_contents[$line][0] = array( + 'td' => '', + 'text' => $langs->trans("PreviousConnexion"), + ); + if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); + else $tmp = $langs->trans("Unknown"); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $tmp, + ); + } /** @@ -109,8 +109,8 @@ class box_lastlogin extends ModeleBoxes * @param int $nooutput No print, only return string * @return void */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 2b2d8418e47..2d0ad45a266 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015 Frederic France + * 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 @@ -32,28 +32,28 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_members extends ModeleBoxes { - public $boxcode = "lastmembers"; - public $boximg = "object_user"; - public $boxlabel = "BoxLastMembers"; - public $depends = array("adherent"); + public $boxcode = "lastmembers"; + public $boximg = "object_user"; + public $boxlabel = "BoxLastMembers"; + public $depends = array("adherent"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -72,7 +72,7 @@ class box_members extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -81,15 +81,15 @@ class box_members extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic = new Adherent($this->db); + 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) - { + if ($user->rights->adherent->lire) { $sql = "SELECT a.rowid, 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"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE a.entity IN (".getEntity('member').")"; @@ -98,13 +98,11 @@ class box_members extends ModeleBoxes $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $line = 0; - while ($line < $num) - { + while ($line < $num) { $objp = $this->db->fetch_object($result); $datec = $this->db->jdate($objp->datec); $datem = $this->db->jdate($objp->tms); @@ -112,8 +110,13 @@ class box_members extends ModeleBoxes $memberstatic->lastname = $objp->lastname; $memberstatic->firstname = $objp->firstname; $memberstatic->id = $objp->rowid; - $memberstatic->ref = $objp->rowid; - $memberstatic->company = $objp->company; + $memberstatic->ref = $objp->rowid; + $memberstatic->photo = $objp->photo; + $memberstatic->gender = $objp->gender; + $memberstatic->email = $objp->email; + $memberstatic->morphy = $objp->morphy; + $memberstatic->company = $objp->company; + $memberstatic->statut = $objp->status; if (!empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; @@ -123,52 +126,52 @@ class box_members extends ModeleBoxes $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->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="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $memberstatic->company, + 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $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), - ); + $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++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedCustomers"), - ); + 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") - ); - } - } + $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 @@ -178,8 +181,8 @@ class box_members extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_mos.php b/htdocs/core/boxes/box_mos.php index ec21d5d00cf..dde8294f80b 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -32,143 +32,143 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_mos extends ModeleBoxes { - public $boxcode = "lastmos"; - public $boximg = "object_mrp"; - public $boxlabel = "BoxTitleLatestModifiedMos"; - public $depends = array("mrp"); + public $boxcode = "lastmos"; + public $boximg = "object_mrp"; + public $boxlabel = "BoxTitleLatestModifiedMos"; + public $depends = array("mrp"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bom->read); - } + $this->hidden = !($user->rights->bom->read); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $mostatic = new Mo($this->db); - $productstatic = new Product($this->db); - $userstatic = new User($this->db); + $mostatic = new Mo($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max)); - if ($user->rights->mrp->read) - { - $sql = "SELECT p.ref as product_ref"; - $sql .= ", c.rowid"; - $sql .= ", c.date_creation"; - $sql .= ", c.tms"; - $sql .= ", c.ref"; - $sql .= ", c.status"; - //$sql.= ", c.fk_user_valid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; - $sql .= " WHERE c.fk_product = p.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " ORDER BY c.tms DESC, c.ref DESC"; - $sql .= " ".$this->db->plimit($max, 0); + if ($user->rights->mrp->read) + { + $sql = "SELECT p.ref as product_ref"; + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; + //$sql.= ", c.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datem = $this->db->jdate($objp->tms); - $mostatic->id = $objp->rowid; - $mostatic->ref = $objp->ref; - $mostatic->id = $objp->socid; - $mostatic->status = $objp->status; - $productstatic->ref = $objp->product_ref; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem = $this->db->jdate($objp->tms); + $mostatic->id = $objp->rowid; + $mostatic->ref = $objp->ref; + $mostatic->id = $objp->socid; + $mostatic->status = $objp->status; + $productstatic->ref = $objp->product_ref; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $mostatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $mostatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $mostatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $mostatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $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") - ); - } - } + $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 @@ -178,8 +178,8 @@ class box_mos extends ModeleBoxes * @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); - } + 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_produits.php b/htdocs/core/boxes/box_produits.php index 52591fa5292..06808ab2518 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -33,20 +33,20 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits extends ModeleBoxes { - public $boxcode = "lastproducts"; - public $boximg = "object_product"; - public $boxlabel = "BoxLastProducts"; - public $depends = array("produit"); + public $boxcode = "lastproducts"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProducts"; + public $depends = array("produit"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -57,21 +57,21 @@ class box_produits extends ModeleBoxes */ public function __construct($db, $param) { - global $conf, $user; + global $conf, $user; - $this->db = $db; + $this->db = $db; - $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); - $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); - $this->hidden = ($showmode != 1); + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $this->hidden = ($showmode != 1); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -94,9 +94,9 @@ class box_produits extends ModeleBoxes // Add where from hooks if (is_object($hookmanager)) { - $parameters = array('boxproductlist'=>1); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; + $parameters = array('boxproductlist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } $sql .= $this->db->order('p.datec', 'DESC'); $sql .= $this->db->plimit($max, 0); @@ -128,33 +128,33 @@ class box_produits extends ModeleBoxes $objp->label = $objtp->label; } } - $productstatic->id = $objp->rowid; - $productstatic->ref = $objp->ref; - $productstatic->type = $objp->fk_product_type; - $productstatic->label = $objp->label; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->type = $objp->fk_product_type; + $productstatic->label = $objp->label; $productstatic->entity = $objp->entity; $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', - 'text' => $objp->label, - ); - $price = ''; - $price_base_type = ''; - if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { - $price_base_type = $langs->trans($objp->price_base_type); - $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); - } else //Parse the dynamic price - { + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'text' => $objp->label, + ); + $price = ''; + $price_base_type = ''; + if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); + } else //Parse the dynamic price + { $productstatic->fetch($objp->rowid, '', '', 1); - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProduct($productstatic); - if ($price_result >= 0) { + $priceparser = new PriceParser($this->db); + $price_result = $priceparser->parseProduct($productstatic); + if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { $price_base_type = $langs->trans("HT"); @@ -163,69 +163,69 @@ class box_produits extends ModeleBoxes $price_base_type = $langs->trans("TTC"); } $price = price($price_result); - } - } + } + } $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $price, - ); + 'td' => 'class="right"', + 'text' => $price, + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="nowrap"', - 'text' => $price_base_type, - ); + 'td' => 'class="nowrap"', + 'text' => $price_base_type, + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', - 'asis' => 1 - ); + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 1).'', - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 1).'', + 'asis' => 1 + ); - $line++; - } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedProducts"), - ); + $line++; + } + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProducts"), + ); - $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") - ); - } - } + $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); - } + /** + * 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_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 6845cb2db5f..893bb2273ab 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -35,20 +35,20 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits_alerte_stock extends ModeleBoxes { - public $boxcode = "productsalertstock"; - public $boximg = "object_product"; - public $boxlabel = "BoxProductsAlertStock"; - public $depends = array("produit"); + public $boxcode = "productsalertstock"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductsAlertStock"; + public $depends = array("produit"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -59,21 +59,21 @@ class box_produits_alerte_stock extends ModeleBoxes */ public function __construct($db, $param = '') { - global $conf, $user; + global $conf, $user; - $this->db = $db; + $this->db = $db; - $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); - $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); - $this->hidden = ($showmode != 1); + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $this->hidden = ($showmode != 1); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -99,16 +99,16 @@ class box_produits_alerte_stock extends ModeleBoxes if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; // Add where from hooks - if (is_object($hookmanager)) - { - $parameters = array('boxproductalertstocklist'=>1); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; - } - $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,"; - $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; - $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export"; - $sql .= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; + if (is_object($hookmanager)) + { + $parameters = array('boxproductalertstocklist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + } + $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,"; + $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; + $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export"; + $sql .= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; $sql .= $this->db->order('p.seuil_stock_alerte', 'DESC'); $sql .= $this->db->plimit($max, 0); @@ -118,11 +118,11 @@ class box_produits_alerte_stock extends ModeleBoxes $langs->load("stocks"); $num = $this->db->num_rows($result); $line = 0; - while ($line < $num) { + while ($line < $num) { $objp = $this->db->fetch_object($result); $datem = $this->db->jdate($objp->tms); - $price = ''; - $price_base_type = ''; + $price = ''; + $price_base_type = ''; // Multilangs if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active @@ -141,10 +141,10 @@ class box_produits_alerte_stock extends ModeleBoxes $objp->label = $objtp->label; } } - $productstatic->id = $objp->rowid; - $productstatic->ref = $objp->ref; - $productstatic->type = $objp->fk_product_type; - $productstatic->label = $objp->label; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->type = $objp->fk_product_type; + $productstatic->label = $objp->label; $productstatic->entity = $objp->entity; $productstatic->barcode = $objp->barcode; $productstatic->status = $objp->tosell; @@ -156,27 +156,27 @@ class box_produits_alerte_stock extends ModeleBoxes $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra; $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $objp->label, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $objp->label, + ); - if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) - { - $price_base_type = $langs->trans($objp->price_base_type); - $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); - } else //Parse the dynamic price - { + if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) + { + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); + } else //Parse the dynamic price + { $productstatic->fetch($objp->rowid, '', '', 1); - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProduct($productstatic); - if ($price_result >= 0) { + $priceparser = new PriceParser($this->db); + $price_result = $priceparser->parseProduct($productstatic); + if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { $price_base_type = $langs->trans("HT"); @@ -185,58 +185,58 @@ class box_produits_alerte_stock extends ModeleBoxes $price_base_type = $langs->trans("TTC"); } $price = price($price_result); - } - } - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => $price, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $price_base_type, - ); + } + } $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, - 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', - 'asis' => 1 + 'td' => 'class="right nowraponall"', + 'text' => $price, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 0).'', - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $price_base_type, + ); - $line++; - } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoTooLowStockProducts"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, + 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', + 'asis' => 1 + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 0).'', + 'asis' => 1 + ); + + $line++; + } + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoTooLowStockProducts"), + ); $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + '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") - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -248,8 +248,8 @@ class box_produits_alerte_stock extends ModeleBoxes * @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); + 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_project.php b/htdocs/core/boxes/box_project.php index e8b056322da..1afbdfc6837 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -31,174 +31,174 @@ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_project extends ModeleBoxes { - public $boxcode = "project"; - public $boximg = "object_projectpub"; - public $boxlabel; - //var $depends = array("projet"); + public $boxcode = "project"; + public $boximg = "object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user, $langs; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $user, $langs; - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); - $this->db = $db; - $this->boxlabel = "OpenedProjects"; + $this->db = $db; + $this->boxlabel = "OpenedProjects"; - $this->hidden = !($user->rights->projet->lire); - } + $this->hidden = !($user->rights->projet->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $this->max = $max; + $this->max = $max; - $totalMnt = 0; - $totalnb = 0; - $totalnbTask = 0; + $totalMnt = 0; + $totalnb = 0; + $totalnbTask = 0; - $textHead = $langs->trans("OpenedProjects"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $textHead = $langs->trans("OpenedProjects"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); - // list the summary of the orders - if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic = new Project($this->db); + // list the summary of the orders + if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); - $socid = 0; - //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. + $socid = 0; + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. - // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId = ''; - if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId = ''; + if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok $sql .= " AND p.fk_statut = 1"; // Only open projects - if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users - $sql .= " ORDER BY p.datec DESC"; - //$sql.= $this->db->plimit($max, 0); + $sql .= " ORDER BY p.datec DESC"; + //$sql.= $this->db->plimit($max, 0); - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < min($num, $max)) { - $objp = $this->db->fetch_object($result); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < min($num, $max)) { + $objp = $this->db->fetch_object($result); - $projectstatic->id = $objp->rowid; - $projectstatic->ref = $objp->ref; - $projectstatic->title = $objp->title; - $projectstatic->public = $objp->public; - $projectstatic->statut = $objp->status; + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->ref; + $projectstatic->title = $objp->title; + $projectstatic->public = $objp->public; + $projectstatic->statut = $objp->status; - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $projectstatic->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $objp->title, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $objp->title, + ); - $sql = "SELECT count(*) as nb, sum(progress) as totprogress"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; - $sql .= " WHERE p.entity IN (".getEntity('project').')'; - $sql .= " AND p.rowid = ".$objp->rowid; - $resultTask = $this->db->query($sql); - if ($resultTask) { - $objTask = $this->db->fetch_object($resultTask); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => $objTask->nb." ".$langs->trans("Tasks"), - ); - if ($objTask->nb > 0) - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => round($objTask->totprogress / $objTask->nb, 0)."%", - ); - else $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - $totalnbTask += $objTask->nb; - } else { - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - } - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); + $sql = "SELECT count(*) as nb, sum(progress) as totprogress"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; + $sql .= " WHERE p.entity IN (".getEntity('project').')'; + $sql .= " AND p.rowid = ".$objp->rowid; + $resultTask = $this->db->query($sql); + if ($resultTask) { + $objTask = $this->db->fetch_object($resultTask); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => $objTask->nb." ".$langs->trans("Tasks"), + ); + if ($objTask->nb > 0) + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => round($objTask->totprogress / $objTask->nb, 0)."%", + ); + else $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + $totalnbTask += $objTask->nb; + } else { + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + } + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); - $i++; - } - if ($max < $num) - { - $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); - $i++; - } - } - } + $i++; + } + if ($max < $num) + { + $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $i++; + } + } + } - // Add the sum à the bottom of the boxes - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => $langs->trans("Total")." ".$textHead, - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => round($num, 0)." ".$langs->trans("Projects"), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - } + // Add the sum à the bottom of the boxes + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total")." ".$textHead, + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => round($num, 0)." ".$langs->trans("Projects"), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + } - /** - * 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); - } + /** + * 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_propales.php b/htdocs/core/boxes/box_propales.php index 331ff54cb8d..bbfa2f6fb19 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -33,155 +33,155 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_propales extends ModeleBoxes { - public $boxcode = "lastpropals"; - public $boximg = "object_propal"; - public $boxlabel = "BoxLastProposals"; - public $depends = array("propal"); // conf->propal->enabled + public $boxcode = "lastpropals"; + public $boximg = "object_propal"; + public $boxlabel = "BoxLastProposals"; + public $depends = array("propal"); // conf->propal->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->propale->lire); - } + $this->hidden = !($user->rights->propale->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; + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $propalstatic = new Propal($this->db); - $societestatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $propalstatic = new Propal($this->db); + $societestatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."Propals", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."Propals", $max)); - if ($user->rights->propale->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; - $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY p.datep DESC, p.ref DESC "; - else $sql .= " ORDER BY p.tms DESC, p.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->propale->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; + $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY p.datep DESC, p.ref DESC "; + else $sql .= " ORDER BY p.tms DESC, p.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $now = dol_now(); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $now = dol_now(); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->dp); - $datec = $this->db->jdate($objp->datec); - $datem = $this->db->jdate($objp->tms); - $dateterm = $this->db->jdate($objp->fin_validite); - $dateclose = $this->db->jdate($objp->date_cloture); - $propalstatic->id = $objp->rowid; - $propalstatic->ref = $objp->ref; - $propalstatic->total_ht = $objp->total_ht; - $propalstatic->total_tva = $objp->total_tva; - $propalstatic->total_ttc = $objp->total_ttc; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; - $societestatic->email = $objp->email; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->dp); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); + $propalstatic->id = $objp->rowid; + $propalstatic->ref = $objp->ref; + $propalstatic->total_ht = $objp->total_ht; + $propalstatic->total_tva = $objp->total_tva; + $propalstatic->total_ttc = $objp->total_ttc; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; + $societestatic->email = $objp->email; $societestatic->entity = $objp->entity; - $late = ''; - if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { - $late = img_warning($langs->trans("Late")); - } + $late = ''; + if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { + $late = img_warning($langs->trans("Late")); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $propalstatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $propalstatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $propalstatic->LibStatut($objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $propalstatic->LibStatut($objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedProposals"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProposals"), + ); - $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") - ); - } - } + $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 @@ -191,8 +191,8 @@ class box_propales extends ModeleBoxes * @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); - } + 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_prospect.php b/htdocs/core/boxes/box_prospect.php index 1024ef1d4ec..10a8698aaf9 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -34,27 +34,27 @@ include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; */ class box_prospect extends ModeleBoxes { - public $boxcode = "lastprospects"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastProspects"; - public $depends = array("societe"); + public $boxcode = "lastprospects"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastProspects"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -72,7 +72,7 @@ class box_prospect extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -88,10 +88,10 @@ class box_prospect extends ModeleBoxes { $sql = "SELECT s.nom as name, s.rowid as socid"; $sql .= ", s.code_client"; - $sql .= ", s.client, s.email"; - $sql .= ", s.code_fournisseur"; - $sql .= ", s.fournisseur"; - $sql .= ", s.logo"; + $sql .= ", s.client, s.email"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.logo"; $sql .= ", s.fk_stcomm, s.datec, s.tms, s.status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -115,58 +115,58 @@ class box_prospect extends ModeleBoxes $datec = $this->db->jdate($objp->datec); $datem = $this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => str_replace('img ', 'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => str_replace('img ', 'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=> $langs->trans("NoRecordedProspects"), - ); - } + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=> $langs->trans("NoRecordedProspects"), + ); + } - $this->db->free($resql); - } 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") - ); + $this->db->free($resql); + } 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") + ); } } @@ -178,8 +178,8 @@ class box_prospect extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + 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_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index d528a4d68ca..c4a713a03b5 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_services_contracts extends ModeleBoxes { - public $boxcode = "lastproductsincontract"; - public $boximg = "object_product"; - public $boxlabel = "BoxLastProductsInContract"; - public $depends = array("service", "contrat"); + public $boxcode = "lastproductsincontract"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProductsInContract"; + public $depends = array("service", "contrat"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,18 +56,18 @@ class box_services_contracts extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); + $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -83,15 +83,15 @@ class box_services_contracts extends ModeleBoxes if ($user->rights->service->lire && $user->rights->contrat->lire) { - $contractstatic = new Contrat($this->db); - $contractlinestatic = new ContratLigne($this->db); - $thirdpartytmp = new Societe($this->db); - $productstatic = new Product($this->db); + $contractstatic = new Contrat($this->db); + $contractlinestatic = new ContratLigne($this->db); + $thirdpartytmp = new Societe($this->db); + $productstatic = new Product($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 contract_status, c.ref_customer, c.ref_supplier,"; $sql .= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut as contractline_status, cd.product_type as type, cd.date_fin_validite as date_line,"; - $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity, p.tobuy, p.tosell"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as product_type, p.entity, p.tobuy, p.tosell"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; @@ -125,6 +125,7 @@ class box_services_contracts extends ModeleBoxes $contractlinestatic->type = $objp->type; $contractlinestatic->product_id = $objp->product_id; $contractlinestatic->product_ref = $objp->product_ref; + $contractlinestatic->product_type = $objp->product_type; $contractlinestatic->statut = $objp->contractline_status; $contractstatic->id = $objp->rowid; @@ -150,27 +151,27 @@ class box_services_contracts extends ModeleBoxes if ($objp->product_id > 0) { $productstatic->id = $objp->product_id; - $productstatic->type = $objp->ptype; + $productstatic->type = $objp->product_type; $productstatic->ref = $objp->product_ref; $productstatic->entity = $objp->pentity; - $productstatic->label = $objp->plabel; + $productstatic->label = $objp->product_label; $productstatic->status = $objp->tosell; $productstatic->status_buy = $objp->tobuy; $text = $productstatic->getNomUrl(1, '', 20); - if ($objp->plabel) + if ($objp->product_label) { $text .= ' - '; //$productstatic->ref=$objp->label; //$text .= $productstatic->getNomUrl(0,'',16); - $text .= $objp->plabel; + $text .= $objp->product_label; } $description = $objp->description; // Add description in form if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - //$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'
    '.dol_htmlentitiesbr($objp->description):''; + //$text .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'
    '.dol_htmlentitiesbr($objp->description):''; $description = ''; // Already added into main visible desc } @@ -181,31 +182,31 @@ class box_services_contracts extends ModeleBoxes $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $s, - 'asis' => 1 - ); + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $s, + 'asis' => 1 + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contractstatic->getNomUrl(1), - 'asis' => 1 - ); + 'td' => 'class="nowraponall"', + 'text' => $contractstatic->getNomUrl(1), + 'asis' => 1 + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1), - 'asis' => 1 - ); + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1), + 'asis' => 1 + ); $this->info_box_contents[$i][] = array( - 'td' => '', - 'text' => dol_print_date($datem, 'day'), + 'td' => '', + 'text' => dol_print_date($datem, 'day'), 'text2'=> $late, - ); + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="right" width="18"', + 'td' => 'class="right" width="18"', 'text' => $contractlinestatic->getLibStatut(3) ); @@ -219,15 +220,15 @@ class box_services_contracts extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength' => 500, - 'text' => ($this->db->error().' sql='.$sql), - ); + '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") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -240,8 +241,8 @@ class box_services_contracts extends ModeleBoxes * @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); - } + 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_services_expired.php b/htdocs/core/boxes/box_services_expired.php index d7b3433f6d2..7a65fd0a9d2 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -30,160 +30,160 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_services_expired extends ModeleBoxes { - public $boxcode = "expiredservices"; // id of box - public $boximg = "object_contract"; - public $boxlabel = "BoxOldestExpiredServices"; - public $depends = array("contrat"); // conf->propal->enabled + public $boxcode = "expiredservices"; // id of box + public $boximg = "object_contract"; + public $boxlabel = "BoxOldestExpiredServices"; + public $depends = array("contrat"); // conf->propal->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->contrat->lire); - } + $this->hidden = !($user->rights->contrat->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $now = dol_now(); + $now = dol_now(); - $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); - if ($user->rights->contrat->lire) - { - // Select contracts with at least one expired service + if ($user->rights->contrat->lire) + { + // Select contracts with at least one expired service $sql = "SELECT "; - $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; $sql .= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; - $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; - if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; - $sql .= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; - $sql .= " ORDER BY date_line ASC"; - $sql .= $this->db->plimit($max, 0); + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; + if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; + $sql .= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; + $sql .= " ORDER BY date_line ASC"; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); - $i = 0; + $i = 0; - $thirdpartytmp = new Societe($this->db); - $contract = new Contrat($this->db); + $thirdpartytmp = new Societe($this->db); + $contract = new Contrat($this->db); - while ($i < $num) - { - $late = ''; + while ($i < $num) + { + $late = ''; - $objp = $this->db->fetch_object($resql); + $objp = $this->db->fetch_object($resql); - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->client = $objp->client; - $thirdpartytmp->fournisseur = $objp->fournisseur; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->code_compta = $objp->code_compta; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - $contract->id = $objp->rowid; - $contract->ref = $objp->ref; - $contract->statut = $objp->fk_statut; - $contract->ref_customer = $objp->ref_customer; - $contract->ref_supplier = $objp->ref_supplier; + $contract->id = $objp->rowid; + $contract->ref = $objp->ref; + $contract->statut = $objp->fk_statut; + $contract->ref_customer = $objp->ref_customer; + $contract->ref_supplier = $objp->ref_supplier; $dateline = $this->db->jdate($objp->date_line); if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contract->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $contract->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone left"', - 'text' => $thirdpartytmp->getNomUrl(1, 'customer'), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone left"', + 'text' => $thirdpartytmp->getNomUrl(1, 'customer'), + 'asis' => 1 + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($dateline, 'day'), - 'text2'=> $late, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center nowraponall"', + 'text' => dol_print_date($dateline, 'day'), + 'text2'=> $late, + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => $objp->nb_services, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => $objp->nb_services, + ); - $i++; - } + $i++; + } - if ($num == 0) - { - $langs->load("contracts"); - $this->info_box_contents[$i][] = array( - 'td' => 'class="nohover opacitymedium center"', - 'text' => $langs->trans("NoExpiredServices"), - ); - } + if ($num == 0) + { + $langs->load("contracts"); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nohover opacitymedium center"', + 'text' => $langs->trans("NoExpiredServices"), + ); + } $this->db->free($resql); - } else { - $this->info_box_contents[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") - ); - } - } + } else { + $this->info_box_contents[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 @@ -193,8 +193,8 @@ class box_services_expired extends ModeleBoxes * @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); - } + 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_shipments.php b/htdocs/core/boxes/box_shipments.php index 8574b7ce01b..1b3c865f5a1 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -32,152 +32,152 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_shipments extends ModeleBoxes { - public $boxcode = "lastcustomershipments"; - public $boximg = "sending"; - public $boxlabel = "BoxLastCustomerShipments"; - public $depends = array("expedition"); + public $boxcode = "lastcustomershipments"; + public $boximg = "sending"; + public $boxlabel = "BoxLastCustomerShipments"; + public $depends = array("expedition"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->expedition->lire); - } + $this->hidden = !($user->rights->expedition->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; - $langs->loadLangs(array('orders', 'sendings')); + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->loadLangs(array('orders', 'sendings')); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $shipmentstatic = new Expedition($this->db); - $orderstatic = new Commande($this->db); - $societestatic = new Societe($this->db); + $shipmentstatic = new Expedition($this->db); + $orderstatic = new Commande($this->db); + $societestatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max)); - if ($user->rights->expedition->lire) - { - $sql = "SELECT s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client"; - $sql .= ", s.logo, s.email"; - $sql .= ", e.ref, e.tms"; - $sql .= ", e.rowid"; - $sql .= ", e.ref_customer"; - $sql .= ", e.fk_statut"; - $sql .= ", e.fk_user_valid"; - $sql .= ", c.ref as commande_ref"; - $sql .= ", c.rowid as commande_id"; - $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; - $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; - if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id; - else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->expedition->lire) + { + $sql = "SELECT s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", e.ref, e.tms"; + $sql .= ", e.rowid"; + $sql .= ", e.ref_customer"; + $sql .= ", e.fk_statut"; + $sql .= ", e.fk_user_valid"; + $sql .= ", c.ref as commande_ref"; + $sql .= ", c.rowid as commande_id"; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id; + else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $shipmentstatic->id = $objp->rowid; - $shipmentstatic->ref = $objp->ref; - $shipmentstatic->ref_customer = $objp->ref_customer; + $shipmentstatic->id = $objp->rowid; + $shipmentstatic->ref = $objp->ref; + $shipmentstatic->ref_customer = $objp->ref_customer; - $orderstatic->id = $objp->commande_id; - $orderstatic->ref = $objp->commande_ref; + $orderstatic->id = $objp->commande_id; + $orderstatic->ref = $objp->commande_ref; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->email = $objp->email; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $shipmentstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $shipmentstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $orderstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $orderstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedShipments") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedShipments") + ); - $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") - ); - } - } + $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 @@ -187,8 +187,8 @@ class box_shipments extends ModeleBoxes * @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); - } + 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_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index cdc1dd51440..6c5dd4379d3 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -31,160 +31,160 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_supplier_orders extends ModeleBoxes { - public $boxcode = "latestsupplierorders"; - public $boximg = "object_order"; - public $boxlabel = "BoxLatestSupplierOrders"; - public $depends = array("fournisseur"); + public $boxcode = "latestsupplierorders"; + public $boximg = "object_order"; + public $boxlabel = "BoxLatestSupplierOrders"; + public $depends = array("fournisseur"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->commande->lire); - } + $this->hidden = !($user->rights->fournisseur->commande->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 $conf, $user, $langs; - $langs->load("boxes"); + /** + * 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 $conf, $user, $langs; + $langs->load("boxes"); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic = new CommandeFournisseur($this->db); - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp = new Fournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $supplierorderstatic = new CommandeFournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $thirdpartytmp = new Fournisseur($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); - if ($user->rights->fournisseur->commande->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql .= " s.code_client, s.code_fournisseur,"; - $sql .= " s.logo, s.email,"; - $sql .= " c.rowid, c.ref, c.tms, c.date_commande,"; - $sql .= " c.total_ht,"; - $sql .= " c.tva as total_tva,"; - $sql .= " c.total_ttc,"; - $sql .= " c.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->fournisseur->commande->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql .= " s.code_client, s.code_fournisseur,"; + $sql .= " s.logo, s.email,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande,"; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); - $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_commande); + $line = 0; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_commande); $datem = $this->db->jdate($objp->tms); $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->fournisseur = 1; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->logo = $objp->logo; - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $supplierorderstatic->getNomUrl(1), - 'asis' => 1 - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + 'td' => 'class="nowraponall"', + 'text' => $supplierorderstatic->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); - $line++; - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - if ($num == 0) - $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $langs->trans("NoSupplierOrder"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3), + ); - /** - * 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); - } + $line++; + } + + if ($num == 0) + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $langs->trans("NoSupplierOrder"), + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[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_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 54b8955d519..57656915d62 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -31,166 +31,167 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_supplier_orders_awaiting_reception extends ModeleBoxes { - public $boxcode = "supplierordersawaitingreception"; - public $boximg = "object_order"; - public $boxlabel = "BoxLatestSupplierOrdersAwaitingReception"; - public $depends = array("fournisseur"); + public $boxcode = "supplierordersawaitingreception"; + public $boximg = "object_order"; + public $boxlabel = "BoxLatestSupplierOrdersAwaitingReception"; + public $depends = array("fournisseur"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + 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 $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->commande->lire); - } + $this->hidden = !($user->rights->fournisseur->commande->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 $conf, $user, $langs; - $langs->loadLangs(array("boxes", "sendings", "orders")); + /** + * 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 $conf, $user, $langs; + $langs->loadLangs(array("boxes", "sendings", "orders")); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic = new CommandeFournisseur($this->db); - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp = new Fournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $supplierorderstatic = new CommandeFournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $thirdpartytmp = new Fournisseur($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleSupplierOrdersAwaitingReception", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleSupplierOrdersAwaitingReception", $max)); - if ($user->rights->fournisseur->commande->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql .= " s.code_client, s.code_fournisseur, s.email,"; - $sql .= " s.logo,"; - $sql .= " c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison, "; - $sql .= " c.total_ht,"; - $sql .= " c.tva as total_tva,"; - $sql .= " c.total_ttc,"; - $sql .= " c.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; - $sql .= " AND c.fk_statut = ".CommandeFournisseur::STATUS_ORDERSENT; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql .= " ORDER BY c.date_livraison ASC, c.fk_statut ASC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->fournisseur->commande->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql .= " s.code_client, s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison as delivery_date, "; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; + $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC"; + else $sql .= " ORDER BY c.date_livraison ASC, c.fk_statut ASC"; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); - $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_commande); - $date_livraison = $this->db->jdate($objp->date_livraison); + $line = 0; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_commande); + $delivery_date = $this->db->jdate($objp->delivery_date); $datem = $this->db->jdate($objp->tms); - $supplierorderstatic->date_livraison = $date_livraison; - $supplierorderstatic->statut = $objp->fk_statut; + $supplierorderstatic->date_livraison = $delivery_date; + $supplierorderstatic->delivery_date = $delivery_date; + $supplierorderstatic->statut = $objp->fk_statut; $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->fournisseur = 1; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $supplierorderstatic->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $supplierorderstatic->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $delayIcon = ''; - if ($supplierorderstatic->hasDelay()) { - $delayIcon = img_warning($langs->trans("Late")); - } + $delayIcon = ''; + if ($supplierorderstatic->hasDelay()) { + $delayIcon = img_warning($langs->trans("Late")); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $delayIcon.' '.dol_print_date($date_livraison, 'day').'', - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $delayIcon.' '.dol_print_date($delivery_date, 'day').'', + 'asis' => 1 + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $langs->trans("NoSupplierOrder"), - ); + if ($num == 0) + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $langs->trans("NoSupplierOrder"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[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); - } + /** + * 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_task.php b/htdocs/core/boxes/box_task.php index c1d728eb667..f2bfd523d75 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -1,6 +1,6 @@ - * Copyright (C) 2015-2019 Frederic France +/* Copyright (C) 2012-2018 Charlene BENKE + * 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 @@ -31,41 +31,41 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; */ class box_task extends ModeleBoxes { - public $boxcode = "projettask"; - public $boximg = "object_projecttask"; - public $boxlabel; - public $depends = array("projet"); + public $boxcode = "projettask"; + public $boximg = "object_projecttask"; + public $boxlabel; + public $depends = array("projet"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; // enable because fixed ;-). + public $param; + public $enabled = 1; // enable because fixed ;-). - public $info_box_head = array(); - public $info_box_contents = array(); + 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, $langs; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user, $langs; - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); - $this->boxlabel = "Tasks"; - $this->db = $db; + $this->boxlabel = "Tasks"; + $this->db = $db; - $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || !($user->rights->projet->lire)); - } + $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || !($user->rights->projet->lire)); + } /** * Load data for box to show them later @@ -80,93 +80,93 @@ class box_task extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT."/projet/class/task.class.php"; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"; - $projectstatic = new Project($this->db); + require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"; + $projectstatic = new Project($this->db); $taskstatic = new Task($this->db); $form = new Form($this->db); - $cookie_name = 'DOLUSERCOOKIE_boxfilter_task'; - $boxcontent = ''; - $socid = $user->socid; + $cookie_name = 'DOLUSERCOOKIE_boxfilter_task'; + $boxcontent = ''; + $socid = $user->socid; - $textHead = $langs->trans("CurentlyOpenedTasks"); + $textHead = $langs->trans("CurentlyOpenedTasks"); - $filterValue = 'all'; - if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) { - $filterValue = GETPOST($cookie_name); - } elseif (!empty($_COOKIE[$cookie_name])) { - $filterValue = preg_replace('/[^a-z_]/', '', $_COOKIE[$cookie_name]); // Clean cookie from evil data - } + $filterValue = 'all'; + if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) { + $filterValue = GETPOST($cookie_name); + } elseif (!empty($_COOKIE[$cookie_name])) { + $filterValue = preg_replace('/[^a-z_]/', '', $_COOKIE[$cookie_name]); // Clean cookie from evil data + } - if ($filterValue == 'im_task_contact') { - $textHead .= ' : '.$langs->trans("WhichIamLinkedTo"); - } elseif ($filterValue == 'im_project_contact') { - $textHead .= ' : '.$langs->trans("WhichIamLinkedToProject"); - } + if ($filterValue == 'im_task_contact') { + $textHead .= ' : '.$langs->trans("WhichIamLinkedTo"); + } elseif ($filterValue == 'im_project_contact') { + $textHead .= ' : '.$langs->trans("WhichIamLinkedToProject"); + } $this->info_box_head = array( - 'text' => $textHead, - 'limit'=> dol_strlen($textHead), - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" - ); + 'text' => $textHead, + 'limit'=> dol_strlen($textHead), + 'sublink'=>'', + 'subtext'=>$langs->trans("Filter"), + 'subpicto'=>'filter.png', + 'subclass'=>'linkobject boxfilter', + 'target'=>'none' // Set '' to get target="_blank" + ); // list the summary of the orders if ($user->rights->projet->lire) { - $boxcontent .= '
    '."\n"; - $boxcontent .= '
    '."\n"; - $boxcontent .= '
    boxcode.'">'."\n"; - $boxcontent .= ''."\n"; - $selectArray = array('all' => $langs->trans("NoFilter"), 'im_task_contact' => $langs->trans("WhichIamLinkedTo"), 'im_project_contact' => $langs->trans("WhichIamLinkedToProject")); - $boxcontent .= $form->selectArray($cookie_name, $selectArray, $filterValue); - $boxcontent .= ''; - $boxcontent .= '
    '."\n"; - $boxcontent .= '
    '."\n"; - if (!empty($conf->use_javascript_ajax)) { - $boxcontent .= ''; - // set cookie by js - $boxcontent .= ''; - } - $this->info_box_contents[0][] = array( - 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', - 'td' => 'class="nohover"', - 'textnoformat' => $boxcontent, - ); + // set cookie by js + $boxcontent .= ''; + } + $this->info_box_contents[0][] = array( + 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', + 'td' => 'class="nohover"', + 'textnoformat' => $boxcontent, + ); - // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId = ''; - if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId = ''; + if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; + $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; $sql .= ", p.rowid project_id, p.ref project_ref, p.title project_title"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; $sql .= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)"; - if ($filterValue === 'im_task_contact') { - $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = ".((int) $user->id).")"; - $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )"; - } elseif ($filterValue === 'im_project_contact') { - $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = ".((int) $user->id).")"; - $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )"; - } + if ($filterValue === 'im_task_contact') { + $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = ".((int) $user->id).")"; + $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )"; + } elseif ($filterValue === 'im_project_contact') { + $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = ".((int) $user->id).")"; + $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )"; + } $sql .= " WHERE "; $sql .= " pt.entity = ".$conf->entity; $sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED; $sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed - $sql .= " AND p.usage_task = 1 "; - if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + $sql .= " AND p.usage_task = 1 "; + if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users $sql .= " ORDER BY pt.datee ASC, pt.dateo ASC"; $sql .= $this->db->plimit($max, 0); @@ -175,33 +175,33 @@ class box_task extends ModeleBoxes $i = 1; if ($result) { $num = $this->db->num_rows($result); - while ($objp = $this->db->fetch_object($result)) { - $taskstatic->id = $objp->rowid; - $taskstatic->ref = $objp->ref; - $taskstatic->label = $objp->label; - $taskstatic->progress = $objp->progress; - $taskstatic->fk_statut = $objp->fk_statut; - $taskstatic->date_end = $objp->datee; - $taskstatic->planned_workload = $objp->planned_workload; - $taskstatic->duration_effective = $objp->duration_effective; + while ($objp = $this->db->fetch_object($result)) { + $taskstatic->id = $objp->rowid; + $taskstatic->ref = $objp->ref; + $taskstatic->label = $objp->label; + $taskstatic->progress = $objp->progress; + $taskstatic->fk_statut = $objp->fk_statut; + $taskstatic->date_end = $this->db->jdate($objp->datee); + $taskstatic->planned_workload = $objp->planned_workload; + $taskstatic->duration_effective = $objp->duration_effective; - $projectstatic->id = $objp->project_id; - $projectstatic->ref = $objp->project_ref; - $projectstatic->title = $objp->project_title; + $projectstatic->id = $objp->project_id; + $projectstatic->ref = $objp->project_ref; + $projectstatic->title = $objp->project_title; - $label = $projectstatic->getNomUrl(1).'   '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); + $label = $projectstatic->getNomUrl(1).'   '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); - $boxcontent = getTaskProgressView($taskstatic, $label, true, false, false); + $boxcontent = getTaskProgressView($taskstatic, $label, true, false, false); - $this->info_box_contents[$i][] = array( - 'td' => '', - 'text' => $boxcontent, - ); + $this->info_box_contents[$i][] = array( + 'td' => '', + 'text' => $boxcontent, + ); $i++; } } else { - dol_print_error($this->db); - } + dol_print_error($this->db); + } } } diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index b4eddf5f18d..537e88b9bdf 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -31,95 +31,95 @@ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_validated_projects extends ModeleBoxes { - public $boxcode="validated_project"; - public $boximg="object_projectpub"; - public $boxlabel; - //var $depends = array("projet"); + public $boxcode = "validated_project"; + public $boximg = "object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - public $enabled = 1; + public $enabled = 1; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $conf, $user, $langs; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user, $langs; - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); - $this->db = $db; - $this->boxlabel = "ProjectsWithTask"; + $this->db = $db; + $this->boxlabel = "ProjectsWithTask"; - $this->hidden = ! ($user->rights->projet->lire); + $this->hidden = !($user->rights->projet->lire); if ($conf->global->MAIN_FEATURES_LEVEL < 2) $this->enabled = 0; - } + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $totalMnt = 0; - $totalnb = 0; - $totalnbTask=0; + $totalMnt = 0; + $totalnb = 0; + $totalnbTask = 0; - $textHead = $langs->trans("ProjectTasksWithoutTimeSpent"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $textHead = $langs->trans("ProjectTasksWithoutTimeSpent"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); - // list the summary of the orders - if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic = new Project($this->db); + // list the summary of the orders + if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); - $socid=0; - //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. + $socid = 0; + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. - // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId=''; - if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId = ''; + if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - // I tried to solve sql error and performance problem, rewriting sql request but it is not clear what we want. - // Count of tasks without time spent for tasks we are assigned too or - // Count of tasks without time spent for all tasks of projects we are allowed to read (what it does) ? - $sql = "SELECT p.rowid, p.ref, p.fk_soc, p.dateo as startdate,"; - $sql.= " COUNT(DISTINCT t.rowid) as tasknumber"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; - // TODO Replace -1, -2, -3 with ID used for type of contat project_task into llx_c_type_contact. Once done, we can switch widget as stable. - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid AND fk_c_type_contact IN (-1, -2, -3)"; - $sql.= " WHERE p.fk_statut = 1"; // Only open projects - if ($projectsListId) $sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only project we ara allowed - $sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")"; - $sql.= " GROUP BY p.rowid, p.ref, p.fk_soc, p.dateo"; - $sql.= " ORDER BY p.dateo ASC"; + // I tried to solve sql error and performance problem, rewriting sql request but it is not clear what we want. + // Count of tasks without time spent for tasks we are assigned too or + // Count of tasks without time spent for all tasks of projects we are allowed to read (what it does) ? + $sql = "SELECT p.rowid, p.ref, p.fk_soc, p.dateo as startdate,"; + $sql .= " COUNT(DISTINCT t.rowid) as tasknumber"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet AS p"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; + // TODO Replace -1, -2, -3 with ID used for type of contat project_task into llx_c_type_contact. Once done, we can switch widget as stable. + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid AND fk_c_type_contact IN (-1, -2, -3)"; + $sql .= " WHERE p.fk_statut = 1"; // Only open projects + if ($projectsListId) $sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only project we ara allowed + $sql .= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")"; + $sql .= " GROUP BY p.rowid, p.ref, p.fk_soc, p.dateo"; + $sql .= " ORDER BY p.dateo ASC"; - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', 'text' => "Reference projet", @@ -138,67 +138,67 @@ class box_validated_projects extends ModeleBoxes ); $i++; - while ($i < min($num+1, $max+1)) { - $objp = $this->db->fetch_object($result); + while ($i < min($num + 1, $max + 1)) { + $objp = $this->db->fetch_object($result); - $projectstatic->id = $objp->rowid; - $projectstatic->ref = $objp->ref; + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->ref; - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $projectstatic->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 + ); - if ($objp->fk_soc > 0) { - $sql = 'SELECT rowid, nom as name FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->fk_soc; - $resql = $this->db->query($sql); - //$socstatic = new Societe($this->db); - $obj2 = $this->db->fetch_object($resql); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $obj2->name, - 'asis' => 1, - 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj2->rowid - ); - } - else { - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => '', - 'asis' => 1, - 'url' => '' - ); - } + if ($objp->fk_soc > 0) { + $sql = 'SELECT rowid, nom as name FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->fk_soc; + $resql = $this->db->query($sql); + //$socstatic = new Societe($this->db); + $obj2 = $this->db->fetch_object($resql); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $obj2->name, + 'asis' => 1, + 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj2->rowid + ); + } + else { + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => '', + 'asis' => 1, + 'url' => '' + ); + } - $this->info_box_contents[$i][] = array( - 'td' => 'class="center"', - 'text' => $objp->startDate, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => $objp->startDate, + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="center"', - 'text' => $objp->tasknumber." ".$langs->trans("Tasks"), + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => $objp->tasknumber." ".$langs->trans("Tasks"), 'asis' => 1, - ); - $i++; - } - }else { - dol_print_error($this->db); + ); + $i++; + } + } else { + dol_print_error($this->db); } - } - } + } + } - /** - * 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); - } + /** + * 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/intracommreport_box.php b/htdocs/core/boxes/intracommreport_box.php index 1df09500173..d7c383138b6 100644 --- a/htdocs/core/boxes/intracommreport_box.php +++ b/htdocs/core/boxes/intracommreport_box.php @@ -22,7 +22,7 @@ * \brief This file is a sample box definition file * Put some comments here */ -include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; +include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box @@ -30,59 +30,59 @@ include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; class intracommreportbox extends ModeleBoxes { - public $boxcode = "mybox"; - public $boximg = "intracommreport"; - public $boxlabel; - public $depends = array("intracommreport"); - public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "mybox"; + public $boximg = "intracommreport"; + public $boxlabel; + public $depends = array("intracommreport"); + public $db; + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - */ - public function __construct() - { - global $langs; - $langs->load("boxes"); + /** + * Constructor + */ + public function __construct() + { + global $langs; + $langs->load("boxes"); - $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); - } + $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); + } - /** - * 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 $conf, $user, $langs, $db; + /** + * 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 $conf, $user, $langs, $db; - $this->max = $max; + $this->max = $max; - //include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php"; + //include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php"; - $text = $langs->trans("MyBoxDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text) - ); + $text = $langs->trans("MyBoxDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text) + ); - $this->info_box_contents[0][0] = array('td' => 'align="left"', - 'text' => $langs->trans("MyBoxContent")); - } + $this->info_box_contents[0][0] = array('td' => 'align="left"', + 'text' => $langs->trans("MyBoxContent")); + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @return void - */ - public function showBox($head = null, $contents = null) - { - parent::showBox($this->info_box_head, $this->info_box_contents); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @return void + */ + public function showBox($head = null, $contents = null) + { + parent::showBox($this->info_box_head, $this->info_box_contents); + } } diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index fd179dec7b6..2ac7ee05c6b 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -113,7 +113,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -156,7 +156,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box if ($obj) { $this->id = $obj->id; - $this->rowid = $obj->id; // For backward compatibility + $this->rowid = $obj->id; // For backward compatibility $this->box_id = $obj->box_id; $this->position = $obj->position; $this->box_order = $obj->box_order; @@ -184,180 +184,180 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box if (!empty($this->hidden)) return '\n\n'; // Nothing done if hidden (for example when user has no permission) - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $MAXLENGTHBOX = 60; // Mettre 0 pour pas de limite - $cachetime = 900; // 900 : 15mn - $cachedir = DOL_DATA_ROOT.'/boxes/temp'; - $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'.cache'; - $filename = '/box-'.$fileid; - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $out = ''; + $cachetime = 900; // 900 : 15mn + $cachedir = DOL_DATA_ROOT.'/boxes/temp'; + $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'.cache'; + $filename = '/box-'.$fileid; + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $out = ''; - if ($refresh) { - dol_syslog(get_class($this).'::showBox'); + if ($refresh) { + dol_syslog(get_class($this).'::showBox'); - // Define nbcol and nblines of the box to show - $nbcol = 0; - if (isset($contents[0])) $nbcol = count($contents[0]); - $nblines = count($contents); + // Define nbcol and nblines of the box to show + $nbcol = 0; + if (isset($contents[0])) $nbcol = count($contents[0]); + $nblines = count($contents); - $out .= "\n\n"; + $out .= "\n\n"; - $out .= '
    '."\n"; + $out .= '
    '."\n"; - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) - { - $out .= ''."\n"; - } + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) + { + $out .= '
    '."\n"; + } - // Show box title - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) - { - $out .= ''; - $out .= ' 0) { $out .= ' colspan="'.$nbcol.'"'; } - $out .= '>'; - if (!empty($conf->use_javascript_ajax)) - { - //$out.= '
    '; + // Show box title + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) + { + $out .= ''; + $out .= ' 0) { $out .= ' colspan="'.$nbcol.'"'; } + $out .= '>'; + if (!empty($conf->use_javascript_ajax)) + { + //$out.= '
    '; - $out .= '
    '; - } - if (!empty($head['text'])) - { - $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX); - $out .= $s; - } - if (!empty($conf->use_javascript_ajax)) - { - $out .= '
    '; - } - //$out.= '
    '; - if (!empty($conf->use_javascript_ajax)) - { - $sublink = ''; - if (!empty($head['sublink'])) $sublink .= ''; - if (!empty($head['subpicto'])) $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); - if (!empty($head['sublink'])) $sublink .= ''; + if (!empty($conf->use_javascript_ajax)) + { + $sublink = ''; + if (!empty($head['sublink'])) $sublink .= ''; + if (!empty($head['subpicto'])) $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); + if (!empty($head['sublink'])) $sublink .= ''; - //$out.= '
    '; + $out .= '
    '; + } + if (!empty($head['text'])) + { + $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX); + $out .= $s; + } + if (!empty($conf->use_javascript_ajax)) + { + $out .= '
    '; + } + //$out.= '
    '; - $out .= '
    '; - $out .= $sublink; - // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - $out .= img_picto($langs->trans("MoveBox", $this->box_id), 'grip_title', 'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"'); - $out .= img_picto($langs->trans("CloseBox", $this->box_id), 'close_title', 'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.'"'); - $label = $head['text']; - //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')'; - if (!empty($head['graph'])) $label .= ' '; - $out .= ''; - //$out.= '
    '; - $out .= '
    '; - } + //$out.= ''; + $out .= '
    '; + $out .= $sublink; + // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object + $out .= img_picto($langs->trans("MoveBox", $this->box_id), 'grip_title', 'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"'); + $out .= img_picto($langs->trans("CloseBox", $this->box_id), 'close_title', 'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.'"'); + $label = $head['text']; + //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')'; + if (!empty($head['graph'])) $label .= ' '; + $out .= ''; + //$out.= ''; + $out .= '
    '; + } - $out .= ""; - $out .= "\n"; - } + $out .= ""; + $out .= "\n"; + } - // Show box lines - if ($nblines) - { - // Loop on each record - for ($i = 0, $n = $nblines; $i < $n; $i++) - { - if (isset($contents[$i])) - { - // TR - if (isset($contents[$i][0]['tr'])) $out .= ''; - else $out .= ''; + // Show box lines + if ($nblines) + { + // Loop on each record + for ($i = 0, $n = $nblines; $i < $n; $i++) + { + if (isset($contents[$i])) + { + // TR + if (isset($contents[$i][0]['tr'])) $out .= ''; + else $out .= ''; - // Loop on each TD - $nbcolthisline = count($contents[$i]); - for ($j = 0; $j < $nbcolthisline; $j++) { - // Define tdparam - $tdparam = ''; - if (isset($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td']; + // Loop on each TD + $nbcolthisline = count($contents[$i]); + for ($j = 0; $j < $nbcolthisline; $j++) { + // Define tdparam + $tdparam = ''; + if (isset($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td']; - $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : ''; - $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text); - $text2 = isset($contents[$i][$j]['text2']) ? $contents[$i][$j]['text2'] : ''; - $text2withnotags = preg_replace('/<([^>]+)>/i', '', $text2); + $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : ''; + $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text); + $text2 = isset($contents[$i][$j]['text2']) ? $contents[$i][$j]['text2'] : ''; + $text2withnotags = preg_replace('/<([^>]+)>/i', '', $text2); - $textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : ''; - //$out.= "xxx $textwithnotags y"; - if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip'] = ""; - $tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : ''; + $textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : ''; + //$out.= "xxx $textwithnotags y"; + if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip'] = ""; + $tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : ''; - $out .= ''."\n"; + $out .= ''."\n"; - // Url - if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) - { - $out .= 'trans("Show").' '.$tooltip, 1).'" class="classfortooltip"'; - } - //$out.= ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "" - $out .= isset($contents[$i][$j]['target']) ? ' target="'.$contents[$i][$j]['target'].'"' : ''; - $out .= '>'; - } + // Url + if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) + { + $out .= 'trans("Show").' '.$tooltip, 1).'" class="classfortooltip"'; + } + //$out.= ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "" + $out .= isset($contents[$i][$j]['target']) ? ' target="'.$contents[$i][$j]['target'].'"' : ''; + $out .= '>'; + } - // Logo - if (!empty($contents[$i][$j]['logo'])) - { - $logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']); - $out .= ''; - $out .= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"'); - } + // Logo + if (!empty($contents[$i][$j]['logo'])) + { + $logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']); + $out .= ''; + $out .= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"'); + } - $maxlength = $MAXLENGTHBOX; - if (!empty($contents[$i][$j]['maxlength'])) $maxlength = $contents[$i][$j]['maxlength']; + $maxlength = $MAXLENGTHBOX; + if (!empty($contents[$i][$j]['maxlength'])) $maxlength = $contents[$i][$j]['maxlength']; - if ($maxlength) $textwithnotags = dol_trunc($textwithnotags, $maxlength); - if (preg_match('/^<(img|div|span)/i', $text) || !empty($contents[$i][$j]['asis'])) $out .= $text; // show text with no html cleaning - else $out .= $textwithnotags; // show text with html cleaning + if ($maxlength) $textwithnotags = dol_trunc($textwithnotags, $maxlength); + if (preg_match('/^<(img|div|span)/i', $text) || !empty($contents[$i][$j]['asis'])) $out .= $text; // show text with no html cleaning + else $out .= $textwithnotags; // show text with html cleaning - // End Url - if (!empty($contents[$i][$j]['url'])) $out .= ''; + // End Url + if (!empty($contents[$i][$j]['url'])) $out .= ''; - if (preg_match('/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j]['asis2'])) $out .= $text2; // show text with no html cleaning - else $out .= $text2withnotags; // show text with html cleaning + if (preg_match('/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j]['asis2'])) $out .= $text2; // show text with no html cleaning + else $out .= $text2withnotags; // show text with html cleaning - if (!empty($textnoformat)) $out .= "\n".$textnoformat."\n"; + if (!empty($textnoformat)) $out .= "\n".$textnoformat."\n"; - $out .= "\n"; - } + $out .= "\n"; + } - $out .= "\n"; - } - } - } + $out .= "\n"; + } + } + } - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) - { - $out .= "\n"; - } + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) + { + $out .= "\n"; + } - // If invisible box with no contents - if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) $out .= "
    \n"; + // If invisible box with no contents + if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) $out .= "
    \n"; - $out .= "
    \n"; + $out .= "\n"; - $out .= "\n\n"; - if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $out); - } - } else { - dol_syslog(get_class($this).'::showBoxCached'); - $out = ""; - $out .= dol_readcachefile($cachedir, $filename); - } + $out .= "\n\n"; + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $out); + } + } else { + dol_syslog(get_class($this).'::showBoxCached'); + $out = ""; + $out .= dol_readcachefile($cachedir, $filename); + } - if ($nooutput) return $out; - else print $out; + if ($nooutput) return $out; + else print $out; - return ''; + return ''; } @@ -458,6 +458,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box { // Define disabledbyname and disabledbymodule $disabledbyname = 0; + $disabledbymodule = 0; // TODO Set to 2 if module is not enabled $module = ''; // Check if widget file is disabled by name @@ -476,7 +477,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box $text = ''.$langs->trans("Description").':
    '; $text .= $objMod->boxlabel.'
    '; $text .= '
    '.$langs->trans("Status").':
    '; - if ($disabledbymodule == 2) $text .= $langs->trans("HooksDisabledAsModuleDisabled", $module).'
    '; + if ($disabledbymodule == 2) $text .= $langs->trans("WidgetDisabledAsModuleDisabled", $module).'
    '; $widget[$j]['info'] = $text; } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index bb8086f9b90..65c017e3dad 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -294,13 +294,13 @@ class CMailFile $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; } - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); - $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; + $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_' . $smtpContextKey; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey; } } @@ -653,19 +653,19 @@ class CMailFile $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW'; $keyfortls = 'MAIN_MAIL_EMAIL_TLS'; $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS'; - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { - $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_' . $smtpContextKey; - $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_' . $smtpContextKey; - $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_' . $smtpContextKey; - $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_' . $smtpContextKey; - $keyfortls = 'MAIN_MAIL_EMAIL_TLS_' . $smtpContextKey; - $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_' . $smtpContextKey; - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_' . $smtpContextKey; + $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey; + $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey; + $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey; + $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey; + $keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey; + $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey; } } @@ -862,7 +862,7 @@ class CMailFile if (!empty($conf->global->$keyforsmtpid)) $this->transport->setUsername($conf->global->$keyforsmtpid); if (!empty($conf->global->$keyforsmtppw)) $this->transport->setPassword($conf->global->$keyforsmtppw); - if (! empty($conf->global->$keyforsslseflsigned)) $this->transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false)));; + if (!empty($conf->global->$keyforsslseflsigned)) $this->transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false))); //$smtps->_msgReplyTo = 'reply@web.com'; // Switch content encoding to base64 - avoid the doubledot issue with quoted-printable diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 4f1959d2707..62257e79447 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -34,7 +34,7 @@ */ class CSMSFile { - /** + /** * @var string Error code (or message) */ public $error = ''; @@ -76,21 +76,21 @@ class CSMSFile // If ending method not defined if (empty($conf->global->MAIN_SMS_SENDMODE)) { - $this->error = 'No SMS Engine defined'; - return -1; + $this->error = 'No SMS Engine defined'; + return -1; } dol_syslog("CSMSFile::CSMSFile: MAIN_SMS_SENDMODE=".$conf->global->MAIN_SMS_SENDMODE." charset=".$conf->file->character_set_client." from=".$from.", to=".$to.", msg length=".count($msg), LOG_DEBUG); dol_syslog("CSMSFile::CSMSFile: deferred=".$deferred." priority=".$priority." class=".$class, LOG_DEBUG); // Action according to choosed sending method - $this->addr_from = $from; - $this->addr_to = $to; - $this->deferred = $deferred; - $this->priority = $priority; - $this->class = $class; - $this->message = $msg; - $this->nostop = false; + $this->addr_from = $from; + $this->addr_to = $to; + $this->deferred = $deferred; + $this->priority = $priority; + $this->class = $class; + $this->message = $msg; + $this->nostop = false; } @@ -108,17 +108,17 @@ class CSMSFile $res = false; - dol_syslog("CSMSFile::sendfile addr_to=".$this->addr_to, LOG_DEBUG); - dol_syslog("CSMSFile::sendfile message=\n".$this->message); + dol_syslog("CSMSFile::sendfile addr_to=".$this->addr_to, LOG_DEBUG); + dol_syslog("CSMSFile::sendfile message=\n".$this->message); - $this->message = stripslashes($this->message); + $this->message = stripslashes($this->message); - if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms(); + if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms(); if (empty($conf->global->MAIN_DISABLE_ALL_SMS)) { - // Action according to choosed sending method - if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') // Backward compatibility @deprecated + // Action according to choosed sending method + if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') // Backward compatibility @deprecated { dol_include_once('/ovh/class/ovhsms.class.php'); $sms = new OvhSms($this->db); @@ -127,14 +127,14 @@ class CSMSFile $sms->message = $this->message; $sms->deferred = $this->deferred; $sms->priority = $this->priority; - $sms->class = $this->class; - $sms->nostop = $this->nostop; + $sms->class = $this->class; + $sms->nostop = $this->nostop; - $sms->socid = $this->socid; - $sms->contact_id = $this->contact_id; - $sms->project = $this->fk_project; + $sms->socid = $this->socid; + $sms->contact_id = $this->contact_id; + $sms->project = $this->fk_project; - $res = $sms->SmsSend(); + $res = $sms->SmsSend(); if ($res <= 0) { @@ -146,42 +146,42 @@ class CSMSFile if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res); } } elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module' - { - $tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE); - $classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); - dol_include_once('/'.$module.'/class/'.$classfile.'.class.php'); - try { - $classname = ucfirst($classfile); - $sms = new $classname($this->db); - $sms->expe = $this->addr_from; - $sms->dest = $this->addr_to; - $sms->deferred = $this->deferred; - $sms->priority = $this->priority; - $sms->class = $this->class; - $sms->message = $this->message; - $sms->nostop = $this->nostop; + { + $tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE); + $classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); + dol_include_once('/'.$module.'/class/'.$classfile.'.class.php'); + try { + $classname = ucfirst($classfile); + $sms = new $classname($this->db); + $sms->expe = $this->addr_from; + $sms->dest = $this->addr_to; + $sms->deferred = $this->deferred; + $sms->priority = $this->priority; + $sms->class = $this->class; + $sms->message = $this->message; + $sms->nostop = $this->nostop; - $sms->socid = $this->socid; - $sms->contact_id = $this->contact_id; - $sms->fk_project = $this->fk_project; + $sms->socid = $this->socid; + $sms->contact_id = $this->contact_id; + $sms->fk_project = $this->fk_project; - $res = $sms->SmsSend(); + $res = $sms->SmsSend(); - $this->error = $sms->error; - $this->errors = $sms->errors; - if ($res <= 0) - { - dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR); - } else { - dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG); - //var_dump($res); // 1973128 - if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res); - } - } catch (Exception $e) - { - dol_print_error('', 'Error to get list of senders: '.$e->getMessage()); - } - } else { + $this->error = $sms->error; + $this->errors = $sms->errors; + if ($res <= 0) + { + dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR); + } else { + dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG); + //var_dump($res); // 1973128 + if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res); + } + } catch (Exception $e) + { + dol_print_error('', 'Error to get list of senders: '.$e->getMessage()); + } + } else { // Send sms method not correctly defined // -------------------------------------- @@ -198,17 +198,17 @@ class CSMSFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Write content of a SendSms request into a dump file (mode = all) - * Used for debugging. - * - * @return void - */ - public function dump_sms() - { - // phpcs:enable - global $conf, $dolibarr_main_data_root; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Write content of a SendSms request into a dump file (mode = all) + * Used for debugging. + * + * @return void + */ + public function dump_sms() + { + // phpcs:enable + global $conf, $dolibarr_main_data_root; if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir { @@ -229,29 +229,29 @@ class CSMSFile } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Write content of a SendSms result into a dump file (mode = all) - * Used for debugging. - * - * @param int $result Result of sms sending - * @return void - */ - public function dump_sms_result($result) - { - // phpcs:enable - global $conf, $dolibarr_main_data_root; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Write content of a SendSms result into a dump file (mode = all) + * Used for debugging. + * + * @param int $result Result of sms sending + * @return void + */ + public function dump_sms_result($result) + { + // phpcs:enable + global $conf, $dolibarr_main_data_root; - if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir - { - $outputfile = $dolibarr_main_data_root."/dolibarr_sms.log"; - $fp = fopen($outputfile, "a+"); + if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir + { + $outputfile = $dolibarr_main_data_root."/dolibarr_sms.log"; + $fp = fopen($outputfile, "a+"); - fputs($fp, "\nResult id=".$result); + fputs($fp, "\nResult id=".$result); - fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } - } + fclose($fp); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); + } + } } diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index f897ae46a62..e6bd24ad016 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -45,9 +45,9 @@ class AntiVir public $output; /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * Constructor @@ -59,7 +59,7 @@ class AntiVir $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Scan a file with antivirus. * This function runs the command defined in setup. This antivirus command must return 0 if OK. @@ -70,24 +70,24 @@ class AntiVir */ public function dol_avscan_file($file) { - // phpcs:enable + // phpcs:enable global $conf; $return = 0; if (preg_match('/\.virus$/i', $file)) { - $this->errors[] = 'File has an extension saying file is a virus'; - return -97; + $this->errors[] = 'File has an extension saying file is a virus'; + return -97; } $fullcommand = $this->getCliCommand($file); //$fullcommand='"c:\Program Files (x86)\ClamWin\bin\clamscan.exe" --database="C:\Program Files (x86)\ClamWin\lib" "c:\temp\aaa.txt"'; - $fullcommand .= ' 2>&1'; // This is to get error output + $fullcommand .= ' 2>&1'; // This is to get error output $output = array(); $return_var = 0; - $safemode = ini_get("safe_mode"); + $safemode = ini_get("safe_mode"); // Create a clean fullcommand dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand." with safe_mode ".($safemode ? "on" : "off")); // Run CLI command. If run of Windows, you can get return with echo %ERRORLEVEL% @@ -95,7 +95,7 @@ class AntiVir if (is_null($output)) $output = array(); - //print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit; + //print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit; /* $outputfile=$conf->admin->dir_temp.'/dol_avscan_file.out.'.session_id(); @@ -181,7 +181,7 @@ class AntiVir $ret = $command.' '.$param; //$ret=$command.' '.$param.' 2>&1'; - //print "xx".$ret."xx";exit; + //print "xx".$ret."xx";exit; return $ret; } diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 80c6ff1b7a6..91157f52ba0 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -29,9 +29,9 @@ class Canvas { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -45,16 +45,16 @@ class Canvas public $actiontype; - public $dirmodule; // Module directory - public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - public $canvas; // Name of canvas (ex: company, individual, product, service, ...) - public $card; // Tab (sub-canvas) + public $dirmodule; // Module directory + public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) + public $canvas; // Name of canvas (ex: company, individual, product, service, ...) + public $card; // Tab (sub-canvas) - public $template_dir; // Initialized by getCanvas with templates directory - public $control; // Initialized by getCanvas with controller instance + public $template_dir; // Initialized by getCanvas with templates directory + public $control; // Initialized by getCanvas with controller instance - /** + /** * Constructor * * @param DoliDB $db Database handler @@ -75,11 +75,11 @@ class Canvas */ private function _cleanaction($action) { - $newaction = $action; - if ($newaction == 'add') $newaction = 'create'; - if ($newaction == 'update') $newaction = 'edit'; - if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view'; - return $newaction; + $newaction = $action; + if ($newaction == 'add') $newaction = 'create'; + if ($newaction == 'update') $newaction = 'edit'; + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view'; + return $newaction; } @@ -96,45 +96,45 @@ class Canvas global $conf, $langs; // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas - $this->targetmodule = $module; - $this->canvas = $canvas; - $this->card = $card; - $this->dirmodule = $module; - // Correct values if canvas is into an external module + $this->targetmodule = $module; + $this->canvas = $canvas; + $this->card = $card; + $this->dirmodule = $module; + // Correct values if canvas is into an external module if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs)) { - $this->canvas = $regs[1]; - $this->dirmodule = $regs[2]; + $this->canvas = $regs[1]; + $this->dirmodule = $regs[2]; } // For compatibility - if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } + if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } - // Control file + // Control file $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); if (file_exists($controlclassfile)) { - // Include actions class (controller) - $this->control_file = $controlclassfile; - require_once $controlclassfile; + // Include actions class (controller) + $this->control_file = $controlclassfile; + require_once $controlclassfile; - // Instantiate actions class (controller) - $controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas); - $this->control = new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card); + // Instantiate actions class (controller) + $controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas); + $this->control = new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card); } // Template dir $this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/'); - if (!is_dir($this->template_dir)) - { - $this->template_dir = ''; - } + if (!is_dir($this->template_dir)) + { + $this->template_dir = ''; + } - //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
    '; - //print ' => template_dir='.$this->template_dir.'
    '; + //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
    '; + //print ' => template_dir='.$this->template_dir.'
    '; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Shared method for canvas to assign values for templates * * @param string $action Action string @@ -144,25 +144,25 @@ class Canvas */ public function assign_values(&$action = 'view', $id = 0, $ref = '') { - // phpcs:enable + // phpcs:enable if (method_exists($this->control, 'assign_values')) $this->control->assign_values($action, $id, $ref); } - /** - * Return the template to display canvas (if it exists) + /** + * Return the template to display canvas (if it exists) * * @param string $action Action code - * @return int 0=Canvas template file does not exist, 1=Canvas template file exists - */ - public function displayCanvasExists($action) - { - if (empty($this->template_dir)) return 0; + * @return int 0=Canvas template file does not exist, 1=Canvas template file exists + */ + public function displayCanvasExists($action) + { + if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1; - else return 0; - } + if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1; + else return 0; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display a canvas page. This will include the template for output. * Variables used by templates may have been defined or loaded before into the assign_values function. @@ -172,7 +172,7 @@ class Canvas */ public function display_canvas($action) { - // phpcs:enable + // phpcs:enable global $db, $conf, $langs, $user, $canvas; global $form, $formfile; @@ -191,12 +191,12 @@ class Canvas */ public function hasActions() { - return (is_object($this->control)); + return (is_object($this->control)); } /** * Shared method for canvas to execute actions. - * @deprecated Use the doActions of hooks instead of this. + * @deprecated Use the doActions of hooks instead of this. * This function is called if you add a doActions class inside your canvas. Try to not * do that and add action code into a hook instead. * diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index cf671eb57ca..d19e6d00a36 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -33,9 +33,9 @@ class Ccountry // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -50,7 +50,7 @@ class Ccountry // extends CommonObject public $element = 'ccountry'; //!< Id that identify managed objects public $table_element = 'c_country'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -59,9 +59,9 @@ class Ccountry // extends CommonObject public $code_iso; /** - * @var string Countries label - */ - public $label; + * @var string Countries label + */ + public $label; public $active; @@ -70,27 +70,27 @@ class Ccountry // extends CommonObject ); - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -102,14 +102,14 @@ class Ccountry // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_country("; $sql .= "rowid,"; $sql .= "code,"; $sql .= "code_iso,"; $sql .= "label,"; $sql .= "active"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->code_iso) ? 'NULL' : "'".$this->db->escape($this->code_iso)."'").","; @@ -120,88 +120,88 @@ class Ccountry // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country"); - } + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @param string $code Code - * @param string $code_iso Code ISO - * @return int >0 if OK, 0 if not found, <0 if KO - */ - public function fetch($id, $code = '', $code_iso = '') - { - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @param string $code_iso Code ISO + * @return int >0 if OK, 0 if not found, <0 if KO + */ + public function fetch($id, $code = '', $code_iso = '') + { + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code,"; $sql .= " t.code_iso,"; $sql .= " t.label,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_country as t"; - if ($id) $sql .= " WHERE t.rowid = ".$id; - elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; - elseif ($code_iso) $sql .= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_country as t"; + if ($id) $sql .= " WHERE t.rowid = ".$id; + elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($code_iso) $sql .= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code = $obj->code; $this->code_iso = $obj->code_iso; $this->label = $obj->label; $this->active = $obj->active; - $this->db->free($resql); - return 1; - } else { - return 0; - } - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + $this->db->free($resql); + return 1; + } else { + return 0; + } + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -214,27 +214,27 @@ class Ccountry // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_country SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_country SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " code_iso=".(isset($this->code_iso) ? "'".$this->db->escape($this->code_iso)."'" : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null").""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -242,16 +242,16 @@ class Ccountry // extends CommonObject $this->db->commit(); return 1; } - } + } /** * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -264,15 +264,15 @@ class Ccountry // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -282,19 +282,19 @@ class Ccountry // extends CommonObject } } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $langs; - return $langs->trans($this->label); - } + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $langs; + return $langs->trans($this->label); + } } diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 39ae2eb63ef..d2c6221a598 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -44,27 +44,27 @@ class Comment extends CommonObject public $description; /** - * Date modification record (tms) - * - * @var integer - */ + * Date modification record (tms) + * + * @var integer + */ public $tms; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; /** diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 6015bbceece..26debedc9a7 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -77,11 +77,11 @@ abstract class CommonDocGenerator public function get_substitutionarray_user($user, $outputlangs) { // phpcs:enable - global $conf; + global $conf, $extrafields; $logotouse = $conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo; - return array( + $array_user = array( 'myuser_lastname'=>$user->lastname, 'myuser_firstname'=>$user->firstname, 'myuser_fullname'=>$user->getFullName($outputlangs, 1), @@ -101,6 +101,53 @@ abstract class CommonDocGenerator 'myuser_job'=>$user->job, 'myuser_web'=>'' // url not exist in $user object ); + // Retrieve extrafields + if (is_array($user->array_options) && count($user->array_options)) { + $array_user = $this->fill_substitutionarray_with_extrafields($user, $array_user, $extrafields, 'myuser', $outputlangs); + } + return $array_user; + } + + + /** + * Define array with couple substitution key => substitution value + * + * @param Adherent $member Member + * @param Translate $outputlangs Language object for output + * @return array Array of substitution key->code + */ + public function getSubstitutionarrayMember($member, $outputlangs) + { + global $conf, $extrafields; + + $logotouse = $conf->adherent->dir_output.'/'.get_exdir($member->id, 2, 0, 1, $member, 'user').'/'.$member->photo; + + $array_member = array( + 'mymember_lastname' => $member->lastname, + 'mymember_firstname' => $member->firstname, + 'mymember_fullname' => $member->getFullName($outputlangs, 1), + 'mymember_login' => $member->login, + 'mymember_address' => $member->address, + 'mymember_zip' => $member->zip, + 'mymember_town' => $member->town, + 'mymember_country_code' => $member->country_code, + 'mymember_country' => $member->country, + 'mymember_state_code' => $member->state_code, + 'mymember_state' => $member->state, + 'mymember_phone_perso' => $member->phone_perso, + 'mymember_phone_pro' => $member->phone, + 'mymember_phone_mobile' => $member->phone_mobile, + 'mymember_email' => $member->email, + 'mymember_logo' => $logotouse, + 'mymember_gender' => $member->gender, + 'mymember_birth_locale' => dol_print_date($member->birth, 'day', 'tzuser', $outputlangs), + 'mymember_birth' => dol_print_date($member->birth, 'day', 'tzuser'), + ); + // Retrieve extrafields + if (is_array($member->array_options) && count($member->array_options)) { + $array_member = $this->fill_substitutionarray_with_extrafields($member, $array_member, $extrafields, 'mymember', $outputlangs); + } + return $array_member; } @@ -1249,7 +1296,7 @@ abstract class CommonDocGenerator $html = ''; $fields = array(); - if (is_array($extrafields->attributes[$object->table_element]['label'])) { + if (is_array($extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { // Enable extrafield ? diff --git a/htdocs/core/class/commonincoterm.class.php b/htdocs/core/class/commonincoterm.class.php index b2d5491684e..f98f3aaabad 100644 --- a/htdocs/core/class/commonincoterm.class.php +++ b/htdocs/core/class/commonincoterm.class.php @@ -105,7 +105,7 @@ trait CommonIncoterm * * @param int $id_incoterm Id of incoterm to set or '' to remove * @param string $location location of incoterm - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function setIncoterms($id_incoterm, $location) { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 920dd42f515..5c679848354 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -33,36 +33,36 @@ abstract class CommonInvoice extends CommonObject { use CommonIncoterm; - /** - * Standard invoice - */ - const TYPE_STANDARD = 0; + /** + * Standard invoice + */ + const TYPE_STANDARD = 0; - /** - * Replacement invoice - */ - const TYPE_REPLACEMENT = 1; + /** + * Replacement invoice + */ + const TYPE_REPLACEMENT = 1; - /** - * Credit note invoice - */ - const TYPE_CREDIT_NOTE = 2; + /** + * Credit note invoice + */ + const TYPE_CREDIT_NOTE = 2; - /** - * Deposit invoice - */ - const TYPE_DEPOSIT = 3; + /** + * Deposit invoice + */ + const TYPE_DEPOSIT = 3; - /** - * Proforma invoice. - * @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice ! - */ - const TYPE_PROFORMA = 4; + /** + * Proforma invoice. + * @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice ! + */ + const TYPE_PROFORMA = 4; - /** - * Situation invoice - */ - const TYPE_SITUATION = 5; + /** + * Situation invoice + */ + const TYPE_SITUATION = 5; /** * Draft status @@ -98,20 +98,20 @@ abstract class CommonInvoice extends CommonObject * This does not include open direct debit requests. * * @param int $multicurrency Return multicurrency_amount instead of amount - * @return double Remain of amount to pay + * @return float Remain of amount to pay */ public function getRemainToPay($multicurrency = 0) { - $alreadypaid = 0; - $alreadypaid += $this->getSommePaiement($multicurrency); - $alreadypaid += $this->getSumDepositsUsed($multicurrency); - $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); + $alreadypaid = 0.0; + $alreadypaid += $this->getSommePaiement($multicurrency); + $alreadypaid += $this->getSumDepositsUsed($multicurrency); + $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); - $remaintopay = price2num($this->total_ttc - $alreadypaid, 'MT'); - if ($this->statut == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment - $remaintopay = 0; - } - return $remaintopay; + $remaintopay = price2num($this->total_ttc - $alreadypaid, 'MT'); + if ($this->statut == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment + $remaintopay = 0.0; + } + return $remaintopay; } /** @@ -119,7 +119,7 @@ abstract class CommonInvoice extends CommonObject * Payments dones using discounts, credit notes, etc are not included. * * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int Amount of payment already done, <0 if KO + * @return float Amount of payment already done, <0 if KO */ public function getSommePaiement($multicurrency = 0) { @@ -151,72 +151,69 @@ abstract class CommonInvoice extends CommonObject /** * Return amount (with tax) of all deposits invoices used by invoice. - * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). + * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). * * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of deposits amount otherwise + * @return float <0 if KO, Sum of deposits amount otherwise */ public function getSumDepositsUsed($multicurrency = 0) { if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') - { - // TODO - return 0; - } + { + // TODO + return 0.0; + } - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic = new DiscountAbsolute($this->db); - $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); - if ($result >= 0) - { - return $result; - } else { - $this->error = $discountstatic->error; - return -1; - } + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); + if ($result >= 0) { + return $result; + } else { + $this->error = $discountstatic->error; + return -1; + } } /** * Return amount (with tax) of all credit notes invoices + excess received used by invoice * * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + * @return float <0 if KO, Sum of credit notes and deposits amount otherwise */ public function getSumCreditNotesUsed($multicurrency = 0) { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic = new DiscountAbsolute($this->db); - $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); - if ($result >= 0) - { - return $result; - } else { - $this->error = $discountstatic->error; - return -1; - } + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); + if ($result >= 0) { + return $result; + } else { + $this->error = $discountstatic->error; + return -1; + } } /** * Return amount (with tax) of all converted amount for this credit note * * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + * @return float <0 if KO, Sum of credit notes and deposits amount otherwise */ public function getSumFromThisCreditNotesNotUsed($multicurrency = 0) { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic = new DiscountAbsolute($this->db); - $result = $discountstatic->getSumFromThisCreditNotesNotUsed($this, $multicurrency); - if ($result >= 0) - { - return $result; - } else { - $this->error = $discountstatic->error; - return -1; - } + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getSumFromThisCreditNotesNotUsed($this, $multicurrency); + if ($result >= 0) { + return $result; + } else { + $this->error = $discountstatic->error; + return -1; + } } /** @@ -300,7 +297,7 @@ abstract class CommonInvoice extends CommonObject $table2 = 'paiement'; $field = 'fk_facture'; $field2 = 'fk_paiement'; - $field3=', p.ref_ext'; + $field3 = ', p.ref_ext'; $sharedentity = 'facture'; if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { @@ -308,7 +305,7 @@ abstract class CommonInvoice extends CommonObject $table2 = 'paiementfourn'; $field = 'fk_facturefourn'; $field2 = 'fk_paiementfourn'; - $field3=''; + $field3 = ''; $sharedentity = 'facture_fourn'; } @@ -330,11 +327,11 @@ abstract class CommonInvoice extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $tmp = array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); + $tmp = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); if (!empty($field3)) { - $tmp['ref_ext'] = $obj->ref_ext; + $tmp['ref_ext'] = $obj->ref_ext; } - $retarray[]=$tmp; + $retarray[] = $tmp; $i++; } $this->db->free($resql); @@ -388,7 +385,7 @@ abstract class CommonInvoice extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if an invoice can be deleted * Rule is: @@ -402,9 +399,9 @@ abstract class CommonInvoice extends CommonObject * * @return int <=0 if no, >0 if yes */ - public function is_erasable() - { - // phpcs:enable + public function is_erasable() + { + // phpcs:enable global $conf; // We check if invoice is a temporary number (PROVxxxx) @@ -489,15 +486,15 @@ abstract class CommonInvoice extends CommonObject * * @return string Label of type of invoice */ - public function getLibType() + public function getLibType() { global $langs; - if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); - elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); - elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); - elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); - elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. - elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); + if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); + elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); + elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); + elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); + elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. + elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); return $langs->trans("Unknown"); } @@ -513,7 +510,7 @@ abstract class CommonInvoice extends CommonObject return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -521,57 +518,59 @@ abstract class CommonInvoice extends CommonObject * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise) - * @param int $type Type invoice + * @param int $type Type invoice. If -1, we use $this->type * @return string Label of status */ - public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) + public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = -1) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load('bills'); + if ($type == -1) $type = $this->type; + $statusType = 'status0'; $prefix = 'Short'; if (!$paye) { - if ($status == 0) { - $labelStatus = $langs->trans('BillStatusDraft'); - $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusDraft'); - } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { - $labelStatus = $langs->trans('BillStatusClosedUnpaid'); - $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); - $statusType = 'status5'; - } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { - $labelStatus = $langs->trans('BillStatusClosedPaidPartially'); - $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - $statusType = 'status9'; - } elseif ($alreadypaid == 0) { - $labelStatus = $langs->trans('BillStatusNotPaid'); - $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusNotPaid'); - $statusType = 'status1'; - } else { - $labelStatus = $langs->trans('BillStatusStarted'); - $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusStarted'); - $statusType = 'status3'; - } + if ($status == 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusDraft'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusDraft'); + } elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedUnpaid'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedUnpaid'); + $statusType = 'status5'; + } elseif (($status == 3 || $status == 2) && $alreadypaid > 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedPaidPartially'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedPaidPartially'); + $statusType = 'status9'; + } elseif ($alreadypaid == 0) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusNotPaid'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusNotPaid'); + $statusType = 'status1'; + } else { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusStarted'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusStarted'); + $statusType = 'status3'; + } } else { - $statusType = 'status6'; + $statusType = 'status6'; - if ($type == self::TYPE_CREDIT_NOTE) { - $labelStatus = $langs->trans('BillStatusPaidBackOrConverted'); // credit note - $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note - } elseif ($type == self::TYPE_DEPOSIT) { - $labelStatus = $langs->trans('BillStatusConverted'); // deposit invoice - $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice - } else { - $labelStatus = $langs->trans('BillStatusPaid'); - $labelStatusShort = $langs->trans('Bill'.$prefix.'StatusPaid'); - } + if ($type == self::TYPE_CREDIT_NOTE) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusPaidBackOrConverted'); // credit note + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note + } elseif ($type == self::TYPE_DEPOSIT) { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusConverted'); // deposit invoice + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusConverted'); // deposit invoice + } else { + $labelStatus = $langs->transnoentitiesnoconv('BillStatusPaid'); + $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusPaid'); + } } return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an invoice payment deadline based on the invoice settlement * conditions and billing date. @@ -579,15 +578,15 @@ abstract class CommonInvoice extends CommonObject * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. * @return integer Date limite de reglement si ok, <0 si ko */ - public function calculate_date_lim_reglement($cond_reglement = 0) + public function calculate_date_lim_reglement($cond_reglement = 0) { - // phpcs:enable + // phpcs:enable if (!$cond_reglement) $cond_reglement = $this->cond_reglement_code; if (!$cond_reglement) $cond_reglement = $this->cond_reglement_id; $cdr_nbjour = 0; - $cdr_type = 0; - $cdr_decalage = 0; + $cdr_type = 0; + $cdr_decalage = 0; $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; $sqltemp .= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; @@ -646,7 +645,7 @@ abstract class CommonInvoice extends CommonObject // 2 : application of the rule, the N of the current or next month elseif ($cdr_type == 2 && !empty($cdr_decalage)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $datelim = $this->date + ($cdr_nbjour * 3600 * 24); $date_piece = dol_mktime(0, 0, 0, date('m', $datelim), date('d', $datelim), date('Y', $datelim)); // Sans les heures minutes et secondes @@ -697,7 +696,7 @@ abstract class CommonInvoice extends CommonObject } else { $sql .= ' WHERE fk_facture = '.$this->id; } - $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments + $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments $sql .= ' AND traite = 0'; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); @@ -756,7 +755,7 @@ abstract class CommonInvoice extends CommonObject if (!$error) { // Force payment mode of invoice to withdraw - $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); + $payment_mode_id = dol_getIdFromCode($this->db, ($type == 'bank-transfer' ? 'VIR' : 'PRE'), 'c_paiement', 'code', 'id', 1); if ($payment_mode_id > 0) { $result = $this->setPaymentMethods($payment_mode_id); } @@ -934,21 +933,23 @@ abstract class CommonInvoiceLine extends CommonObjectLine */ public $total_ttc; + public $date_start_fill; // If set to 1, when invoice is created from a template invoice, it will also auto set the field date_start at creation + public $date_end_fill; // If set to 1, when invoice is created from a template invoice, it will also auto set the field date_end at creation + /** * List of cumulative options: - * Bit 0: 0 si TVA normal - 1 si TVA NPR + * Bit 0: 0 for common VAT - 1 if VAT french NPR * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) * @var int */ public $info_bits = 0; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct(DoliDB $db) - { - $this->db = $db; - } + public $special_code = 0; + + public $fk_multicurrency; + public $multicurrency_code; + public $multicurrency_subprice; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ea38df7a826..741f5f086a9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2017 ATM Consulting * Copyright (C) 2017-2019 Nicolas ZABOURI * Copyright (C) 2017 Rui Strecht - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2018 Josep Lluís Amador * * This program is free software; you can redistribute it and/or modify @@ -51,6 +51,11 @@ abstract class CommonObject */ public $id; + /** + * @var int The environment ID when using a multicompany module + */ + public $entity; + /** * @var string Error string * @see $errors @@ -296,11 +301,16 @@ abstract class CommonObject */ public $cond_reglement_id; - /** - * @var int Transport mode ID (For module intracomm report) - * @see setTransportMode() - */ - public $transport_mode_id; + /** + * @var int Demand reason ID + */ + public $demand_reason_id; + + /** + * @var int Transport mode ID (For module intracomm report) + * @see setTransportMode() + */ + public $transport_mode_id; /** * @var int Payment terms ID @@ -334,12 +344,24 @@ abstract class CommonObject */ public $last_main_doc; + /** + * @var int Bank account ID + * @deprecated + * @see $fk_account + */ + public $fk_bank; + /** * @var int Bank account ID * @see SetBankAccount() */ public $fk_account; + /** + * @var string Open ID + */ + public $openid; + /** * @var string Public note * @see update_note() @@ -437,6 +459,11 @@ abstract class CommonObject public $next_prev_filter; + /** + * @var int 1 if object is specimen + */ + public $specimen = 0; + /** * @var array List of child tables. To test if we can delete object. */ @@ -569,6 +596,28 @@ abstract class CommonObject return dol_trunc($ret, $maxlen); } + /** + * Set to upper or ucwords/lower if needed + * + * @return void; + */ + public function setUpperOrLowerCase() + { + global $conf; + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) { + $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); + $this->firstname = dol_ucwords(dol_strtolower($this->firstname)); + $this->name = dol_ucwords(dol_strtolower($this->name)); + } + if (!empty($conf->global->MAIN_ALL_TO_UPPER)) { + $this->lastname = dol_strtoupper($this->lastname); + $this->name = dol_strtoupper($this->name); + } + if (!empty($conf->global->MAIN_ALL_TOWN_TO_UPPER)) { + $this->town = dol_strtoupper($this->town); + } + } + /** * Return clicable link of object (with eventually picto) * @@ -2196,42 +2245,42 @@ abstract class CommonObject } } - /** - * Change the transport mode methods - * - * @param int $id Id of new payment method - * @return int >0 if OK, <0 if KO - */ - public function setTransportMode($id) - { - dol_syslog(get_class($this).'::setTransportMode('.$id.')'); - if ($this->statut >= 0 || $this->element == 'societe') - { - $fieldname = 'fk_transport_mode'; - if ($this->element == 'societe') $fieldname = 'transport_mode'; - if (get_class($this) == 'Fournisseur') $fieldname = 'transport_mode_supplier'; + /** + * Change the transport mode methods + * + * @param int $id Id of new payment method + * @return int >0 if OK, <0 if KO + */ + public function setTransportMode($id) + { + dol_syslog(get_class($this).'::setTransportMode('.$id.')'); + if ($this->statut >= 0 || $this->element == 'societe') + { + $fieldname = 'fk_transport_mode'; + if ($this->element == 'societe') $fieldname = 'transport_mode'; + if (get_class($this) == 'Fournisseur') $fieldname = 'transport_mode_supplier'; - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); - $sql .= ' WHERE rowid='.$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); + $sql .= ' WHERE rowid='.$this->id; - if ($this->db->query($sql)) - { - $this->transport_mode_id = $id; - // for supplier - if (get_class($this) == 'Fournisseur') $this->transport_mode_supplier_id = $id; - return 1; - } else { - dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); - return -1; - } - } else { - dol_syslog(get_class($this).'::setTransportMode, status of the object is incompatible'); - $this->error='Status of the object is incompatible '.$this->statut; - return -2; - } - } + if ($this->db->query($sql)) + { + $this->transport_mode_id = $id; + // for supplier + if (get_class($this) == 'Fournisseur') $this->transport_mode_supplier_id = $id; + return 1; + } else { + dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); + $this->error = $this->db->error(); + return -1; + } + } else { + dol_syslog(get_class($this).'::setTransportMode, status of the object is incompatible'); + $this->error = 'Status of the object is incompatible '.$this->statut; + return -2; + } + } /** * Change the retained warranty payments terms @@ -2787,7 +2836,7 @@ abstract class CommonObject { // phpcs:enable $positionfield = 'rang'; - if ($this->table_element == 'bom') $positionfield = 'position'; + if ($this->table_element == 'bom_bom') $positionfield = 'position'; // Search the last rang with fk_parent_line if ($fk_parent_line) @@ -3356,7 +3405,7 @@ abstract class CommonObject } elseif ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; } elseif ($objecttype == 'delivery') { - $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; + $classpath = 'delivery/class'; $subelement = 'delivery'; $module = 'delivery_note'; } elseif ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') { $classpath = 'fourn/class'; $module = 'fournisseur'; } elseif ($objecttype == 'fichinter') { @@ -4526,13 +4575,17 @@ abstract class CommonObject { foreach (array('doc', 'pdf') as $prefix) { - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php - else $file = $prefix."_".$modele.".modules.php"; + if (in_array(get_class($this), array('Adherent'))) { + // Member module use prefix_modele.class.php + $file = $prefix."_".$modele.".class.php"; + } else { + // Other module use prefix_modele.modules.php + $file = $prefix."_".$modele.".modules.php"; + } // On verifie l'emplacement du modele $file = dol_buildpath($reldir.$modelspath.$file, 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = $file; $classname = $prefix.'_'.$modele; break; @@ -4975,7 +5028,7 @@ abstract class CommonObject { $value_arr = GETPOST($postfieldkey, 'array'); // check if an array if (!empty($value_arr)) { - $value_key = implode($value_arr, ','); + $value_key = implode(',', $value_arr); } else { $value_key = ''; } @@ -5039,7 +5092,7 @@ abstract class CommonObject global $conf, $extrafields; if (empty($rowid)) $rowid = $this->id; - if (empty($rowid)) $rowid = $this->rowid; + if (empty($rowid) && isset($this->rowid)) $rowid = $this->rowid; // deprecated // To avoid SQL errors. Probably not the better solution though if (!$this->table_element) { @@ -5195,7 +5248,7 @@ abstract class CommonObject $extrafields = new ExtraFields($this->db); $target_extrafields = $extrafields->fetch_name_optionals_label($this->table_element); - //Eliminate copied source object extra_fields that do not exist in target object + // Eliminate copied source object extra fields that do not exist in target object $new_array_options = array(); foreach ($this->array_options as $key => $value) { if (in_array(substr($key, 8), array_keys($target_extrafields))) // We remove the 'options_' from $key for test @@ -5213,7 +5266,8 @@ abstract class CommonObject $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey]; $attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey]; - if ($attributeRequired) + // Similar code than into insertExtraFields + if ($attributeRequired) { $mandatorypb = false; if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb = true; @@ -5241,7 +5295,7 @@ abstract class CommonObject } } - switch ($attributeType) + switch ($attributeType) { case 'int': if (!is_numeric($value) && $value != '') @@ -5325,11 +5379,10 @@ abstract class CommonObject if ($value == '-1') // -1 is key for no defined in combo list of objects { $new_array_options[$key] = ''; - } elseif ($value) - { + } elseif ($value) { $object = new $InfoFieldList[0]($this->db); - if (is_numeric($value)) $res = $object->fetch($value); - else $res = $object->fetch('', $value); + if (is_numeric($value)) $res = $object->fetch($value); // Common case + else $res = $object->fetch('', $value); // For compatibility if ($res > 0) $new_array_options[$key] = $object->id; else { @@ -5552,7 +5605,7 @@ abstract class CommonObject } /** - * Update an extra field value for the current object. + * Update 1 extra field value for the current object. Keep other fields unchanged. * Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * * @param string $key Key of the extrafield to update (without starting 'options_') @@ -5585,10 +5638,37 @@ abstract class CommonObject $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$key]; $attributeParam = $extrafields->attributes[$this->table_element]['param'][$key]; $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$key]; + $attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$key]; + + // Similar code than into insertExtraFields + if ($attributeRequired) + { + $mandatorypb = false; + if ($attributeType == 'link' && $this->array_options["options_".$key] == '-1') $mandatorypb = true; + if ($this->array_options["options_".$key] === '') $mandatorypb = true; + if ($mandatorypb) + { + dol_syslog("Mandatory extra field options_".$key." is empty"); + $this->errors[] = $langs->trans('ErrorFieldRequired', $attributeLabel); + return -1; + } + } //dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG); //dol_syslog("attributeType=".$attributeType, LOG_DEBUG); + if (!empty($attrfieldcomputed)) + { + if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) + { + $value = dol_eval($attrfieldcomputed, 1, 0); + dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG); + $this->array_options["options_".$key] = $value; + } else { + $this->array_options["options_".$key] = null; + } + } + switch ($attributeType) { case 'int': @@ -5630,31 +5710,65 @@ abstract class CommonObject case 'datetime': $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]); break; + /* case 'link': $param_list = array_keys($attributeParam['options']); // 0 : ObjectName // 1 : classPath $InfoFieldList = explode(":", $param_list[0]); dol_include_once($InfoFieldList[1]); - if ($value) + if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) { - $object = new $InfoFieldList[0]($this->db); - $object->fetch(0, $value); - $this->array_options["options_".$key] = $object->id; + if ($value == '-1') // -1 is key for no defined in combo list of objects + { + $new_array_options[$key] = ''; + } elseif ($value) { + $object = new $InfoFieldList[0]($this->db); + if (is_numeric($value)) $res = $object->fetch($value); // Common case + else $res = $object->fetch('', $value); // For compatibility + + if ($res > 0) $new_array_options[$key] = $object->id; + else { + $this->error = "Id/Ref '".$value."' for object '".$object->element."' not found"; + $this->db->rollback(); + return -1; + } + } + } else { + dol_syslog('Error bad setup of extrafield', LOG_WARNING); } break; + */ } $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key."='".$this->db->escape($this->array_options["options_".$key])."'"; - $sql .= " WHERE fk_object = ".$this->id; + + $linealreadyfound = 0; + + // Check if there is already a line for this object (in most cases, it is, but sometimes it is not, for example when extra field has been created after), so we must keep this overload) + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + $resql = $this->db->query($sql); + if ($resql) { + $tmpobj = $this->db->fetch_object($resql); + if ($tmpobj) { + $linealreadyfound = $tmpobj->nb; + } + } + + if ($linealreadyfound) { + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; + $sql .= " WHERE fk_object = ".$this->id; + } else { + $result = $this->insertExtraFields('', $user); + if ($result < 0) $error++; + } + $resql = $this->db->query($sql); if (!$resql) { $error++; $this->error = $this->db->lasterror(); } - if (!$error && $trigger) { // Call trigger @@ -5706,7 +5820,7 @@ abstract class CommonObject * * @param array $val Array of properties for field to show (used only if ->fields not defined) * @param string $key Key of attribute - * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) + * @param string|array $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value, for array type must be array) * @param string $moreparam To add more parameters on html input tag * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) @@ -6223,7 +6337,8 @@ abstract class CommonObject $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' $param_list_array = explode(':', $param_list[0]); $showempty = (($required && $default != '') ? 0 : 1); - if (!empty($param_list_array[2])) { // If the entry into $fields is set to add a create button + + if (!preg_match('/search_/', $keyprefix) && !empty($param_list_array[2])) { // If the entry into $fields is set to add a create button $morecss .= ' widthcentpercentminusx'; } @@ -6327,7 +6442,7 @@ abstract class CommonObject $type = 'varchar'; // convert varchar(xx) int varchar $size = $reg[1]; } elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar - if (is_array($val['arrayofkeyval'])) $type = 'select'; + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) $type = 'select'; if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type = 'link'; $default = $val['default']; @@ -6337,7 +6452,7 @@ abstract class CommonObject $param = array(); $param['options'] = array(); - if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { $type = 'link'; @@ -6726,7 +6841,7 @@ abstract class CommonObject switch ($mode) { case "view": - $value = $this->array_options["options_".$key.$keysuffix]; // Value may be clean or formated later + $value = $this->array_options["options_".$key.$keysuffix]; // Value may be clean or formated later break; case "create": case "edit": @@ -6801,7 +6916,7 @@ abstract class CommonObject { $datenotinstring = $this->db->jdate($datenotinstring); } - $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring; + $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring; } // Convert float submited string into real php numeric (value in memory must be a php numeric) if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double'))) @@ -6870,32 +6985,37 @@ abstract class CommonObject if (!empty($conf->use_javascript_ajax)) { $out .= ' '."\n"; } @@ -7409,8 +7529,7 @@ abstract class CommonObject // Depending on field type ('datetime', ...) if ($this->isDate($info)) { - if (empty($this->{$field})) - { + if (empty($this->{$field})) { $queryarray[$field] = null; } else { $queryarray[$field] = $this->db->idate($this->{$field}); @@ -7428,16 +7547,27 @@ abstract class CommonObject } elseif ($this->isDuration($info)) { // $this->{$field} may be null, '', 0, '0', 123, '123' - if ($this->{$field} != '' || !empty($info['notnull'])) $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 + if ((isset($this->{$field}) && $this->{$field} != '') || !empty($info['notnull'])) { + if (!isset($this->{$field})) { + $queryarray[$field] = 0; + } else { + $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 + } + } else $queryarray[$field] = null; } elseif ($this->isInt($info) || $this->isFloat($info)) { if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field] = $conf->entity; else { // $this->{$field} may be null, '', 0, '0', 123, '123' - if ($this->{$field} != '' || !empty($info['notnull'])) { - if ($this->isInt($info)) $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 - if ($this->isFloat($info)) $queryarray[$field] = (double) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 + if ((isset($this->{$field}) && $this->{$field} != '') || !empty($info['notnull'])) { + if (!isset($this->{$field})) { + $queryarray[$field] = 0; + } elseif ($this->isInt($info)) { + $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 + } elseif ($this->isFloat($info)) { + $queryarray[$field] = (double) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 + } } else $queryarray[$field] = null; } } else { @@ -7725,7 +7855,7 @@ abstract class CommonObject { $this->setVarsFromFetchObj($obj); - // Retreive all extrafield + // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals(); @@ -7814,6 +7944,7 @@ abstract class CommonObject unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data + // Add quotes and escape on fields with type string $keys = array(); $values = array(); $tmp = array(); @@ -7824,7 +7955,7 @@ abstract class CommonObject $tmp[] = $k.'='.$this->quote($v, $this->fields[$k]); } - // Clean and check mandatory + // Clean and check mandatory fields foreach ($keys as $key) { if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = ''; // This is an implicit foreign key field @@ -7976,6 +8107,18 @@ abstract class CommonObject } } + // Delete llx_ecm_files + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + $error++; + } + } + if (!$error && !empty($this->isextrafieldmanaged)) { $result = $this->deleteExtraFields(); @@ -8138,8 +8281,11 @@ abstract class CommonObject $this->db->begin(); + $statusfield = 'status'; + if ($this->element == 'don' || $this->element == 'donation') $statusfield = 'fk_statut'; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET status = ".$status; + $sql .= " SET ".$statusfield." = ".((int) $status); $sql .= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) @@ -8175,22 +8321,31 @@ abstract class CommonObject * Initialise object with example values * Id must be 0 if object instance is a specimen * - * @return void + * @return int */ public function initAsSpecimenCommon() { global $user; $this->id = 0; - if (array_key_exists('label', $this->fields)) $this->label = 'This is label'; - if (array_key_exists('note_public', $this->fields)) $this->note_public = 'Public note'; - if (array_key_exists('note_private', $this->fields)) $this->note_private = 'Private note'; - if (array_key_exists('date_creation', $this->fields)) $this->date_creation = (dol_now() - 3600 * 24); - if (array_key_exists('date_modification', $this->fields)) $this->date_modification = (dol_now() - 3600 * 24); - if (array_key_exists('fk_user_creat', $this->fields)) $this->fk_user_creat = $user->id; - if (array_key_exists('fk_user_modif', $this->fields)) $this->fk_user_modif = $user->id; - if (array_key_exists('date', $this->fields)) $this->date = dol_now(); - // ... + $this->specimen = 1; + $fields = array( + 'label' => 'This is label', + 'ref' => 'ABCD1234', + 'description' => 'This is a description', + 'qty' => 123.12, + 'note_public' => 'Public note', + 'note_private' => 'Private note', + 'date_creation' => (dol_now() - 3600 * 48), + 'date_modification' => (dol_now() - 3600 * 24), + 'fk_user_creat' => $user->id, + 'fk_user_modif' => $user->id, + 'date' => dol_now(), + ); + foreach ($fields as $key => $value) { + if (array_key_exists($key, $this->fields)) $this->{$key} = $value; + } + return 1; } @@ -8227,8 +8382,8 @@ abstract class CommonObject /** * Trim object parameters - * @param string[] $parameters array of parameters to trim * + * @param string[] $parameters array of parameters to trim * @return void */ public function trimParameters($parameters) @@ -8365,7 +8520,7 @@ abstract class CommonObject $this->db->begin(); - switch ($this->element){ + switch ($this->element) { case 'propal': $element = 'propale'; break; @@ -8373,10 +8528,10 @@ abstract class CommonObject $element = 'produit'; break; case 'order_supplier': - $element ='fournisseur/commande'; + $element = 'fournisseur/commande'; break; case 'invoice_supplier': - $element = 'fournisseur/facture/' . get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); + $element = 'fournisseur/facture/'.get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); break; case 'shipping': $element = 'expedition/sending'; @@ -8386,8 +8541,8 @@ abstract class CommonObject } $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; - $sql.= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index c7e95aa1fbc..0d4cfbe4f34 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -19,7 +19,7 @@ /** * \file htdocs/core/class/commonobjectline.class.php * \ingroup core - * \brief File of the superclass of classes of lines of business objects (invoice, contract, PROPAL, commands, etc. ...) + * \brief File of the superclass of classes of lines of business objects (invoice, contract, proposal, orders, etc. ...) */ diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 8874175a138..5062a7016bb 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -89,7 +89,7 @@ abstract class CommonOrderLine extends CommonObjectLine * @deprecated * @see $subprice */ - public $price; + public $price; /** * Unit price before taxes @@ -121,6 +121,12 @@ abstract class CommonOrderLine extends CommonObjectLine */ public $remise_percent; + /** + * VAT code + * @var string + */ + public $vat_src_code; + /** * VAT % * @var float @@ -151,4 +157,11 @@ abstract class CommonOrderLine extends CommonObjectLine public $info_bits = 0; public $special_code = 0; + + public $fk_multicurrency; + public $multicurrency_code; + public $multicurrency_subprice; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; } diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index c3d6e7de299..3a8712ad67d 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -61,46 +61,46 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; */ abstract class CommonStickerGenerator { - public $code; // Code of format + public $code; // Code of format - /** - * @var array format Array with informations - */ - public $format; + /** + * @var array format Array with informations + */ + public $format; - // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore - // protected - // Nom du format de l'etiquette - protected $_Avery_Name = ''; - // Marge de gauche de l'etiquette - protected $_Margin_Left = 0; - // marge en haut de la page avant la premiere etiquette - protected $_Margin_Top = 0; - // Espace horizontal entre 2 bandes d'etiquettes - protected $_X_Space = 0; - // Espace vertical entre 2 bandes d'etiquettes - protected $_Y_Space = 0; - // NX Nombre d'etiquettes sur la largeur de la page - protected $_X_Number = 0; - // NY Nombre d'etiquettes sur la hauteur de la page - protected $_Y_Number = 0; - // Largeur de chaque etiquette - protected $_Width = 0; - // Hauteur de chaque etiquette - protected $_Height = 0; - // Hauteur des caracteres - protected $_Char_Size = 10; - // Hauteur par defaut d'une ligne - protected $_Line_Height = 10; - // Type of metric.. Will help to calculate good values - protected $_Metric = 'mm'; - // Type of metric for the doc.. - protected $_Metric_Doc = 'mm'; - protected $_COUNTX = 1; - protected $_COUNTY = 1; - protected $_First = 1; - public $Tformat; - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore + // protected + // Nom du format de l'etiquette + protected $_Avery_Name = ''; + // Marge de gauche de l'etiquette + protected $_Margin_Left = 0; + // marge en haut de la page avant la premiere etiquette + protected $_Margin_Top = 0; + // Espace horizontal entre 2 bandes d'etiquettes + protected $_X_Space = 0; + // Espace vertical entre 2 bandes d'etiquettes + protected $_Y_Space = 0; + // NX Nombre d'etiquettes sur la largeur de la page + protected $_X_Number = 0; + // NY Nombre d'etiquettes sur la hauteur de la page + protected $_Y_Number = 0; + // Largeur de chaque etiquette + protected $_Width = 0; + // Hauteur de chaque etiquette + protected $_Height = 0; + // Hauteur des caracteres + protected $_Char_Size = 10; + // Hauteur par defaut d'une ligne + protected $_Line_Height = 10; + // Type of metric.. Will help to calculate good values + protected $_Metric = 'mm'; + // Type of metric for the doc.. + protected $_Metric_Doc = 'mm'; + protected $_COUNTX = 1; + protected $_COUNTY = 1; + protected $_First = 1; + public $Tformat; + // phpcs:enable /** * Constructor * @@ -111,7 +111,7 @@ abstract class CommonStickerGenerator $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP strem. * @@ -122,7 +122,7 @@ abstract class CommonStickerGenerator * @return int 1=OK, 0=KO */ public abstract function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = ''); - // phpcs:enable + // phpcs:enable /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) @@ -134,7 +134,7 @@ abstract class CommonStickerGenerator */ public abstract function addSticker(&$pdf, $outputlangs, $param); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Methode qui permet de modifier la taille des caracteres * Cela modiera aussi l'espace entre chaque ligne @@ -145,7 +145,7 @@ abstract class CommonStickerGenerator */ public function Set_Char_Size(&$pdf, $pt) { - // phpcs:enable + // phpcs:enable if ($pt > 3) { $this->_Char_Size = $pt; $this->_Line_Height = $this->_Get_Height_Chars($pt); @@ -153,8 +153,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * protected Print dot line * @@ -167,9 +167,9 @@ abstract class CommonStickerGenerator * @param int $nbPointilles Nb pointilles * @return void */ - protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) - { - // phpcs:enable + protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) + { + // phpcs:enable $pdf->SetLineWidth($epaisseur); $length = abs($x1 - $x2); $hauteur = abs($y1 - $y2); @@ -181,23 +181,23 @@ abstract class CommonStickerGenerator for ($i = $x1; $i <= $x2; $i += $Pointilles + $Pointilles) { for ($j = $i; $j <= ($i + $Pointilles); $j++) { if ($j <= ($x2 - 1)) { - $pdf->Line($j, $y1, $j + 1, $y1); // on trace le pointill? du haut, point par point - $pdf->Line($j, $y2, $j + 1, $y2); // on trace le pointill? du bas, point par point + $pdf->Line($j, $y1, $j + 1, $y1); // on trace le pointill? du haut, point par point + $pdf->Line($j, $y2, $j + 1, $y2); // on trace le pointill? du bas, point par point } } } for ($i = $y1; $i <= $y2; $i += $Pointilles + $Pointilles) { for ($j = $i; $j <= ($i + $Pointilles); $j++) { if ($j <= ($y2 - 1)) { - $pdf->Line($x1, $j, $x1, $j + 1); // on trace le pointill? du haut, point par point - $pdf->Line($x2, $j, $x2, $j + 1); // on trace le pointill? du bas, point par point + $pdf->Line($x1, $j, $x1, $j + 1); // on trace le pointill? du haut, point par point + $pdf->Line($x2, $j, $x2, $j + 1); // on trace le pointill? du bas, point par point } } } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Function realisant une croix aux 4 coins des cartes * @@ -212,7 +212,7 @@ abstract class CommonStickerGenerator */ protected function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4) { - // phpcs:enable + // phpcs:enable $pdf->SetDrawColor(192, 192, 192); $pdf->SetLineWidth($epaisseur); @@ -255,8 +255,8 @@ abstract class CommonStickerGenerator return $value; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Give the height for a char size given. * @@ -265,7 +265,7 @@ abstract class CommonStickerGenerator */ protected function _Get_Height_Chars($pt) { - // phpcs:enable + // phpcs:enable // Array for link between height of characters and space between lines $_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>3.5, 10=>4, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10); if (in_array($pt, array_keys($_Table_Hauteur_Chars))) { @@ -275,8 +275,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Set format * @@ -286,7 +286,7 @@ abstract class CommonStickerGenerator */ protected function _Set_Format(&$pdf, $format) { - // phpcs:enable + // phpcs:enable $this->_Metric = $format['metric']; $this->_Avery_Name = $format['name']; $this->_Avery_Code = $format['code']; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index ce726265006..5bb441ceb0a 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -32,61 +32,61 @@ */ class Conf { - /** \public */ - //! To store properties found in conf file - public $file; + /** \public */ + //! To store properties found in conf file + public $file; - /** - * @var Object Associative array with some properties ->type, ->db, ... - */ - public $db; + /** + * @var Object Associative array with some properties ->type, ->db, ... + */ + public $db; - //! To store properties found into database - public $global; - //! To store browser info - public $browser; + //! To store properties found into database + public $global; + //! To store browser info + public $browser; - //! To store if javascript/ajax is enabked - public $use_javascript_ajax; - //! To store if javascript/ajax is enabked - public $disable_compute; + //! To store if javascript/ajax is enabked + public $use_javascript_ajax; + //! To store if javascript/ajax is enabked + public $disable_compute; //! Used to store current currency (ISO code like 'USD', 'EUR', ...) public $currency; //! Used to store current css (from theme) public $theme; // Contains current theme ("eldy", "auguria", ...) public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...) - //! Used to store current menu handler + //! Used to store current menu handler public $standard_menu; - // List of activated modules - public $modules = array(); - public $modules_parts = array( - 'css' => array(), - 'js' => array(), - 'tabs' => array(), - 'triggers' => array(), - 'login' => array(), - 'substitutions' => array(), - 'menus' => array(), - 'theme' => array(), - 'sms' => array(), - 'tpl' => array(), - 'barcode' => array(), - 'models' => array(), - 'societe' => array(), - 'hooks' => array(), - 'dir' => array(), - 'syslog' => array(), - ); + // List of activated modules + public $modules = array(); + public $modules_parts = array( + 'css' => array(), + 'js' => array(), + 'tabs' => array(), + 'triggers' => array(), + 'login' => array(), + 'substitutions' => array(), + 'menus' => array(), + 'theme' => array(), + 'sms' => array(), + 'tpl' => array(), + 'barcode' => array(), + 'models' => array(), + 'societe' => array(), + 'hooks' => array(), + 'dir' => array(), + 'syslog' => array(), + ); - public $logbuffer = array(); + public $logbuffer = array(); - /** - * @var LogHandlerInterface[] - */ - public $loghandlers = array(); + /** + * @var LogHandlerInterface[] + */ + public $loghandlers = array(); - //! To store properties of multi-company - public $multicompany; + //! To store properties of multi-company + public $multicompany; //! Used to store running instance for multi-company (default 1) public $entity = 1; //! Used to store list of entities to use for each element @@ -122,7 +122,7 @@ class Conf // First level object // TODO Remove this part. $this->expedition_bon = new stdClass(); - $this->livraison_bon = new stdClass(); + $this->delivery_note = new stdClass(); $this->fournisseur = new stdClass(); $this->product = new stdClass(); $this->service = new stdClass(); @@ -212,7 +212,7 @@ class Conf elseif ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array } - // If this is a module constant (must be at end) + // If this is a module constant (must be at end) elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) { $modulename = strtolower($reg[1]); @@ -227,20 +227,20 @@ class Conf $i++; } - $db->free($resql); - } + $db->free($resql); + } - // Include other local consts.php files and fetch their values to the corresponding database constants. - if (!empty($this->global->LOCAL_CONSTS_FILES)) { - $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); - foreach ($filesList as $file) { - $file = dol_sanitizeFileName($file); - dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars. - } - } + // Include other local consts.php files and fetch their values to the corresponding database constants. + if (!empty($this->global->LOCAL_CONSTS_FILES)) { + $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); + foreach ($filesList as $file) { + $file = dol_sanitizeFileName($file); + dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars. + } + } - //var_dump($this->modules); - //var_dump($this->modules_parts['theme']); + //var_dump($this->modules); + //var_dump($this->modules_parts['theme']); // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC. // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore. @@ -296,7 +296,7 @@ class Conf // Define default dir_output and dir_temp for directories of modules foreach ($this->modules as $module) { - //var_dump($module); + //var_dump($module); // For multicompany sharings $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); $this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp"); @@ -370,8 +370,8 @@ class Conf // Sous module bons d'expedition $this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0); - // Sous module bons de livraison - $this->livraison_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_LIVRAISON) ? $this->global->MAIN_SUBMODULE_LIVRAISON : 0); + // Sub module delivery note Sous module bons de livraison + $this->delivery_note->enabled = (!empty($this->global->MAIN_SUBMODULE_DELIVERY) ? $this->global->MAIN_SUBMODULE_DELIVERY : 0); // Module fournisseur if (!empty($this->fournisseur)) @@ -450,7 +450,7 @@ class Conf // Set some default values //$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month - $this->global->MAIN_MAIL_USE_MULTI_PART = 1; + $this->global->MAIN_MAIL_USE_MULTI_PART = 1; // societe if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard"; @@ -459,9 +459,9 @@ class Conf if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint'; if (empty($this->global->TICKET_ADDON)) $this->global->TICKET_ADDON = 'mod_ticket_simple'; - // Security + // Security if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator - if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask + if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask // conf->use_javascript_ajax $this->use_javascript_ajax = 1; @@ -499,16 +499,16 @@ class Conf if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) - if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' + if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' - // By default, suppliers objects can be linked to all projects - if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; + // By default, suppliers objects can be linked to all projects + if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; - // By default we enable feature to bill time spent - if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1; + // By default we enable feature to bill time spent + if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1; - // MAIN_HTML_TITLE - if (!isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly'; + // MAIN_HTML_TITLE + if (!isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly'; // conf->liste_limit = constante de taille maximale des listes if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT = 25; @@ -520,7 +520,7 @@ class Conf // conf->theme et $this->css if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME = "eldy"; - if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME; + if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME; $this->theme = $this->global->MAIN_THEME; $this->css = "/theme/".$this->theme."/style.css.php"; @@ -537,20 +537,20 @@ class Conf if (!empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM; if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID = 1; - // Format for date (used by default when not found or not searched in lang) - $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) - $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags - $this->format_hour_short = "%H:%M"; - $this->format_hour_short_duration = "%H:%M"; - $this->format_date_text_short = "%d %b %Y"; - $this->format_date_text = "%d %B %Y"; - $this->format_date_hour_short = "%d/%m/%Y %H:%M"; - $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S"; - $this->format_date_hour_text_short = "%d %b %Y %H:%M"; - $this->format_date_hour_text = "%d %B %Y %H:%M"; + // Format for date (used by default when not found or not searched in lang) + $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) + $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags + $this->format_hour_short = "%H:%M"; + $this->format_hour_short_duration = "%H:%M"; + $this->format_date_text_short = "%d %b %Y"; + $this->format_date_text = "%d %B %Y"; + $this->format_date_hour_short = "%d/%m/%Y %H:%M"; + $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S"; + $this->format_date_hour_text_short = "%d %b %Y %H:%M"; + $this->format_date_hour_text = "%d %B %Y %H:%M"; - // Duration of workday - if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY = 86400; + // Duration of workday + if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY = 86400; // Limites decimales si non definie (peuvent etre egale a 0) if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT = 5; @@ -590,76 +590,76 @@ class Conf if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2'; // Timeouts - if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT = 10; - if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30; + if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT = 10; + if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30; // Set default variable to calculate VAT as if option tax_mode was 0 (standard) - if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT = 'invoice'; - if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT = 'invoice'; - if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE = 'payment'; - if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment'; + if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT = 'invoice'; + if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT = 'invoice'; + if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE = 'payment'; + if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment'; // Delay before warnings // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx if (isset($this->agenda)) { - $this->adherent->subscription = new stdClass(); - $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 86400; + $this->adherent->subscription = new stdClass(); + $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 86400; } if (isset($this->agenda)) { $this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 86400; - } + } if (isset($this->projet)) { $this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 86400; - $this->projet->task = new StdClass(); - $this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400; + $this->projet->task = new StdClass(); + $this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400; } - if (isset($this->commande)) { - $this->commande->client = new stdClass(); - $this->commande->fournisseur = new stdClass(); - $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400; - $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 86400; + if (isset($this->commande)) { + $this->commande->client = new stdClass(); + $this->commande->fournisseur = new stdClass(); + $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400; + $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 86400; } if (isset($this->propal)) { - $this->propal->cloture = new stdClass(); - $this->propal->facturation = new stdClass(); - $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400; - $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400; + $this->propal->cloture = new stdClass(); + $this->propal->facturation = new stdClass(); + $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400; + $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400; } if (isset($this->facture)) { - $this->facture->client = new stdClass(); - $this->facture->fournisseur = new stdClass(); - $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400; - $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 86400; + $this->facture->client = new stdClass(); + $this->facture->fournisseur = new stdClass(); + $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400; + $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 86400; } if (isset($this->contrat)) { - $this->contrat->services = new stdClass(); - $this->contrat->services->inactifs = new stdClass(); - $this->contrat->services->expires = new stdClass(); - $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400; - $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400; + $this->contrat->services = new stdClass(); + $this->contrat->services->inactifs = new stdClass(); + $this->contrat->services->expires = new stdClass(); + $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400; + $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400; } if (isset($this->commande)) { - $this->bank->rappro = new stdClass(); - $this->bank->cheque = new stdClass(); - $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400; - $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400; + $this->bank->rappro = new stdClass(); + $this->bank->cheque = new stdClass(); + $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400; + $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400; } if (isset($this->expensereport)) { - $this->expensereport->approve = new stdClass(); - $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400; - $this->expensereport->payment = new stdClass(); - $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400; + $this->expensereport->approve = new stdClass(); + $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400; + $this->expensereport->payment = new stdClass(); + $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400; + } + if (isset($this->holiday)) { + $this->holiday->approve = new stdClass(); + $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400; } - if (isset($this->holiday)) { - $this->holiday->approve = new stdClass(); - $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400; - } if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) { - $this->global->PRODUIT_MULTIPRICES_LIMIT = 5; + $this->global->PRODUIT_MULTIPRICES_LIMIT = 5; } // For modules that want to disable top or left menu @@ -695,13 +695,13 @@ class Conf if (isset($this->categorie)) $this->category = $this->categorie; if (isset($this->project)) $this->project = $this->projet; - // Object $mc - if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) - { - if (is_object($mc)) $mc->setValues($this); - } + // Object $mc + if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) + { + if (is_object($mc)) $mc->setValues($this); + } - if (!empty($this->syslog->enabled)) { + if (!empty($this->syslog->enabled)) { // We init log handlers if (!empty($this->global->SYSLOG_HANDLERS)) { $handlers = json_decode($this->global->SYSLOG_HANDLERS); @@ -737,6 +737,8 @@ class Conf $this->loghandlers[$handler] = $loghandlerinstance; } } - } + } + + return 0; } } diff --git a/htdocs/core/class/cproductnature.class.php b/htdocs/core/class/cproductnature.class.php new file mode 100644 index 00000000000..eb16cff53ea --- /dev/null +++ b/htdocs/core/class/cproductnature.class.php @@ -0,0 +1,340 @@ + + * Copyright (C) 2020 Florian HENRY + * + * 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/cproductnature.class.php + * \ingroup core + * \brief This file is CRUD class file (Create/Read/Update/Delete) for c_units dictionary + */ + + +/** + * Class of dictionary of nature of product (used by imports) + */ +class CProductNature // extends CommonObject +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); + + /** + * @var array record + */ + public $records = array(); + + /** + * @var string element + */ + public $element = 'cproductnbature'; + + /** + * @var string table element + */ + public $table_element = 'c_product_nature'; + + /** + * @var int ID + */ + public $id; + + /** + * @var int code + */ + public $code; + + /** + * @var string label + */ + public $label; + + /** + * @var int active + */ + public $active; + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; + $sql .= "rowid,"; + $sql .= "code,"; + $sql .= "label,"; + $sql .= "active"; + $sql .= ") VALUES ("; + $sql .= " ".(!isset($this->id) ? 'NULL' : ((int) $this->id)).","; + $sql .= " ".(!isset($this->code) ? 'NULL' : ((int) $this->code)).","; + $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape(trim($this->label))."'").","; + $sql .= " ".(!isset($this->active) ? 'NULL' : ((int) $this->active)).","; + $sql .= ")"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + // Commit or rollback + if (!$resql) { + dol_syslog(get_class($this)."::create ".$this->db->lasterror(), LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + $this->db->rollback(); + return -1; + } else { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + $this->db->commit(); + return $this->id; + } + } + + + /** + * Load object in memory from database + * + * @param int $id Id of CUnit object to fetch (rowid) + * @param string $code Code + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '') + { + global $langs; + + $sql = "SELECT"; + $sql .= " t.rowid,"; + $sql .= " t.code,"; + $sql .= " t.label,"; + $sql .= " t.active"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql_where = array(); + if ($id) $sql_where[] = " t.rowid = ".$id; + if ($code >= 0) $sql_where[] = " t.code = ".((int) $code); + if (count($sql_where) > 0) { + $sql .= ' WHERE '.implode(' AND ', $sql_where); + } + + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->code = $obj->code; + $this->label = $obj->label; + $this->active = $obj->active; + } + $this->db->free($resql); + + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= " t.rowid,"; + $sql .= " t.code,"; + $sql .= " t.label,"; + $sql .= " t.active"; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid' || $key == 't.active' || $key == 't.code') { + $sqlwhere[] = $key.'='.(int) $value; + } elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 't.label') { + $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ('.implode(' '.$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) { + $this->records = array(); + $num = $this->db->num_rows($resql); + if ($num > 0) { + while ($obj = $this->db->fetch_object($resql)) + { + $record = new self($this->db); + + $record->id = $obj->rowid; + $record->code = $obj->code; + $record->label = $obj->label; + $this->records[$record->id] = $record; + } + } + $this->db->free($resql); + + return $this->records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; + $sql .= " code=".(isset($this->code) ? ((int) $this->code) : "null").","; + $sql .= " label=".(isset($this->label) ? "'".$this->db->escape(trim($this->label))."'" : "null").","; + $sql .= " active=".(isset($this->active) ? ((int) $this->active) : "null"); + $sql .= " WHERE rowid=".(int) $this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + // Commit or rollback + if (!$resql) { + dol_syslog(get_class($this)."::update Error ".$this->db->lasterror(), LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete($user, $notrigger = 0) + { + global $conf, $langs; + $error = 0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE rowid=".(int) $this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + // Commit or rollback + if (!$resql) { + dol_syslog(get_class($this)."::delete Error ".$this->db->lasterror(), LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } + + + /** + * Get unit from code + * @param int $code code of unit + * @param string $mode 0= id , short_label=Use short label as value, code=use code + * @return int <0 if KO, Id of code if OK + */ + public function getProductNatureFromCode($code, $mode = 'code') + { + if ($mode == 'label') { + return dol_getIdFromCode($this->db, $code, $this->table_element, 'label', 'code'); + } elseif ($mode == 'code') { + return dol_getIdFromCode($this->db, $code, $this->table_element, 'code', 'code'); + } + + return $code; + } +} diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index 80c47591fbb..75ef9cc7f77 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -27,9 +27,9 @@ class Cstate // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -44,7 +44,7 @@ class Cstate // extends CommonObject //var $element='cstate'; //!< Id that identify managed objects //var $table_element='cstate'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -68,27 +68,27 @@ class Cstate // extends CommonObject - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -99,13 +99,13 @@ class Cstate // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_departements("; $sql .= "rowid,"; $sql .= "code_departement,"; $sql .= "nom,"; $sql .= "active"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; $sql .= " ".(!isset($this->code_departement) ? 'NULL' : "'".$this->db->escape($this->code_departement)."'").","; $sql .= " ".(!isset($this->nom) ? 'NULL' : "'".$this->db->escape($this->nom)."'").","; @@ -115,84 +115,84 @@ class Cstate // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); - } + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @param string $code Code - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '') - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '') + { + global $langs; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code_departement,"; $sql .= " t.nom,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t"; - if ($id) $sql .= " WHERE t.rowid = ".$id; - elseif ($code) $sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t"; + if ($id) $sql .= " WHERE t.rowid = ".$id; + elseif ($code) $sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->code_departement = $obj->code_departement; //deprecated + $this->id = $obj->rowid; + $this->code_departement = $obj->code_departement; //deprecated $this->code = $obj->code_departement; - $this->nom = $obj->nom; //deprecated + $this->nom = $obj->nom; //deprecated $this->name = $obj->nom; $this->active = $obj->active; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -204,40 +204,40 @@ class Cstate // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET"; $sql .= " code_departement=".(isset($this->code_departement) ? "'".$this->db->escape($this->code_departement)."'" : "null").","; $sql .= " nom=".(isset($this->nom) ? "'".$this->db->escape($this->nom)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null").""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback - if ($error) { - foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } /** * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -250,15 +250,15 @@ class Cstate // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 07d3563088e..fccdec72ab6 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -28,9 +28,9 @@ class Ctypent // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -45,7 +45,7 @@ class Ctypent // extends CommonObject //var $element='ctypent'; //!< Id that identify managed objects //var $table_element='ctypent'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -58,27 +58,27 @@ class Ctypent // extends CommonObject - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -94,7 +94,7 @@ class Ctypent // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_typent("; $sql .= "id,"; @@ -104,7 +104,7 @@ class Ctypent // extends CommonObject $sql .= "module"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->id) ? 'NULL' : "'".$this->db->escape($this->id)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; @@ -118,88 +118,88 @@ class Ctypent // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent"); - } + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @param string $code Code - * @param string $label Label - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '', $label = '') - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @param string $label Label + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '', $label = '') + { + global $langs; + $sql = "SELECT"; $sql .= " t.id,"; $sql .= " t.code,"; $sql .= " t.libelle as label,"; $sql .= " t.fk_country as country_id,"; $sql .= " t.active,"; $sql .= " t.module"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t"; - if ($id) $sql .= " WHERE t.id = ".$id; - elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; - elseif ($label) $sql .= " WHERE t.libelle = '".$this->db->escape($label)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t"; + if ($id) $sql .= " WHERE t.id = ".$id; + elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($label) $sql .= " WHERE t.libelle = '".$this->db->escape($label)."'"; - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->id; + $this->id = $obj->id; $this->code = $obj->code; $this->libelle = $obj->label; $this->country_id = $obj->country_id; $this->active = $obj->active; $this->module = $obj->module; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -212,27 +212,27 @@ class Ctypent // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_typent SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_typent SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " libelle=".(isset($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null").","; $sql .= " module=".(isset($this->module) ? "'".$this->db->escape($this->module)."'" : "null").""; - $sql .= " WHERE id=".$this->id; + $sql .= " WHERE id=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -240,16 +240,16 @@ class Ctypent // extends CommonObject $this->db->commit(); return 1; } - } + } /** - * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -262,21 +262,21 @@ class Ctypent // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback - if ($error) - { + // Commit or rollback + if ($error) + { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } + } else { + $this->db->commit(); + return 1; + } + } } diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 410c3ae3f21..9d1e5c53de1 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -50,9 +50,9 @@ class Ctyperesource public $code; /** - * @var string Type resource label - */ - public $label; + * @var string Type resource label + */ + public $label; public $active; @@ -252,7 +252,7 @@ class Ctyperesource $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -482,9 +482,9 @@ class CtyperesourceLine public $code; /** - * @var string Type resource line label - */ - public $label; + * @var string Type resource line label + */ + public $label; public $active; diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index ac7b07ea5a9..c94919eb1dc 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -28,9 +28,9 @@ class CUnits // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -46,7 +46,7 @@ class CUnits // extends CommonObject //var $element='ctypent'; //!< Id that identify managed objects //var $table_element='ctypent'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -61,27 +61,27 @@ class CUnits // extends CommonObject - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -97,7 +97,7 @@ class CUnits // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_units("; $sql .= "rowid,"; $sql .= "code,"; @@ -105,7 +105,7 @@ class CUnits // extends CommonObject $sql .= "short_label,"; $sql .= "unit_type"; $sql .= "scale"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->id) ? 'NULL' : "'".$this->db->escape($this->id)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").","; @@ -117,45 +117,45 @@ class CUnits // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units"); - } + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id of CUnit object to fetch (rowid) - * @param string $code Code - * @param string $short_label Short Label ('g', 'kg', ...) - * @param string $unit_type Unit type ('size', 'surface', 'volume', 'weight', ...) - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '', $short_label = '', $unit_type = '') - { - global $langs; + /** + * Load object in memory from database + * + * @param int $id Id of CUnit object to fetch (rowid) + * @param string $code Code + * @param string $short_label Short Label ('g', 'kg', ...) + * @param string $unit_type Unit type ('size', 'surface', 'volume', 'weight', ...) + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '', $short_label = '', $unit_type = '') + { + global $langs; - $sql = "SELECT"; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code,"; $sql .= " t.label,"; @@ -164,24 +164,24 @@ class CUnits // extends CommonObject $sql .= " t.unit_type,"; $sql .= " t.scale,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; - $sql_where = array(); - if ($id) $sql_where[] = " t.rowid = ".$id; - if ($unit_type) $sql_where[] = " t.unit_type = '".$this->db->escape($unit_type)."'"; - if ($code) $sql_where[] = " t.code = '".$this->db->escape($code)."'"; - if ($short_label) $sql_where[] = " t.short_label = '".$this->db->escape($short_label)."'"; - if (count($sql_where) > 0) { - $sql .= ' WHERE '.implode(' AND ', $sql_where); - } + $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; + $sql_where = array(); + if ($id) $sql_where[] = " t.rowid = ".$id; + if ($unit_type) $sql_where[] = " t.unit_type = '".$this->db->escape($unit_type)."'"; + if ($code) $sql_where[] = " t.code = '".$this->db->escape($code)."'"; + if ($short_label) $sql_where[] = " t.short_label = '".$this->db->escape($short_label)."'"; + if (count($sql_where) > 0) { + $sql .= ' WHERE '.implode(' AND ', $sql_where); + } - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code = $obj->code; $this->label = $obj->label; $this->short_label = $obj->short_label; @@ -189,110 +189,109 @@ class CUnits // extends CommonObject $this->unit_type = $obj->unit_type; $this->scale = $obj->scale; $this->active = $obj->active; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $sql = 'SELECT'; - $sql .= " t.rowid,"; - $sql .= " t.code,"; - $sql .= " t.label,"; - $sql .= " t.short_label,"; - $sql .= " t.unit_type,"; - $sql .= " t.scale,"; - $sql .= " t.active"; - $sql .= ' FROM '.MAIN_DB_PREFIX.'c_units as t'; - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid' || $key == 't.active' || $key == 't.scale') { - $sqlwhere[] = $key.'='.(int) $value; - } elseif (strpos($key, 'date') !== false) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 't.unit_type' || $key == 't.code' || $key == 't.short_label') { - $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } + $sql = 'SELECT'; + $sql .= " t.rowid,"; + $sql .= " t.code,"; + $sql .= " t.label,"; + $sql .= " t.short_label,"; + $sql .= " t.unit_type,"; + $sql .= " t.scale,"; + $sql .= " t.active"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'c_units as t'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid' || $key == 't.active' || $key == 't.scale') { + $sqlwhere[] = $key.'='.(int) $value; + } elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 't.unit_type' || $key == 't.code' || $key == 't.short_label') { + $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } + 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) { - $this->records = array(); - $num = $this->db->num_rows($resql); - if ($num > 0) { - while ($obj = $this->db->fetch_object($resql)) - { - $record = new self($this->db); + $resql = $this->db->query($sql); + if ($resql) { + $this->records = array(); + $num = $this->db->num_rows($resql); + if ($num > 0) { + while ($obj = $this->db->fetch_object($resql)) { + $record = new self($this->db); - $record->id = $obj->rowid; - $record->code = $obj->code; - $record->label = $obj->label; - $record->short_label = $obj->short_label; - $record->unit_type = $obj->unit_type; - $record->scale = $obj->scale; - $record->active = $obj->active; - $this->records[$record->id] = $record; - } - } - $this->db->free($resql); + $record->id = $obj->rowid; + $record->code = $obj->code; + $record->label = $obj->label; + $record->short_label = $obj->short_label; + $record->unit_type = $obj->unit_type; + $record->scale = $obj->scale; + $record->active = $obj->active; + $this->records[$record->id] = $record; + } + } + $this->db->free($resql); - return $this->records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + return $this->records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return -1; - } - } + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -306,29 +305,29 @@ class CUnits // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " short_label=".(isset($this->short_label) ? "'".$this->db->escape($this->short_label)."'" : "null").","; $sql .= " unit_type=".(isset($this->unit_type) ? "'".$this->db->escape($this->unit_type)."'" : "null").","; $sql .= " scale=".(isset($this->scale) ? "'".$this->db->escape($this->scale)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null"); - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -336,16 +335,16 @@ class CUnits // extends CommonObject $this->db->commit(); return 1; } - } + } /** - * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -358,15 +357,15 @@ class CUnits // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -386,9 +385,9 @@ class CUnits // extends CommonObject public function getUnitFromCode($code, $mode = 'code') { - if ($mode == 'short_label'){ + if ($mode == 'short_label') { return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid'); - } elseif ($mode == 'code'){ + } elseif ($mode == 'code') { return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid'); } @@ -404,21 +403,21 @@ class CUnits // extends CommonObject */ public function unitConverter($value, $fk_unit, $fk_new_unit = 0) { - $value = doubleval(price2num($value)); + $value = doubleval(price2num($value)); $fk_unit = intval($fk_unit); // Calcul en unité de base $scaleUnitPow = $this->scaleOfUnitPow($fk_unit); // convert to standard unit - $value = $value * $scaleUnitPow; - if ($fk_new_unit !=0 ){ + $value = $value * $scaleUnitPow; + if ($fk_new_unit != 0) { // Calcul en unité de base $scaleUnitPow = $this->scaleOfUnitPow($fk_new_unit); if (!empty($scaleUnitPow)) { // convert to new unit - $value = $value / $scaleUnitPow; + $value = $value / $scaleUnitPow; } } return round($value, 2); diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 4cddc65d636..9f901ed3452 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -28,12 +28,12 @@ */ class DiscountAbsolute { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error; @@ -48,190 +48,190 @@ class DiscountAbsolute */ public $id; - /** + /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; - public $discount_type; // 0 => customer discount, 1 => supplier discount - public $amount_ht; // - public $amount_tva; // - public $amount_ttc; // - public $multicurrency_amount_ht; - public $multicurrency_amount_tva; - public $multicurrency_amount_ttc; - // Vat rate - public $tva_tx; - public $vat_src_code; + public $discount_type; // 0 => customer discount, 1 => supplier discount + public $amount_ht; // + public $amount_tva; // + public $amount_ttc; // + public $multicurrency_amount_ht; + public $multicurrency_amount_tva; + public $multicurrency_amount_ttc; + // Vat rate + public $tva_tx; + public $vat_src_code; - /** + /** * @var int User ID Id utilisateur qui accorde la remise */ public $fk_user; - /** + /** * @var string description */ public $description; - /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + /** + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * @var int ID invoice line when a discount is used into an invoice line (for absolute discounts) - */ - public $fk_facture_line; + /** + * @var int ID invoice line when a discount is used into an invoice line (for absolute discounts) + */ + public $fk_facture_line; - /** - * @var int ID invoice when a discount line is used into an invoice (for credit note) - */ - public $fk_facture; + /** + * @var int ID invoice when a discount line is used into an invoice (for credit note) + */ + public $fk_facture; - /** - * @var int ID credit note or deposit used to create the discount - */ - public $fk_facture_source; - public $ref_facture_source; // Ref credit note or deposit used to create the discount + /** + * @var int ID credit note or deposit used to create the discount + */ + public $fk_facture_source; + public $ref_facture_source; // Ref credit note or deposit used to create the discount public $type_facture_source; - public $fk_invoice_supplier_source; - public $ref_invoice_supplier_source; // Ref credit note or deposit used to create the discount - public $type_invoice_supplier_source; + public $fk_invoice_supplier_source; + public $ref_invoice_supplier_source; // Ref credit note or deposit used to create the discount + public $type_invoice_supplier_source; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Load object from database into memory - * - * @param int $rowid id discount to load - * @param int $fk_facture_source fk_facture_source - * @param int $fk_invoice_supplier_source fk_invoice_supplier_source - * @return int <0 if KO, =0 if not found, >0 if OK - */ - public function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) - { - global $conf; + /** + * Load object from database into memory + * + * @param int $rowid id discount to load + * @param int $fk_facture_source fk_facture_source + * @param int $fk_invoice_supplier_source fk_invoice_supplier_source + * @return int <0 if KO, =0 if not found, >0 if OK + */ + public function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) + { + global $conf; - // Check parameters - if (!$rowid && !$fk_facture_source && !$fk_invoice_supplier_source) - { - $this->error = 'ErrorBadParameters'; - return -1; - } + // Check parameters + if (!$rowid && !$fk_facture_source && !$fk_invoice_supplier_source) + { + $this->error = 'ErrorBadParameters'; + return -1; + } - $sql = "SELECT sr.rowid, sr.fk_soc, sr.discount_type,"; - $sql .= " sr.fk_user,"; - $sql .= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx, sr.vat_src_code,"; - $sql .= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; - $sql .= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,"; - $sql .= " sr.datec,"; - $sql .= " f.ref as ref_facture_source, f.type as type_facture_source,"; - $sql .= " fsup.ref as ref_invoice_supplier_source, fsup.type as type_invoice_supplier_source"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; - $sql .= " WHERE sr.entity IN (".getEntity('invoice').")"; - if ($rowid) $sql .= " AND sr.rowid=".$rowid; - if ($fk_facture_source) $sql .= " AND sr.fk_facture_source=".$fk_facture_source; - if ($fk_invoice_supplier_source) $sql .= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; + $sql = "SELECT sr.rowid, sr.fk_soc, sr.discount_type,"; + $sql .= " sr.fk_user,"; + $sql .= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx, sr.vat_src_code,"; + $sql .= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; + $sql .= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,"; + $sql .= " sr.datec,"; + $sql .= " f.ref as ref_facture_source, f.type as type_facture_source,"; + $sql .= " fsup.ref as ref_invoice_supplier_source, fsup.type as type_invoice_supplier_source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; + $sql .= " WHERE sr.entity IN (".getEntity('invoice').")"; + if ($rowid) $sql .= " AND sr.rowid=".$rowid; + if ($fk_facture_source) $sql .= " AND sr.fk_facture_source=".$fk_facture_source; + if ($fk_invoice_supplier_source) $sql .= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->fk_soc = $obj->fk_soc; - $this->discount_type = $obj->discount_type; + $this->id = $obj->rowid; + $this->fk_soc = $obj->fk_soc; + $this->discount_type = $obj->discount_type; - $this->amount_ht = $obj->amount_ht; - $this->amount_tva = $obj->amount_tva; - $this->amount_ttc = $obj->amount_ttc; + $this->amount_ht = $obj->amount_ht; + $this->amount_tva = $obj->amount_tva; + $this->amount_ttc = $obj->amount_ttc; - $this->multicurrency_amount_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht; - $this->multicurrency_amount_tva = $obj->multicurrency_amount_tva; - $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; + $this->multicurrency_amount_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht; + $this->multicurrency_amount_tva = $obj->multicurrency_amount_tva; + $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; - $this->tva_tx = $obj->tva_tx; - $this->vat_src_code = $obj->vat_src_code; + $this->tva_tx = $obj->tva_tx; + $this->vat_src_code = $obj->vat_src_code; - $this->fk_user = $obj->fk_user; - $this->fk_facture_line = $obj->fk_facture_line; - $this->fk_facture = $obj->fk_facture; - $this->fk_facture_source = $obj->fk_facture_source; // Id credit note or deposit source - $this->ref_facture_source = $obj->ref_facture_source; // Ref credit note or deposit source - $this->type_facture_source = $obj->type_facture_source; // Type credit note or deposit source - $this->fk_invoice_supplier_line = $obj->fk_invoice_supplier_line; - $this->fk_invoice_supplier = $obj->fk_invoice_supplier; - $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id credit note or deposit source - $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref credit note or deposit source - $this->type_invoice_supplier_source = $obj->type_invoice_supplier_source; // Type credit note or deposit source - $this->description = $obj->description; - $this->datec = $this->db->jdate($obj->datec); + $this->fk_user = $obj->fk_user; + $this->fk_facture_line = $obj->fk_facture_line; + $this->fk_facture = $obj->fk_facture; + $this->fk_facture_source = $obj->fk_facture_source; // Id credit note or deposit source + $this->ref_facture_source = $obj->ref_facture_source; // Ref credit note or deposit source + $this->type_facture_source = $obj->type_facture_source; // Type credit note or deposit source + $this->fk_invoice_supplier_line = $obj->fk_invoice_supplier_line; + $this->fk_invoice_supplier = $obj->fk_invoice_supplier; + $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id credit note or deposit source + $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref credit note or deposit source + $this->type_invoice_supplier_source = $obj->type_invoice_supplier_source; // Type credit note or deposit source + $this->description = $obj->description; + $this->datec = $this->db->jdate($obj->datec); - $this->db->free($resql); - return 1; - } else { - $this->db->free($resql); - return 0; - } - } else { - $this->error = $this->db->error(); - return -1; - } - } + $this->db->free($resql); + return 1; + } else { + $this->db->free($resql); + return 0; + } + } else { + $this->error = $this->db->error(); + return -1; + } + } - /** - * Create a discount into database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - public function create($user) - { - global $conf, $langs; + /** + * Create a discount into database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf, $langs; - // Clean parameters - $this->amount_ht = price2num($this->amount_ht); - $this->amount_tva = price2num($this->amount_tva); - $this->amount_ttc = price2num($this->amount_ttc); + // Clean parameters + $this->amount_ht = price2num($this->amount_ht); + $this->amount_tva = price2num($this->amount_tva); + $this->amount_ttc = price2num($this->amount_ttc); - $this->tva_tx = price2num($this->tva_tx); + $this->tva_tx = price2num($this->tva_tx); - $this->multicurrency_amount_ht = price2num($this->multicurrency_amount_ht); - $this->multicurrency_amount_tva = price2num($this->multicurrency_amount_tva); - $this->multicurrency_amount_ttc = price2num($this->multicurrency_amount_ttc); + $this->multicurrency_amount_ht = price2num($this->multicurrency_amount_ht); + $this->multicurrency_amount_tva = price2num($this->multicurrency_amount_tva); + $this->multicurrency_amount_ttc = price2num($this->multicurrency_amount_ttc); - if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht = 0; - if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva = 0; - if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc = 0; + if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht = 0; + if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva = 0; + if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc = 0; - // Check parameters - if (empty($this->description)) - { - $this->error = 'BadValueForPropertyDescription'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -1; - } + // Check parameters + if (empty($this->description)) + { + $this->error = 'BadValueForPropertyDescription'; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -1; + } - $userid = $user->id; + $userid = $user->id; if (!($userid > 0)) // For example when record is saved into an anonymous context with a not loaded object $user. { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -240,463 +240,463 @@ class DiscountAbsolute $userid = $tmpinvoice->fk_user_author; // We use the author of invoice } - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except"; - $sql .= " (entity, datec, fk_soc, discount_type, fk_user, description,"; - $sql .= " amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code,"; - $sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,"; - $sql .= " fk_facture_source, fk_invoice_supplier_source"; - $sql .= ")"; - $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".$this->fk_soc.", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".$userid.", '".$this->db->escape($this->description)."',"; - $sql .= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.", '".$this->db->escape($this->vat_src_code)."',"; - $sql .= " ".$this->multicurrency_amount_ht.", ".$this->multicurrency_amount_tva.", ".$this->multicurrency_amount_ttc.", "; - $sql .= " ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null").","; - $sql .= " ".($this->fk_invoice_supplier_source ? "'".$this->db->escape($this->fk_invoice_supplier_source)."'" : "null"); - $sql .= ")"; + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except"; + $sql .= " (entity, datec, fk_soc, discount_type, fk_user, description,"; + $sql .= " amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code,"; + $sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,"; + $sql .= " fk_facture_source, fk_invoice_supplier_source"; + $sql .= ")"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".$this->fk_soc.", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".$userid.", '".$this->db->escape($this->description)."',"; + $sql .= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.", '".$this->db->escape($this->vat_src_code)."',"; + $sql .= " ".$this->multicurrency_amount_ht.", ".$this->multicurrency_amount_tva.", ".$this->multicurrency_amount_ttc.", "; + $sql .= " ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null").","; + $sql .= " ".($this->fk_invoice_supplier_source ? "'".$this->db->escape($this->fk_invoice_supplier_source)."'" : "null"); + $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); - return $this->id; - } else { - $this->error = $this->db->lasterror().' - sql='.$sql; - return -1; - } - } + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); + return $this->id; + } else { + $this->error = $this->db->lasterror().' - sql='.$sql; + return -1; + } + } - /** - * Delete object in database. If fk_facture_source is defined, we delete all familiy with same fk_facture_source. If not, only with id is removed - * - * @param User $user Object of user asking to delete - * @return int <0 if KO, >0 if OK - */ - public function delete($user) - { - global $conf, $langs; + /** + * Delete object in database. If fk_facture_source is defined, we delete all familiy with same fk_facture_source. If not, only with id is removed + * + * @param User $user Object of user asking to delete + * @return int <0 if KO, >0 if OK + */ + public function delete($user) + { + global $conf, $langs; - // Check if we can remove the discount - if ($this->fk_facture_source) - { - $sql = "SELECT COUNT(rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; - $sql .= " WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount - $sql .= " OR fk_facture IS NOT NULL)"; // Not used as credit note and not used as deposit - $sql .= " AND fk_facture_source = ".$this->fk_facture_source; - //$sql.=" AND rowid != ".$this->id; + // Check if we can remove the discount + if ($this->fk_facture_source) + { + $sql = "SELECT COUNT(rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; + $sql .= " WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount + $sql .= " OR fk_facture IS NOT NULL)"; // Not used as credit note and not used as deposit + $sql .= " AND fk_facture_source = ".$this->fk_facture_source; + //$sql.=" AND rowid != ".$this->id; - dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj->nb > 0) - { - $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; - return -2; - } - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj->nb > 0) + { + $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; + return -2; + } + } else { + dol_print_error($this->db); + return -1; + } + } - // Check if we can remove the discount - if ($this->fk_invoice_supplier_source) - { - $sql = "SELECT COUNT(rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; - $sql .= " WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount - $sql .= " OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit - $sql .= " AND fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; - //$sql.=" AND rowid != ".$this->id; + // Check if we can remove the discount + if ($this->fk_invoice_supplier_source) + { + $sql = "SELECT COUNT(rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; + $sql .= " WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount + $sql .= " OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit + $sql .= " AND fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; + //$sql.=" AND rowid != ".$this->id; - dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj->nb > 0) - { - $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; - return -2; - } - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj->nb > 0) + { + $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; + return -2; + } + } else { + dol_print_error($this->db); + return -1; + } + } - $this->db->begin(); + $this->db->begin(); - // Delete but only if not used - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; - if ($this->fk_facture_source) $sql .= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie - elseif ($this->fk_invoice_supplier_source) $sql .= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie - else $sql .= " WHERE rowid = ".$this->id; // Delete only line - $sql .= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount - $sql .= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit - $sql .= " AND (fk_invoice_supplier_line IS NULL"; // Not used as absolute simple discount - $sql .= " AND fk_invoice_supplier IS NULL)"; // Not used as credit note and not used as deposit + // Delete but only if not used + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; + if ($this->fk_facture_source) $sql .= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie + elseif ($this->fk_invoice_supplier_source) $sql .= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie + else $sql .= " WHERE rowid = ".$this->id; // Delete only line + $sql .= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount + $sql .= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit + $sql .= " AND (fk_invoice_supplier_line IS NULL"; // Not used as absolute simple discount + $sql .= " AND fk_invoice_supplier IS NULL)"; // Not used as credit note and not used as deposit - dol_syslog(get_class($this)."::delete Delete discount", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - // If source of discount was a credit note or deposit, we change source statut. - if ($this->fk_facture_source) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $sql .= " set paye=0, fk_statut=1"; - $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source; + dol_syslog(get_class($this)."::delete Delete discount", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + // If source of discount was a credit note or deposit, we change source statut. + if ($this->fk_facture_source) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; + $sql .= " set paye=0, fk_statut=1"; + $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source; - dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } elseif ($this->fk_invoice_supplier_source) { - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; - $sql .= " set paye=0, fk_statut=1"; - $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_invoice_supplier_source; + dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } elseif ($this->fk_invoice_supplier_source) { + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; + $sql .= " set paye=0, fk_statut=1"; + $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_invoice_supplier_source; - dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } else { - $this->db->commit(); - return 1; - } - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } + dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } else { + $this->db->commit(); + return 1; + } + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Link the discount to a particular invoice line or a particular invoice. - * When discount is a global discount used as an invoice line, we link using rowidline. - * When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice - * - * @param int $rowidline Invoice line id (To use discount into invoice lines) - * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) - * @return int <0 if KO, >0 if OK - */ - public function link_to_invoice($rowidline, $rowidinvoice) - { - // phpcs:enable - // Check parameters - if (!$rowidline && !$rowidinvoice) - { - $this->error = 'ErrorBadParameters'; - return -1; - } - if ($rowidline && $rowidinvoice) - { - $this->error = 'ErrorBadParameters'; - return -2; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Link the discount to a particular invoice line or a particular invoice. + * When discount is a global discount used as an invoice line, we link using rowidline. + * When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice + * + * @param int $rowidline Invoice line id (To use discount into invoice lines) + * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) + * @return int <0 if KO, >0 if OK + */ + public function link_to_invoice($rowidline, $rowidinvoice) + { + // phpcs:enable + // Check parameters + if (!$rowidline && !$rowidinvoice) + { + $this->error = 'ErrorBadParameters'; + return -1; + } + if ($rowidline && $rowidinvoice) + { + $this->error = 'ErrorBadParameters'; + return -2; + } - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; - if (!empty($this->discount_type)) { - if ($rowidline) $sql .= " SET fk_invoice_supplier_line = ".$rowidline; - if ($rowidinvoice) $sql .= " SET fk_invoice_supplier = ".$rowidinvoice; - } else { - if ($rowidline) $sql .= " SET fk_facture_line = ".$rowidline; - if ($rowidinvoice) $sql .= " SET fk_facture = ".$rowidinvoice; - } - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; + if (!empty($this->discount_type)) { + if ($rowidline) $sql .= " SET fk_invoice_supplier_line = ".$rowidline; + if ($rowidinvoice) $sql .= " SET fk_invoice_supplier = ".$rowidinvoice; + } else { + if ($rowidline) $sql .= " SET fk_facture_line = ".$rowidline; + if ($rowidinvoice) $sql .= " SET fk_facture = ".$rowidinvoice; + } + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::link_to_invoice", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if (!empty($this->discount_type)) { - $this->fk_invoice_supplier_line = $rowidline; - $this->fk_invoice_supplier = $rowidinvoice; - } else { - $this->fk_facture_line = $rowidline; - $this->fk_facture = $rowidinvoice; - } - return 1; - } else { - $this->error = $this->db->error(); - return -3; - } - } + dol_syslog(get_class($this)."::link_to_invoice", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if (!empty($this->discount_type)) { + $this->fk_invoice_supplier_line = $rowidline; + $this->fk_invoice_supplier = $rowidinvoice; + } else { + $this->fk_facture_line = $rowidline; + $this->fk_facture = $rowidinvoice; + } + return 1; + } else { + $this->error = $this->db->error(); + return -3; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Link the discount to a particular invoice line or a particular invoice. - * Do not call this if discount is linked to a reconcialiated invoice - * - * @return int <0 if KO, >0 if OK - */ - public function unlink_invoice() - { - // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; - if (!empty($this->discount_type)) { - $sql .= " SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL"; - } else { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Link the discount to a particular invoice line or a particular invoice. + * Do not call this if discount is linked to a reconcialiated invoice + * + * @return int <0 if KO, >0 if OK + */ + public function unlink_invoice() + { + // phpcs:enable + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; + if (!empty($this->discount_type)) { + $sql .= " SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL"; + } else { $sql .= " SET fk_facture_line = NULL, fk_facture = NULL"; } - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::unlink_invoice", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - return 1; - } else { - $this->error = $this->db->error(); - return -3; - } - } + dol_syslog(get_class($this)."::unlink_invoice", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + return 1; + } else { + $this->error = $this->db->error(); + return -3; + } + } - /** - * Return amount (with tax) of discounts currently available for a company, user or other criteria - * - * @param Societe $company Object third party for filter - * @param User $user Filtre sur un user auteur des remises - * @param string $filter Filtre autre - * @param int $maxvalue Filter on max value for discount - * @param int $discount_type 0 => customer discount, 1 => supplier discount + /** + * Return amount (with tax) of discounts currently available for a company, user or other criteria + * + * @param Societe $company Object third party for filter + * @param User $user Filtre sur un user auteur des remises + * @param string $filter Filtre autre + * @param int $maxvalue Filter on max value for discount + * @param int $discount_type 0 => customer discount, 1 => supplier discount * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, amount otherwise - */ - public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) - { - global $conf; + * @return int <0 if KO, amount otherwise + */ + public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) + { + global $conf; - dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG); + dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG); - $sql = "SELECT SUM(rc.amount_ttc) as amount, SUM(rc.multicurrency_amount_ttc) as multicurrency_amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql .= " WHERE rc.entity = ".$conf->entity; - $sql .= " AND rc.discount_type=".intval($discount_type); - if (!empty($discount_type)) { - $sql .= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; // Available from supplier - } else { - $sql .= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available to customer - } - if (is_object($company)) $sql .= " AND rc.fk_soc = ".$company->id; - if (is_object($user)) $sql .= " AND rc.fk_user = ".$user->id; - if ($filter) $sql .= ' AND ('.$filter.')'; - if ($maxvalue) $sql .= ' AND rc.amount_ttc <= '.price2num($maxvalue); + $sql = "SELECT SUM(rc.amount_ttc) as amount, SUM(rc.multicurrency_amount_ttc) as multicurrency_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " WHERE rc.entity = ".$conf->entity; + $sql .= " AND rc.discount_type=".intval($discount_type); + if (!empty($discount_type)) { + $sql .= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; // Available from supplier + } else { + $sql .= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available to customer + } + if (is_object($company)) $sql .= " AND rc.fk_soc = ".$company->id; + if (is_object($user)) $sql .= " AND rc.fk_user = ".$user->id; + if ($filter) $sql .= ' AND ('.$filter.')'; + if ($maxvalue) $sql .= ' AND rc.amount_ttc <= '.price2num($maxvalue); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - //while ($obj) - //{ - //print 'zz'.$obj->amount; - //$obj = $this->db->fetch_object($resql); - //} + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + //while ($obj) + //{ + //print 'zz'.$obj->amount; + //$obj = $this->db->fetch_object($resql); + //} if ($multicurrency) { return $obj->amount_multicurrency; } - return $obj->amount; - } - return -1; - } - - - /** - * Return amount (with tax) of all deposits invoices used by invoice as a payment. - * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). - * - * @param CommonInvoice $invoice Object invoice (customer of supplier) - * @param int $multicurrency 1=Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise - */ - public function getSumDepositsUsed($invoice, $multicurrency = 0) - { - dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG); - - if ($invoice->element == 'facture' || $invoice->element == 'invoice') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; - $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql .= ' AND f.type = 3'; - } elseif ($invoice->element == 'invoice_supplier') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; - $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql .= ' AND f.type = 3'; - } else { - $this->error = get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter"; - dol_print_error($this->error); - return -1; - } - - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($multicurrency == 1) return $obj->multicurrency_amount; - else return $obj->amount; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - /** - * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment - * - * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency 1=Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and excess received amount otherwise - */ - public function getSumCreditNotesUsed($invoice, $multicurrency = 0) - { - dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); - - if ($invoice->element == 'facture' || $invoice->element == 'invoice') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; - $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION.')'; // Find discount coming from credit note or excess received - } elseif ($invoice->element == 'invoice_supplier') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; - $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.')'; // Find discount coming from credit note or excess paid - } else { - $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; - dol_print_error($this->error); - return -1; - } - - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($multicurrency == 1) return $obj->multicurrency_amount; - else return $obj->amount; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - /** - * Return amount (with tax) of all converted amount for this credit note - * - * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise - */ - public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency = 0) - { - dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); - - if ($invoice->element == 'facture' || $invoice->element == 'invoice') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; - $sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; - } elseif ($invoice->element == 'invoice_supplier') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; - $sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id; - } else { - $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; - dol_print_error($this->error); - return -1; - } - - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($multicurrency) return $obj->multicurrency_amount; - else return $obj->amount; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - /** - * Return clickable ref of object (with picto or not) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only - * @param string $option Where to link to ('invoice' or 'discount') - * @return string String with URL - */ - public function getNomUrl($withpicto, $option = 'invoice') - { - global $langs; - - $result = ''; - $link = ''; - $linkend = ''; - $label = ''; - $picto = ''; - $ref = ''; - - if ($option == 'invoice') { - $facid = !empty($this->discount_type) ? $this->fk_invoice_supplier_source : $this->fk_facture_source; - $link = !empty($this->discount_type) ? '/fourn/facture/card.php' : '/compta/facture/card.php'; - $label = $langs->trans("ShowSourceInvoice").': '.$this->ref_facture_source; - $link = ''; - $linkend = ''; - $ref = !empty($this->discount_type) ? $this->ref_invoice_supplier_source : $this->ref_facture_source; - $picto = 'bill'; - } - if ($option == 'discount') { - $label = $langs->trans("Discount"); - $link = ''; - $linkend = ''; - $ref = $langs->trans("Discount"); - $picto = 'generic'; - } - - - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result .= ' '; - $result .= $link.$ref.$linkend; - return $result; - } + return $obj->amount; + } + return -1; + } /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Return amount (with tax) of all deposits invoices used by invoice as a payment. + * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). + * + * @param CommonInvoice $invoice Object invoice (customer of supplier) + * @param int $multicurrency 1=Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + public function getSumDepositsUsed($invoice, $multicurrency = 0) + { + dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; + $sql .= ' AND f.type = 3'; + } elseif ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; + $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; + $sql .= ' AND f.type = 3'; + } else { + $this->error = get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency == 1) return $obj->multicurrency_amount; + else return $obj->amount; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + + /** + * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment + * + * @param CommonInvoice $invoice Object invoice + * @param int $multicurrency 1=Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and excess received amount otherwise + */ + public function getSumCreditNotesUsed($invoice, $multicurrency = 0) + { + dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; + $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION.')'; // Find discount coming from credit note or excess received + } elseif ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; + $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; + $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.')'; // Find discount coming from credit note or excess paid + } else { + $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency == 1) return $obj->multicurrency_amount; + else return $obj->amount; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + /** + * Return amount (with tax) of all converted amount for this credit note + * + * @param CommonInvoice $invoice Object invoice + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency = 0) + { + dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; + $sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; + } elseif ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; + $sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id; + } else { + $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency) return $obj->multicurrency_amount; + else return $obj->amount; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + + /** + * Return clickable ref of object (with picto or not) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only + * @param string $option Where to link to ('invoice' or 'discount') + * @return string String with URL + */ + public function getNomUrl($withpicto, $option = 'invoice') + { + global $langs; + + $result = ''; + $link = ''; + $linkend = ''; + $label = ''; + $picto = ''; + $ref = ''; + + if ($option == 'invoice') { + $facid = !empty($this->discount_type) ? $this->fk_invoice_supplier_source : $this->fk_facture_source; + $link = !empty($this->discount_type) ? '/fourn/facture/card.php' : '/compta/facture/card.php'; + $label = $langs->trans("ShowSourceInvoice").': '.$this->ref_facture_source; + $link = ''; + $linkend = ''; + $ref = !empty($this->discount_type) ? $this->ref_invoice_supplier_source : $this->ref_facture_source; + $picto = 'bill'; + } + if ($option == 'discount') { + $label = $langs->trans("Discount"); + $link = ''; + $linkend = ''; + $ref = $langs->trans("Discount"); + $picto = 'generic'; + } + + + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + $result .= $link.$ref.$linkend; + return $result; + } + + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ public function initAsSpecimen() { diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 55474850b8e..a5405fd7158 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -28,132 +28,132 @@ */ class DolEditor { - public $tool; // Store the selected tool + public $tool; // Store the selected tool - // If using fckeditor - public $editor; + // If using fckeditor + public $editor; - // If not using fckeditor - public $content; - public $htmlname; - public $toolbarname; - public $toolbarstartexpanded; - public $rows; - public $cols; - public $height; - public $width; - public $readonly; + // If not using fckeditor + public $content; + public $htmlname; + public $toolbarname; + public $toolbarstartexpanded; + public $rows; + public $cols; + public $height; + public $width; + public $readonly; - /** - * Create an object to build an HTML area to edit a large string content - * - * @param string $htmlname HTML name of WYSIWIG field - * @param string $content Content of WYSIWIG field - * @param int $width Width in pixel of edit area (auto by default) - * @param int $height Height in pixel of edit area (200px by default) - * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). - * @param string $toolbarlocation Where bar is stored : - * 'In' each window has its own toolbar - * 'Out:name' share toolbar into the div called 'name' - * @param boolean $toolbarstartexpanded Bar is visible or not at start + /** + * Create an object to build an HTML area to edit a large string content + * + * @param string $htmlname HTML name of WYSIWIG field + * @param string $content Content of WYSIWIG field + * @param int $width Width in pixel of edit area (auto by default) + * @param int $height Height in pixel of edit area (200px by default) + * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). + * @param string $toolbarlocation Where bar is stored : + * 'In' each window has its own toolbar + * 'Out:name' share toolbar into the div called 'name' + * @param boolean $toolbarstartexpanded Bar is visible or not at start * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". - * @param int $rows Size of rows for textarea tool + * @param int $rows Size of rows for textarea tool * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') * @param int $readonly 0=Read/Edit, 1=Read only */ - public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) - { - global $conf, $langs; + public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) + { + global $conf, $langs; - dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); + dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); - if (!$rows) $rows = round($height / 20); - if (!$cols) $cols = ($width ?round($width / 6) : 80); + if (!$rows) $rows = round($height / 20); + if (!$cols) $cols = ($width ?round($width / 6) : 80); $shorttoolbarname = preg_replace('/_encoded$/', '', $toolbarname); - // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') - $defaulteditor = 'ckeditor'; - $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME; - $this->uselocalbrowser = $uselocalbrowser; - $this->readonly = $readonly; + // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') + $defaulteditor = 'ckeditor'; + $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME; + $this->uselocalbrowser = $uselocalbrowser; + $this->readonly = $readonly; - // Check if extended editor is ok. If not we force textarea - if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; + // Check if extended editor is ok. If not we force textarea + if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; if ($okforextendededitor === 'ace') $this->tool = 'ace'; - //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile + //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile - // Define some properties - if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) - { - if ($this->tool == 'ckeditor' && ! dol_textishtml($content)) { // We force content to be into HTML if we are using an advanced editor if content is not HTML. - $this->content = dol_nl2br($content); - } - else { - $this->content = $content; - } - $this->htmlname = $htmlname; - $this->toolbarname = $shorttoolbarname; - $this->toolbarstartexpanded = $toolbarstartexpanded; - $this->rows = max(ROWS_3, $rows); - $this->cols = (preg_match('/%/', $cols) ? $cols : max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max - $this->height = $height; - $this->width = $width; - } - } + // Define some properties + if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) + { + if ($this->tool == 'ckeditor' && !dol_textishtml($content)) { // We force content to be into HTML if we are using an advanced editor if content is not HTML. + $this->content = dol_nl2br($content); + } + else { + $this->content = $content; + } + $this->htmlname = $htmlname; + $this->toolbarname = $shorttoolbarname; + $this->toolbarstartexpanded = $toolbarstartexpanded; + $this->rows = max(ROWS_3, $rows); + $this->cols = (preg_match('/%/', $cols) ? $cols : max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max + $this->height = $height; + $this->width = $width; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output edit area inside the HTML stream. - * Output depends on this->tool (fckeditor, ckeditor, textarea, ...) - * - * @param int $noprint 1=Return HTML string instead of printing it to output - * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });". Used by CKEditor only. - * @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. Used by CKEditor only. - * @param string $titlecontent Show title content before editor area. Used by ACE editor only. - * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) - * @return void|string - */ - public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') - { - // phpcs:enable - global $conf, $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output edit area inside the HTML stream. + * Output depends on this->tool (fckeditor, ckeditor, textarea, ...) + * + * @param int $noprint 1=Return HTML string instead of printing it to output + * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });". Used by CKEditor only. + * @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. Used by CKEditor only. + * @param string $titlecontent Show title content before editor area. Used by ACE editor only. + * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) + * @return void|string + */ + public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') + { + // phpcs:enable + global $conf, $langs; - $fullpage = false; - if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) - { - $disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all - } + $fullpage = false; + if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) + { + $disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all + } - $found = 0; + $found = 0; $out = ''; - if (in_array($this->tool, array('textarea', 'ckeditor'))) - { - $found = 1; - //$out.= ''; + if (in_array($this->tool, array('textarea', 'ckeditor'))) + { + $found = 1; + //$out.= ''; - if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && !empty($conf->fckeditor->enabled)) - { - if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); + if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && !empty($conf->fckeditor->enabled)) + { + if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); - if (!empty($conf->global->FCKEDITOR_SKIN)) { + if (!empty($conf->global->FCKEDITOR_SKIN)) { $skin = $conf->global->FCKEDITOR_SKIN; } else { $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa } - $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; + $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; - $out .= ''."\n"; - $out .= ''."\n"; - } - } + } + $out .= ' })'.$morejs; + $out .= '});'."\n"; + $out .= ''."\n"; + } + } - // Output editor ACE - // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. - if (preg_match('/^ace/', $this->tool)) - { - $found = 1; + // Output editor ACE + // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. + if (preg_match('/^ace/', $this->tool)) + { + $found = 1; $format = $option; - $out .= "\n".''."\n"; + $out .= "\n".''."\n"; if ($titlecontent) { - $out .= '
    '.$titlecontent; - $out .= '   -   '.dol_escape_htmltag($langs->trans("ShowMoreLines")).'     '; - $out .= '
    '; - $out .= ''."\n"; + $out .= ''."\n"; } - $out .= '
    content);
    -        	$out .= '
    '; - $out .= ''; + $out .= '
    content);
    +			$out .= '
    '; + $out .= ''; - $out .= ''."\n"; - } + $out .= ''."\n"; + } - if (empty($found)) - { - $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; - } + if (empty($found)) + { + $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; + } - if ($noprint) return $out; - else print $out; - } + if ($noprint) return $out; + else print $out; + } } diff --git a/htdocs/core/class/dolexception.class.php b/htdocs/core/class/dolexception.class.php index 2c43a43127c..e083a47d5f7 100644 --- a/htdocs/core/class/dolexception.class.php +++ b/htdocs/core/class/dolexception.class.php @@ -27,10 +27,10 @@ */ class DolException extends Exception { - /** - * Constructor - */ - public function __construct() - { - } + /** + * Constructor + */ + public function __construct() + { + } } diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 2b148a96e8a..215a1710b82 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -33,7 +33,7 @@ */ class DolGeoIP { - public $gi; + public $gi; /** * Constructor @@ -50,18 +50,18 @@ class DolGeoIP if ($type == 'country') { - // geoip may have been already included with PEAR + // geoip may have been already included with PEAR if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) - { - require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; - } + { + require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; + } } elseif ($type == 'city') { - // geoip may have been already included with PEAR + // geoip may have been already included with PEAR if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) - { - require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; - } + { + require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; + } } else { print 'ErrorBadParameterInConstructor'; return 0; } // Here, function exists (embedded into PHP or exists because we made include) @@ -92,10 +92,13 @@ class DolGeoIP } elseif (function_exists('geoip_open')) { $this->gi = geoip_open($datfile, GEOIP_STANDARD); + } + elseif (function_exists('geoip_country_code_by_name')) { + $this->gi = 'NOGI'; // We are using embedded php geoip functions + //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); + //print geoip_database_info(); } else { - $this->gi = 'NOGI'; // We are using embedded php geoip functions - //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); - //print geoip_database_info(); + $this->gi = ''; // For avoid error } } @@ -118,8 +121,8 @@ class DolGeoIP } if ($this->gi == 'NOGI') { - // geoip_country_code_by_addr does not exists - return strtolower(geoip_country_code_by_name($ip)); + // geoip_country_code_by_addr does not exists + return strtolower(geoip_country_code_by_name($ip)); } else { if (preg_match('/^[0-9]+.[0-9]+\.[0-9]+\.[0-9]+/', $ip)) { @@ -133,8 +136,8 @@ class DolGeoIP return ''; } } else { - if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); - return strtolower(geoip_country_code_by_addr($this->gi, $ip)); + if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); + return strtolower(geoip_country_code_by_addr($this->gi, $ip)); } } else { if ($geoipversion == '2') @@ -186,37 +189,37 @@ class DolGeoIP } } - /** - * Return verion of data file - * - * @return string Version of datafile - */ - public function getVersion() - { - global $conf; + /** + * Return verion of data file + * + * @return string Version of datafile + */ + public function getVersion() + { + global $conf; - $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + $geoipversion = '2'; // 'php', or '2' + if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; - if ($geoipversion == 'php') - { - if ($this->gi == 'NOGI') return geoip_database_info(); - else return 'geoip_database_info() function not available'; - } + if ($geoipversion == 'php') + { + if ($this->gi == 'NOGI') return geoip_database_info(); + else return 'geoip_database_info() function not available'; + } - return 'Not available (not using PHP internal geo functions - We are using embedded Geoip v'.$geoipversion.')'; - } + return 'Not available (not using PHP internal geo functions - We are using embedded Geoip v'.$geoipversion.')'; + } - /** - * Close geoip object - * - * @return void - */ - public function close() - { - if (function_exists('geoip_close')) { - // With some geoip with PEAR, geoip_close function may not exists - geoip_close($this->gi); - } - } + /** + * Close geoip object + * + * @return void + */ + public function close() + { + if (function_exists('geoip_close')) { + // With some geoip with PEAR, geoip_close function may not exists + geoip_close($this->gi); + } + } } diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index dee727cb596..0ff627ba20c 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -120,7 +120,7 @@ class DolGraph } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * @@ -129,12 +129,12 @@ class DolGraph */ public function SetHorizTickIncrement($xi) { - // phpcs:enable + // phpcs:enable $this->horizTickIncrement = $xi; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * @@ -143,12 +143,12 @@ class DolGraph */ public function SetNumXTicks($xt) { - // phpcs:enable + // phpcs:enable $this->SetNumXTicks = $xt; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set label interval to reduce number of labels * @@ -157,12 +157,12 @@ class DolGraph */ public function SetLabelInterval($x) { - // phpcs:enable + // phpcs:enable $this->labelInterval = $x; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide X grid * @@ -171,12 +171,12 @@ class DolGraph */ public function SetHideXGrid($bool) { - // phpcs:enable + // phpcs:enable $this->hideXGrid = $bool; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide Y grid * @@ -185,12 +185,12 @@ class DolGraph */ public function SetHideYGrid($bool) { - // phpcs:enable + // phpcs:enable $this->hideYGrid = $bool; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set y label * @@ -199,11 +199,11 @@ class DolGraph */ public function SetYLabel($label) { - // phpcs:enable + // phpcs:enable $this->YLabel = $label; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set width * @@ -212,11 +212,11 @@ class DolGraph */ public function SetWidth($w) { - // phpcs:enable + // phpcs:enable $this->width = $w; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set title * @@ -225,11 +225,11 @@ class DolGraph */ public function SetTitle($title) { - // phpcs:enable + // phpcs:enable $this->title = $title; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set data * @@ -239,11 +239,11 @@ class DolGraph */ public function SetData($data) { - // phpcs:enable + // phpcs:enable $this->data = $data; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set data * @@ -252,11 +252,11 @@ class DolGraph */ public function SetDataColor($datacolor) { - // phpcs:enable + // phpcs:enable $this->datacolor = $datacolor; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set type * @@ -266,11 +266,11 @@ class DolGraph */ public function SetType($type) { - // phpcs:enable + // phpcs:enable $this->type = $type; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set legend * @@ -279,11 +279,11 @@ class DolGraph */ public function SetLegend($legend) { - // phpcs:enable + // phpcs:enable $this->Legend = $legend; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set min width * @@ -292,120 +292,120 @@ class DolGraph */ public function SetLegendWidthMin($legendwidthmin) { - // phpcs:enable + // phpcs:enable $this->LegendWidthMin = $legendwidthmin; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set max value * * @param int $max Max value * @return void */ - public function SetMaxValue($max) + public function SetMaxValue($max) { - // phpcs:enable + // phpcs:enable $this->MaxValue = $max; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get max value * * @return int Max value */ - public function GetMaxValue() + public function GetMaxValue() { - // phpcs:enable + // phpcs:enable return $this->MaxValue; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set min value * * @param int $min Min value * @return void */ - public function SetMinValue($min) + public function SetMinValue($min) { - // phpcs:enable + // phpcs:enable $this->MinValue = $min; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get min value * * @return int Max value */ - public function GetMinValue() + public function GetMinValue() { - // phpcs:enable + // phpcs:enable return $this->MinValue; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set height * * @param int $h Height * @return void */ - public function SetHeight($h) + public function SetHeight($h) { - // phpcs:enable + // phpcs:enable $this->height = $h; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set shading * * @param string $s Shading * @return void */ - public function SetShading($s) + public function SetShading($s) { - // phpcs:enable + // phpcs:enable $this->SetShading = $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set shading * * @param string $s Shading * @return void */ - public function SetCssPrefix($s) + public function SetCssPrefix($s) { - // phpcs:enable + // phpcs:enable $this->cssprefix = $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset bg color * * @return void */ - public function ResetBgColor() + public function ResetBgColor() { - // phpcs:enable + // phpcs:enable unset($this->bgcolor); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset bgcolorgrid * * @return void */ - public function ResetBgColorGrid() + public function ResetBgColorGrid() { - // phpcs:enable + // phpcs:enable unset($this->bgcolorgrid); } @@ -414,7 +414,7 @@ class DolGraph * * @return string Error */ - public function isGraphKo() + public function isGraphKo() { return $this->error; } @@ -425,7 +425,7 @@ class DolGraph * @param int $showlegend 1=Show legend (default), 0=Hide legend, 2=Show legend on right * @return void */ - public function setShowLegend($showlegend) + public function setShowLegend($showlegend) { $this->showlegend = $showlegend; } @@ -436,7 +436,7 @@ class DolGraph * @param int $showpointvalue 1=Show value for each point, as tooltip or inline (default), 0=Hide value * @return void */ - public function setShowPointValue($showpointvalue) + public function setShowPointValue($showpointvalue) { $this->showpointvalue = $showpointvalue; } @@ -447,23 +447,23 @@ class DolGraph * @param int $showpercent 1=Show percent for each point, as tooltip or inline, 0=Hide percent (default) * @return void */ - public function setShowPercent($showpercent) + public function setShowPercent($showpercent) { $this->showpercent = $showpercent; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define background color of complete image * * @param array $bg_color array(R,G,B) ou 'onglet' ou 'default' * @return void */ - public function SetBgColor($bg_color = array(255, 255, 255)) + public function SetBgColor($bg_color = array(255, 255, 255)) { - // phpcs:enable + // phpcs:enable global $theme_bgcolor, $theme_bgcoloronglet; if (!is_array($bg_color)) @@ -480,16 +480,16 @@ class DolGraph } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define background color of grid * * @param array $bg_colorgrid array(R,G,B) ou 'onglet' ou 'default' * @return void */ - public function SetBgColorGrid($bg_colorgrid = array(255, 255, 255)) + public function SetBgColorGrid($bg_colorgrid = array(255, 255, 255)) { - // phpcs:enable + // phpcs:enable global $theme_bgcolor, $theme_bgcoloronglet; if (!is_array($bg_colorgrid)) @@ -506,27 +506,27 @@ class DolGraph } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset data color * * @return void */ - public function ResetDataColor() - { - // phpcs:enable - unset($this->datacolor); - } + public function ResetDataColor() + { + // phpcs:enable + unset($this->datacolor); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Get max value * * @return int Max value */ - public function GetMaxValueInData() + public function GetMaxValueInData() { - // phpcs:enable + // phpcs:enable if (!is_array($this->data)) return 0; $k = 0; @@ -547,15 +547,15 @@ class DolGraph return $vals[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return min value of all data * * @return int Min value of all data */ - public function GetMinValueInData() + public function GetMinValueInData() { - // phpcs:enable + // phpcs:enable if (!is_array($this->data)) return 0; $k = 0; @@ -576,15 +576,15 @@ class DolGraph return $vals[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return max value of all data * * @return int Max value of all data */ - public function GetCeilMaxValue() + public function GetCeilMaxValue() { - // phpcs:enable + // phpcs:enable $max = $this->GetMaxValueInData(); if ($max != 0) $max++; $size = dol_strlen(abs(ceil($max))); @@ -601,15 +601,15 @@ class DolGraph return $res; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return min value of all data * * @return double Max value of all data */ - public function GetFloorMinValue() + public function GetFloorMinValue() { - // phpcs:enable + // phpcs:enable $min = $this->GetMinValueInData(); if ($min == '') $min = 0; if ($min != 0) $min--; @@ -633,7 +633,7 @@ class DolGraph * @param string $fileurl Url path to show image if saved onto disk * @return integer|null */ - public function draw($file, $fileurl = '') + public function draw($file, $fileurl = '') { if (empty($file)) { @@ -656,7 +656,7 @@ class DolGraph call_user_func_array(array($this, $call), array($file, $fileurl)); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build a graph using JFlot library. Input when calling this method should be: * $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); @@ -675,7 +675,7 @@ class DolGraph */ private function draw_jflot($file, $fileurl) { - // phpcs:enable + // phpcs:enable global $conf, $langs; dol_syslog(get_class($this)."::draw_jflot this->type=".join(',', $this->type)." this->MaxValue=".$this->MaxValue); @@ -732,9 +732,9 @@ class DolGraph if (!empty($this->title)) $this->stringtoshow .= '
    '.$this->title.'
    '; if (!empty($this->shownographyet)) { - $this->stringtoshow .= '
    '; - $this->stringtoshow .= '
    '.$langs->trans("NotEnoughDataYet").'...
    '; - return; + $this->stringtoshow .= '
    '; + $this->stringtoshow .= '
    '.$langs->trans("NotEnoughDataYet").'...
    '; + return; } // Start the div that will contains all the graph @@ -825,7 +825,7 @@ class DolGraph // Other cases, graph of type 'bars', 'lines' else { // Add code to support tooltips - // TODO: remove js css and use graph-tooltip-inner class instead by adding css in each themes + // TODO: remove js css and use graph-tooltip-inner class instead by adding css in each themes $this->stringtoshow .= ' function showTooltip_'.$tag.'(x, y, contents) { $(\'
    \' + contents + \'
    \').css({ @@ -881,14 +881,14 @@ class DolGraph if ($i > $firstlot) $this->stringtoshow .= ', '."\n"; $color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]); $this->stringtoshow .= '{ '; - if (! isset($this->type[$i]) || $this->type[$i] == 'bars') { - if ($nblot == 3) { - if ($i == $firstlot) $align = 'right'; - elseif ($i == $firstlot + 1) $align = 'center'; - else $align = 'left'; - $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.$align.'", barWidth: 0.45 }, '; - } else $this->stringtoshow.='bars: { lineWidth: 1, show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, '; - } + if (!isset($this->type[$i]) || $this->type[$i] == 'bars') { + if ($nblot == 3) { + if ($i == $firstlot) $align = 'right'; + elseif ($i == $firstlot + 1) $align = 'center'; + else $align = 'left'; + $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.$align.'", barWidth: 0.45 }, '; + } else $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.($i == $firstlot ? 'center' : 'left').'", barWidth: 0.5 }, '; + } if (isset($this->type[$i]) && ($this->type[$i] == 'lines' || $this->type[$i] == 'linesnopoint')) $this->stringtoshow .= 'lines: { show: true, fill: false }, points: { show: '.($this->type[$i] == 'linesnopoint' ? 'false' : 'true').' }, '; $this->stringtoshow .= 'color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }'; $i++; @@ -1280,7 +1280,7 @@ class DolGraph * * @return string HTML string to total value */ - public function total() + public function total() { $value = 0; foreach ($this->data as $valarray) // Loop on each x @@ -1296,7 +1296,7 @@ class DolGraph * @param int|string $shownographyet Show graph to say there is not enough data or the message in $shownographyet if it is a string. * @return string HTML string to show graph */ - public function show($shownographyet = 0) + public function show($shownographyet = 0) { global $langs; @@ -1305,9 +1305,9 @@ class DolGraph $s = '
    '; $s .= '
    '; if (is_numeric($shownographyet)) { - $s .= $langs->trans("NotEnoughDataYet").'...'; + $s .= $langs->trans("NotEnoughDataYet").'...'; } else { - $s .= $shownographyet.'...'; + $s .= $shownographyet.'...'; } $s .= '
    '; return $s; diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index f8c33f9403a..5ff3f397813 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -25,32 +25,32 @@ /* * Tags for ticket template * - * Left align text - * Center text - * Right align text - * Use font A of printer - * Use font B of printer - * Use font C of printer - * Text Bold - * Disable Text Bold - * Text double height - * Text double width - * Text default height and width - * Underline text - * Disable underline text - * Cut ticket completely - * Cut ticket partially - * Open cash drawer - * Activate buzzer - * Print barcode - * Print logo stored on printer. Example : 32|32 - * Print logo stored on printer. Must be followed by logo code. For old printers. - * Print object lines - * Print object total tax - * Print object local tax - * Print object total - * Print order lines for Printer - * Print payment method + * {dol_align_left} Left align text + * {dol_align_center} Center text + * {dol_align_right} Right align text + * {dol_use_font_a} Use font A of printer + * {dol_use_font_b} Use font B of printer + * {dol_use_font_c} Use font C of printer + * {dol_bold} Text Bold + * {dol_bold_disabled} Disable Text Bold + * {dol_double_height} Text double height + * {dol_double_width} Text double width + * {dol_default_height_width} Text default height and width + * {dol_underline} Underline text + * {dol_underline_disabled} Disable underline text + * {dol_cut_paper_full} Cut ticket completely + * {dol_cut_paper_partial} Cut ticket partially + * {dol_open_drawer} Open cash drawer + * {dol_beep} Activate buzzer + * {dol_print_barcode} Print barcode + * {dol_print_logo} Print logo stored on printer. Example : 32|32 + * {dol_print_logo_old} Print logo stored on printer. Must be followed by logo code. For old printers. + * {dol_print_object_lines} Print object lines + * {dol_print_object_tax} Print object total tax + * {dol_print_object_local_tax} Print object local tax + * {dol_print_object_total} Print object total + * {dol_print_order_lines} Print order lines for Printer + * {dol_print_payment} Print payment method * * Code which can be placed everywhere * Replaced by date AAAA-MM-DD @@ -115,429 +115,429 @@ use Mike42\Escpos\EscposImage; */ class dolReceiptPrinter extends Printer { - const CONNECTOR_DUMMY = 1; - const CONNECTOR_FILE_PRINT = 2; - const CONNECTOR_NETWORK_PRINT = 3; - const CONNECTOR_WINDOWS_PRINT = 4; - const CONNECTOR_CUPS_PRINT = 5; + const CONNECTOR_DUMMY = 1; + const CONNECTOR_FILE_PRINT = 2; + const CONNECTOR_NETWORK_PRINT = 3; + const CONNECTOR_WINDOWS_PRINT = 4; + const CONNECTOR_CUPS_PRINT = 5; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /* + /* * @var string[] array of tags */ - public $tags; - public $printer; - public $template; + public $tags; + public $printer; + public $template; - /** - * Number of order printer - * @var int - */ - public $orderprinter; + /** + * Number of order printer + * @var int + */ + public $orderprinter; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); - /** - * Constructor - * - * @param DoliDB $db database - */ - public function __construct($db) - { - $this->db = $db; - $this->tags = array( - 'dol_line_feed' => 'DOL_LINE_FEED', - 'dol_line_feed_reverse' => 'DOL_LINE_FEED_REVERSE', - 'dol_align_left' => 'DOL_ALIGN_LEFT', - 'dol_align_center' => 'DOL_ALIGN_CENTER', - 'dol_align_right' => 'DOL_ALIGN_RIGHT', - 'dol_use_font_a' => 'DOL_USE_FONT_A', - 'dol_use_font_b' => 'DOL_USE_FONT_B', - 'dol_use_font_c' => 'DOL_USE_FONT_C', - 'dol_bold' => 'DOL_BOLD', - 'dol_bold_disabled' => 'DOL_BOLD_DISABLED', - 'dol_double_height' => 'DOL_DOUBLE_HEIGHT', - 'dol_double_width' => 'DOL_DOUBLE_WIDTH', - 'dol_default_height_width' => 'DOL_DEFAULT_HEIGHT_WIDTH', - 'dol_underline' => 'DOL_UNDERLINE', - 'dol_underline_disabled' => 'DOL_UNDERLINE_DISABLED', - 'dol_cut_paper_full' => 'DOL_CUT_PAPER_FULL', - 'dol_cut_paper_partial' => 'DOL_CUT_PAPER_PARTIAL', - 'dol_open_drawer' => 'DOL_OPEN_DRAWER', - 'dol_beep' => 'DOL_BEEP', - 'dol_print_text' => 'DOL_PRINT_TEXT', - 'dol_print_barcode' => 'DOL_PRINT_BARCODE', - 'dol_value_date' => 'DateInvoice', - 'dol_value_date_time' => 'DateInvoiceWithTime', - 'dol_value_year' => 'YearInvoice', - 'dol_value_month_letters' => 'DOL_VALUE_MONTH_LETTERS', - 'dol_value_month' => 'DOL_VALUE_MONTH', - 'dol_value_day' => 'DOL_VALUE_DAY', - 'dol_value_day_letters' => 'DOL_VALUE_DAY', - 'dol_print_payment' => 'DOL_PRINT_PAYMENT', - 'dol_print_logo' => 'DOL_PRINT_LOGO', - 'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD', - 'dol_value_object_id' => 'InvoiceID', - 'dol_value_object_ref' => 'InvoiceRef', - 'dol_print_object_lines' => 'DOL_PRINT_OBJECT_LINES', - 'dol_print_object_tax' => 'TotalVAT', - 'dol_print_object_local_tax1' => 'TotalLT1', - 'dol_print_object_local_tax2' => 'TotalLT2', - 'dol_print_object_total' => 'Total', - 'dol_print_object_number' => 'DOL_PRINT_OBJECT_NUMBER', - //'dol_value_object_points' => 'DOL_VALUE_OBJECT_POINTS', - 'dol_print_order_lines' => 'DOL_PRINT_ORDER_LINES', - 'dol_value_customer_firstname' => 'DOL_VALUE_CUSTOMER_FIRSTNAME', - 'dol_value_customer_lastname' => 'DOL_VALUE_CUSTOMER_LASTNAME', - 'dol_value_customer_mail' => 'DOL_VALUE_CUSTOMER_MAIL', - 'dol_value_customer_phone' => 'DOL_VALUE_CUSTOMER_PHONE', - 'dol_value_customer_skype' => 'DOL_VALUE_CUSTOMER_SKYPE', - 'dol_value_customer_tax_number' => 'DOL_VALUE_CUSTOMER_TAX_NUMBER', - //'dol_value_customer_account_balance' => 'DOL_VALUE_CUSTOMER_ACCOUNT_BALANCE', - //'dol_value_customer_points' => 'DOL_VALUE_CUSTOMER_POINTS', - 'dol_value_mysoc_name' => 'DOL_VALUE_MYSOC_NAME', - 'dol_value_mysoc_address' => 'Address', - 'dol_value_mysoc_zip' => 'Zip', - 'dol_value_mysoc_town' => 'Town', - 'dol_value_mysoc_country' => 'Country', - 'dol_value_mysoc_idprof1' => 'ProfId1', - 'dol_value_mysoc_idprof2' => 'ProfId2', - 'dol_value_mysoc_idprof3' => 'ProfId3', - 'dol_value_mysoc_idprof4' => 'ProfId4', - 'dol_value_mysoc_idprof5' => 'ProfId5', - 'dol_value_mysoc_idprof6' => 'ProfId6', - 'dol_value_mysoc_tva_intra' => 'VATIntra', - 'dol_value_mysoc_capital' => 'Capital', - 'dol_value_vendor_lastname' => 'VendorLastname', - 'dol_value_vendor_firstname' => 'VendorFirstname', - 'dol_value_vendor_mail' => 'VendorEmail', - ); - } + /** + * Constructor + * + * @param DoliDB $db database + */ + public function __construct($db) + { + $this->db = $db; + $this->tags = array( + 'dol_line_feed' => 'DOL_LINE_FEED', + 'dol_line_feed_reverse' => 'DOL_LINE_FEED_REVERSE', + 'dol_align_left' => 'DOL_ALIGN_LEFT', + 'dol_align_center' => 'DOL_ALIGN_CENTER', + 'dol_align_right' => 'DOL_ALIGN_RIGHT', + 'dol_use_font_a' => 'DOL_USE_FONT_A', + 'dol_use_font_b' => 'DOL_USE_FONT_B', + 'dol_use_font_c' => 'DOL_USE_FONT_C', + 'dol_bold' => 'DOL_BOLD', + 'dol_bold_disabled' => 'DOL_BOLD_DISABLED', + 'dol_double_height' => 'DOL_DOUBLE_HEIGHT', + 'dol_double_width' => 'DOL_DOUBLE_WIDTH', + 'dol_default_height_width' => 'DOL_DEFAULT_HEIGHT_WIDTH', + 'dol_underline' => 'DOL_UNDERLINE', + 'dol_underline_disabled' => 'DOL_UNDERLINE_DISABLED', + 'dol_cut_paper_full' => 'DOL_CUT_PAPER_FULL', + 'dol_cut_paper_partial' => 'DOL_CUT_PAPER_PARTIAL', + 'dol_open_drawer' => 'DOL_OPEN_DRAWER', + 'dol_beep' => 'DOL_BEEP', + 'dol_print_text' => 'DOL_PRINT_TEXT', + 'dol_print_barcode' => 'DOL_PRINT_BARCODE', + 'dol_value_date' => 'DateInvoice', + 'dol_value_date_time' => 'DateInvoiceWithTime', + 'dol_value_year' => 'YearInvoice', + 'dol_value_month_letters' => 'DOL_VALUE_MONTH_LETTERS', + 'dol_value_month' => 'DOL_VALUE_MONTH', + 'dol_value_day' => 'DOL_VALUE_DAY', + 'dol_value_day_letters' => 'DOL_VALUE_DAY', + 'dol_print_payment' => 'DOL_PRINT_PAYMENT', + 'dol_print_logo' => 'DOL_PRINT_LOGO', + 'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD', + 'dol_value_object_id' => 'InvoiceID', + 'dol_value_object_ref' => 'InvoiceRef', + 'dol_print_object_lines' => 'DOL_PRINT_OBJECT_LINES', + 'dol_print_object_tax' => 'TotalVAT', + 'dol_print_object_local_tax1' => 'TotalLT1', + 'dol_print_object_local_tax2' => 'TotalLT2', + 'dol_print_object_total' => 'Total', + 'dol_print_object_number' => 'DOL_PRINT_OBJECT_NUMBER', + //'dol_value_object_points' => 'DOL_VALUE_OBJECT_POINTS', + 'dol_print_order_lines' => 'DOL_PRINT_ORDER_LINES', + 'dol_value_customer_firstname' => 'DOL_VALUE_CUSTOMER_FIRSTNAME', + 'dol_value_customer_lastname' => 'DOL_VALUE_CUSTOMER_LASTNAME', + 'dol_value_customer_mail' => 'DOL_VALUE_CUSTOMER_MAIL', + 'dol_value_customer_phone' => 'DOL_VALUE_CUSTOMER_PHONE', + 'dol_value_customer_skype' => 'DOL_VALUE_CUSTOMER_SKYPE', + 'dol_value_customer_tax_number' => 'DOL_VALUE_CUSTOMER_TAX_NUMBER', + //'dol_value_customer_account_balance' => 'DOL_VALUE_CUSTOMER_ACCOUNT_BALANCE', + //'dol_value_customer_points' => 'DOL_VALUE_CUSTOMER_POINTS', + 'dol_value_mysoc_name' => 'DOL_VALUE_MYSOC_NAME', + 'dol_value_mysoc_address' => 'Address', + 'dol_value_mysoc_zip' => 'Zip', + 'dol_value_mysoc_town' => 'Town', + 'dol_value_mysoc_country' => 'Country', + 'dol_value_mysoc_idprof1' => 'ProfId1', + 'dol_value_mysoc_idprof2' => 'ProfId2', + 'dol_value_mysoc_idprof3' => 'ProfId3', + 'dol_value_mysoc_idprof4' => 'ProfId4', + 'dol_value_mysoc_idprof5' => 'ProfId5', + 'dol_value_mysoc_idprof6' => 'ProfId6', + 'dol_value_mysoc_tva_intra' => 'VATIntra', + 'dol_value_mysoc_capital' => 'Capital', + 'dol_value_vendor_lastname' => 'VendorLastname', + 'dol_value_vendor_firstname' => 'VendorFirstname', + 'dol_value_vendor_mail' => 'VendorEmail', + ); + } - /** - * list printers - * - * @return int 0 if OK; >0 if KO - */ - public function listPrinters() - { - global $conf; - $error = 0; - $line = 0; - $obj = array(); - $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - while ($line < $num) { - $row = $this->db->fetch_array($resql); - switch ($row['fk_type']) { - case 1: - $row['fk_type_name'] = 'CONNECTOR_DUMMY'; - break; - case 2: - $row['fk_type_name'] = 'CONNECTOR_FILE_PRINT'; - break; - case 3: - $row['fk_type_name'] = 'CONNECTOR_NETWORK_PRINT'; - break; - case 4: - $row['fk_type_name'] = 'CONNECTOR_WINDOWS_PRINT'; - break; - case 5: - $row['fk_type_name'] = 'CONNECTOR_CUPS_PRINT'; - break; - default: - $row['fk_type_name'] = 'CONNECTOR_UNKNOWN'; - break; - } - switch ($row['fk_profile']) { - case 0: - $row['fk_profile_name'] = 'PROFILE_DEFAULT'; - break; - case 1: - $row['fk_profile_name'] = 'PROFILE_SIMPLE'; - break; - case 2: - $row['fk_profile_name'] = 'PROFILE_EPOSTEP'; - break; - case 3: - $row['fk_profile_name'] = 'PROFILE_P822D'; - break; - default: - $row['fk_profile_name'] = 'PROFILE_STAR'; - break; - } - $obj[] = $row; - $line++; - } - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - $this->listprinters = $obj; - return $error; - } + /** + * list printers + * + * @return int 0 if OK; >0 if KO + */ + public function listPrinters() + { + global $conf; + $error = 0; + $line = 0; + $obj = array(); + $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + while ($line < $num) { + $row = $this->db->fetch_array($resql); + switch ($row['fk_type']) { + case 1: + $row['fk_type_name'] = 'CONNECTOR_DUMMY'; + break; + case 2: + $row['fk_type_name'] = 'CONNECTOR_FILE_PRINT'; + break; + case 3: + $row['fk_type_name'] = 'CONNECTOR_NETWORK_PRINT'; + break; + case 4: + $row['fk_type_name'] = 'CONNECTOR_WINDOWS_PRINT'; + break; + case 5: + $row['fk_type_name'] = 'CONNECTOR_CUPS_PRINT'; + break; + default: + $row['fk_type_name'] = 'CONNECTOR_UNKNOWN'; + break; + } + switch ($row['fk_profile']) { + case 0: + $row['fk_profile_name'] = 'PROFILE_DEFAULT'; + break; + case 1: + $row['fk_profile_name'] = 'PROFILE_SIMPLE'; + break; + case 2: + $row['fk_profile_name'] = 'PROFILE_EPOSTEP'; + break; + case 3: + $row['fk_profile_name'] = 'PROFILE_P822D'; + break; + default: + $row['fk_profile_name'] = 'PROFILE_STAR'; + break; + } + $obj[] = $row; + $line++; + } + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + $this->listprinters = $obj; + return $error; + } - /** - * List printers templates - * - * @return int 0 if OK; >0 if KO - */ - public function listPrintersTemplates() - { - global $conf; - $error = 0; - $line = 0; - $obj = array(); - $sql = 'SELECT rowid, name, template'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' WHERE entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - while ($line < $num) { - $obj[] = $this->db->fetch_array($resql); - $line++; - } - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - $this->listprinterstemplates = $obj; - return $error; - } + /** + * List printers templates + * + * @return int 0 if OK; >0 if KO + */ + public function listPrintersTemplates() + { + global $conf; + $error = 0; + $line = 0; + $obj = array(); + $sql = 'SELECT rowid, name, template'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' WHERE entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + while ($line < $num) { + $obj[] = $this->db->fetch_array($resql); + $line++; + } + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + $this->listprinterstemplates = $obj; + return $error; + } - /** - * Form to Select type printer - * - * @param string $selected Id printer type pre-selected - * @param string $htmlname select html name - * @return int 0 if OK; >0 if KO - */ - public function selectTypePrinter($selected = '', $htmlname = 'printertypeid') - { - global $langs; + /** + * Form to Select type printer + * + * @param string $selected Id printer type pre-selected + * @param string $htmlname select html name + * @return int 0 if OK; >0 if KO + */ + public function selectTypePrinter($selected = '', $htmlname = 'printertypeid') + { + global $langs; - $options = array( - 1 => $langs->trans('CONNECTOR_DUMMY'), - 2 => $langs->trans('CONNECTOR_FILE_PRINT'), - 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), - 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'), + $options = array( + 1 => $langs->trans('CONNECTOR_DUMMY'), + 2 => $langs->trans('CONNECTOR_FILE_PRINT'), + 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), + 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'), 5 => $langs->trans('CONNECTOR_CUPS_PRINT'), - ); + ); - $this->resprint = Form::selectarray($htmlname, $options, $selected); + $this->resprint = Form::selectarray($htmlname, $options, $selected); - return 0; - } + return 0; + } - /** - * Form to Select Profile printer - * - * @param string $selected Id printer profile pre-selected - * @param string $htmlname select html name - * @return int 0 if OK; >0 if KO - */ - public function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') - { - global $langs; + /** + * Form to Select Profile printer + * + * @param string $selected Id printer profile pre-selected + * @param string $htmlname select html name + * @return int 0 if OK; >0 if KO + */ + public function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') + { + global $langs; - $options = array( - 0 => $langs->trans('PROFILE_DEFAULT'), - 1 => $langs->trans('PROFILE_SIMPLE'), - 2 => $langs->trans('PROFILE_EPOSTEP'), - 3 => $langs->trans('PROFILE_P822D'), - 4 => $langs->trans('PROFILE_STAR'), - ); + $options = array( + 0 => $langs->trans('PROFILE_DEFAULT'), + 1 => $langs->trans('PROFILE_SIMPLE'), + 2 => $langs->trans('PROFILE_EPOSTEP'), + 3 => $langs->trans('PROFILE_P822D'), + 4 => $langs->trans('PROFILE_STAR'), + ); - $this->profileresprint = Form::selectarray($htmlname, $options, $selected); - return 0; - } + $this->profileresprint = Form::selectarray($htmlname, $options, $selected); + return 0; + } - /** - * Function to Add a printer in db - * - * @param string $name Printer name - * @param int $type Printer type - * @param int $profile Printer profile - * @param string $parameter Printer parameter - * @return int 0 if OK; >0 if KO - */ - public function addPrinter($name, $type, $profile, $parameter) - { - global $conf; - $error = 0; - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' (name, fk_type, fk_profile, parameter, entity)'; - $sql .= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Add a printer in db + * + * @param string $name Printer name + * @param int $type Printer type + * @param int $profile Printer profile + * @param string $parameter Printer parameter + * @return int 0 if OK; >0 if KO + */ + public function addPrinter($name, $type, $profile, $parameter) + { + global $conf; + $error = 0; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' (name, fk_type, fk_profile, parameter, entity)'; + $sql .= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Update a printer in db - * - * @param string $name Printer name - * @param int $type Printer type - * @param int $profile Printer profile - * @param string $parameter Printer parameter - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function updatePrinter($name, $type, $profile, $parameter, $printerid) - { - global $conf; - $error = 0; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' SET name="'.$this->db->escape($name).'"'; - $sql .= ', fk_type='.$type; - $sql .= ', fk_profile='.$profile; - $sql .= ', parameter="'.$this->db->escape($parameter).'"'; - $sql .= ' WHERE rowid='.$printerid; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Update a printer in db + * + * @param string $name Printer name + * @param int $type Printer type + * @param int $profile Printer profile + * @param string $parameter Printer parameter + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function updatePrinter($name, $type, $profile, $parameter, $printerid) + { + global $conf; + $error = 0; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' SET name="'.$this->db->escape($name).'"'; + $sql .= ', fk_type='.$type; + $sql .= ', fk_profile='.$profile; + $sql .= ', parameter="'.$this->db->escape($parameter).'"'; + $sql .= ' WHERE rowid='.$printerid; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Delete a printer from db - * - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function deletePrinter($printerid) - { - global $conf; - $error = 0; - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE rowid='.$printerid; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Delete a printer from db + * + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function deletePrinter($printerid) + { + global $conf; + $error = 0; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE rowid='.$printerid; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to add a printer template in db - * - * @param string $name Template name - * @param int $template Template - * @return int 0 if OK; >0 if KO - */ - public function addTemplate($name, $template) - { - global $conf; - $error = 0; - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' (name, template, entity) VALUES ("'.$this->db->escape($name).'"'; - $sql .= ', "'.$this->db->escape($template).'", '.$conf->entity.')'; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to add a printer template in db + * + * @param string $name Template name + * @param int $template Template + * @return int 0 if OK; >0 if KO + */ + public function addTemplate($name, $template) + { + global $conf; + $error = 0; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' (name, template, entity) VALUES ("'.$this->db->escape($name).'"'; + $sql .= ', "'.$this->db->escape($template).'", '.$conf->entity.')'; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to delete a printer template in db - * - * @param int $templateid Template ID - * @return int 0 if OK; >0 if KO - */ - public function deleteTemplate($templateid) - { - global $conf; - $error = 0; - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= " WHERE rowid = ".((int) $this->db->escape($templateid)); - $sql .= " AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to delete a printer template in db + * + * @param int $templateid Template ID + * @return int 0 if OK; >0 if KO + */ + public function deleteTemplate($templateid) + { + global $conf; + $error = 0; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= " WHERE rowid = ".((int) $this->db->escape($templateid)); + $sql .= " AND entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Update a printer template in db - * - * @param string $name Template name - * @param int $template Template - * @param int $templateid Template id - * @return int 0 if OK; >0 if KO - */ - public function updateTemplate($name, $template, $templateid) - { - global $conf; - $error = 0; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' SET name="'.$this->db->escape($name).'"'; - $sql .= ', template="'.$this->db->escape($template).'"'; - $sql .= ' WHERE rowid='.$templateid; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Update a printer template in db + * + * @param string $name Template name + * @param int $template Template + * @param int $templateid Template id + * @return int 0 if OK; >0 if KO + */ + public function updateTemplate($name, $template, $templateid) + { + global $conf; + $error = 0; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' SET name="'.$this->db->escape($name).'"'; + $sql .= ', template="'.$this->db->escape($template).'"'; + $sql .= ' WHERE rowid='.$templateid; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Send Test page to Printer - * - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function sendTestToPrinter($printerid) - { - global $conf; - $error = 0; - $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png'); - //$this->profile = CapabilityProfile::load("TM-T88IV"); - $ret = $this->initPrinter($printerid); - if ($ret > 0) { - setEventMessages($this->error, $this->errors, 'errors'); - } else { - try { - $this->printer->bitImage($img); - $this->printer->text("Hello World!\n"); - $testStr = "1234567890"; - $this->printer->barcode($testStr); - //$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1); - $this->printer->text("Most simple example\n"); - $this->printer->feed(); - $this->printer->cut(); + /** + * Function to Send Test page to Printer + * + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function sendTestToPrinter($printerid) + { + global $conf; + $error = 0; + $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png'); + //$this->profile = CapabilityProfile::load("TM-T88IV"); + $ret = $this->initPrinter($printerid); + if ($ret > 0) { + setEventMessages($this->error, $this->errors, 'errors'); + } else { + try { + $this->printer->bitImage($img); + $this->printer->text("Hello World!\n"); + $testStr = "1234567890"; + $this->printer->barcode($testStr); + //$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1); + $this->printer->text("Most simple example\n"); + $this->printer->feed(); + $this->printer->cut(); // If is DummyPrintConnector send to log to debugging if ($this->printer->connector instanceof DummyPrintConnector) @@ -545,225 +545,227 @@ class dolReceiptPrinter extends Printer $data = $this->printer->connector-> getData(); dol_syslog($data); } - $this->printer->close(); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $error++; - } - } - return $error; - } + $this->printer->close(); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + $error++; + } + } + return $error; + } - /** - * Function to Print Receipt Ticket - * - * @param Facture|Commande $object Order or invoice object - * @param int $templateid Template id - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function sendToPrinter($object, $templateid, $printerid) - { - global $conf, $mysoc, $langs, $user; - $error = 0; - $ret = $this->loadTemplate($templateid); + /** + * Function to Print Receipt Ticket + * + * @param Facture|Commande $object Order or invoice object + * @param int $templateid Template id + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function sendToPrinter($object, $templateid, $printerid) + { + global $conf, $mysoc, $langs, $user; + $error = 0; + $ret = $this->loadTemplate($templateid); - // tags a remplacer par leur valeur avant de parser (dol_value_xxx) - $this->template = str_replace('', $object->id, $this->template); - $this->template = str_replace('', $object->ref, $this->template); - //$this->template = str_replace('', $object->points, $this->template); - $this->template = str_replace('', dol_print_date($object->date, 'day'), $this->template); - $this->template = str_replace('', dol_print_date($object->date, 'dayhour'), $this->template); - $this->template = str_replace('', dol_print_date($object->date, '%Y'), $this->template); - $this->template = str_replace('', $langs->trans("Month".dol_print_date($object->date, '%m')), $this->template); - $this->template = str_replace('', dol_print_date($object->date, '%m'), $this->template); - $this->template = str_replace('', dol_print_date($object->date, '%d'), $this->template); - $this->template = str_replace('', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template); + // tags a remplacer par leur valeur avant de parser (dol_value_xxx) + $this->template = str_replace('{dol_value_object_id}', $object->id, $this->template); + $this->template = str_replace('{dol_value_object_ref}', $object->ref, $this->template); + //$this->template = str_replace('', $object->points, $this->template); + $this->template = str_replace('{dol_value_date}', dol_print_date($object->date, 'day'), $this->template); + $this->template = str_replace('{dol_value_date_time}', dol_print_date($object->date, 'dayhour'), $this->template); + $this->template = str_replace('{dol_value_year}', dol_print_date($object->date, '%Y'), $this->template); + $this->template = str_replace('{dol_value_month_letters}', $langs->trans("Month".dol_print_date($object->date, '%m')), $this->template); + $this->template = str_replace('{dol_value_month}', dol_print_date($object->date, '%m'), $this->template); + $this->template = str_replace('{dol_value_day}', dol_print_date($object->date, '%d'), $this->template); + $this->template = str_replace('{dol_value_day_letters}', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template); - $this->template = str_replace('', $object->thirdparty->firstname, $this->template); - $this->template = str_replace('', $object->thirdparty->lastname, $this->template); - $this->template = str_replace('', $object->thirdparty->email, $this->template); - $this->template = str_replace('', $object->thirdparty->phone, $this->template); - //$this->template = str_replace('', $object->thirdparty->mobile, $this->template); - $this->template = str_replace('', $object->thirdparty->tva_intra, $this->template); - //$this->template = str_replace('', $object->customer_account_balance, $this->template); - //$this->template = str_replace('', $object->customer_points, $this->template); + $this->template = str_replace('{dol_value_customer_firstname}', $object->thirdparty->firstname, $this->template); + $this->template = str_replace('{dol_value_customer_lastname}', $object->thirdparty->lastname, $this->template); + $this->template = str_replace('{dol_value_customer_mail}', $object->thirdparty->email, $this->template); + $this->template = str_replace('{dol_value_customer_phone}', $object->thirdparty->phone, $this->template); + //$this->template = str_replace('', $object->thirdparty->mobile, $this->template); + $this->template = str_replace('{dol_value_customer_tax_number}', $object->thirdparty->tva_intra, $this->template); + //$this->template = str_replace('', $object->customer_account_balance, $this->template); + //$this->template = str_replace('', $object->customer_points, $this->template); - $this->template = str_replace('', $mysoc->name, $this->template); - $this->template = str_replace('', $mysoc->address, $this->template); - $this->template = str_replace('', $mysoc->zip, $this->template); - $this->template = str_replace('', $mysoc->town, $this->template); - $this->template = str_replace('', $mysoc->country, $this->template); - $this->template = str_replace('', $mysoc->idprof1, $this->template); - $this->template = str_replace('', $mysoc->idprof2, $this->template); - $this->template = str_replace('', $mysoc->idprof3, $this->template); - $this->template = str_replace('', $mysoc->idprof4, $this->template); - $this->template = str_replace('', $mysoc->idprof5, $this->template); - $this->template = str_replace('', $mysoc->idprof6, $this->template); - $this->template = str_replace('', $mysoc->tva_intra, $this->template); - $this->template = str_replace('', $mysoc->capital, $this->template); + $this->template = str_replace('{dol_value_mysoc_name}', $mysoc->name, $this->template); + $this->template = str_replace('{dol_value_mysoc_address}', $mysoc->address, $this->template); + $this->template = str_replace('{dol_value_mysoc_zip}', $mysoc->zip, $this->template); + $this->template = str_replace('{dol_value_mysoc_town}', $mysoc->town, $this->template); + $this->template = str_replace('{dol_value_mysoc_country}', $mysoc->country, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof1}', $mysoc->idprof1, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof2}', $mysoc->idprof2, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof3}', $mysoc->idprof3, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof4}', $mysoc->idprof4, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof5}', $mysoc->idprof5, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof6}', $mysoc->idprof6, $this->template); + $this->template = str_replace('{dol_value_mysoc_tva_intra}', $mysoc->tva_intra, $this->template); + $this->template = str_replace('{dol_value_mysoc_capital}', $mysoc->capital, $this->template); - $this->template = str_replace('', $user->firstname, $this->template); - $this->template = str_replace('', $user->lastname, $this->template); - $this->template = str_replace('', $user->email, $this->template); + $this->template = str_replace('{dol_value_vendor_firstname}', $user->firstname, $this->template); + $this->template = str_replace('{dol_value_vendor_lastname}', $user->lastname, $this->template); + $this->template = str_replace('{dol_value_vendor_mail}', $user->email, $this->template); - // parse template - $p = xml_parser_create(); - xml_parse_into_struct($p, $this->template, $vals, $index); - xml_parser_free($p); - //print '
    '.print_r($index, true).'
    '; - //print '
    '.print_r($vals, true).'
    '; - // print ticket - $level = 0; - $nbcharactbyline = (!empty($conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE) ? $conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE : 48); - $ret = $this->initPrinter($printerid); - if ($ret > 0) { - setEventMessages($this->error, $this->errors, 'errors'); - } else { - $nboflines = count($vals); - for ($tplline = 0; $tplline < $nboflines; $tplline++) { - //var_dump($vals[$tplline]['value']); - switch ($vals[$tplline]['tag']) { - case 'DOL_PRINT_TEXT': - $this->printer->text($vals[$tplline]['value']); - break; - case 'DOL_PRINT_OBJECT_LINES': - foreach ($object->lines as $line) { - //var_dump($line); - $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); - $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TAX': - //var_dump($object); - $vatarray = array(); - foreach ($object->lines as $line) { - $vatarray[$line->tva_tx] += $line->total_tva; - } - foreach ($vatarray as $vatkey => $vatvalue) { - $spacestoadd = $nbcharactbyline - strlen($vatkey) - 12; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($spaces.$vatkey.'% '.str_pad(price($vatvalue), 10, ' ', STR_PAD_LEFT)."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TAX1': - //var_dump($object); - $total_localtax1 = 0; - foreach ($object->lines as $line) { - $total_localtax1 += $line->total_localtax1; - } - foreach ($vatarray as $vatkey => $vatvalue) { - $this->printer->text(str_pad(price($total_localtax1), 10, ' ', STR_PAD_LEFT)."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TAX2': - //var_dump($object); - $total_localtax2 = 0; - foreach ($object->lines as $line) { - $total_localtax2 += $line->total_localtax2; - } - foreach ($vatarray as $vatkey => $vatvalue) { - $this->printer->text(str_pad(price($total_localtax2), 10, ' ', STR_PAD_LEFT)."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TOTAL': - $title = $langs->trans('TotalHT'); - $spacestoadd = $nbcharactbyline - strlen($title) - 10; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($title.$spaces.str_pad(price($object->total_ht), 10, ' ', STR_PAD_LEFT)."\n"); - $title = $langs->trans('TotalVAT'); - $spacestoadd = $nbcharactbyline - strlen($title) - 10; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($title.$spaces.str_pad(price($object->total_tva), 10, ' ', STR_PAD_LEFT)."\n"); - $title = $langs->trans('TotalTTC'); - $spacestoadd = $nbcharactbyline - strlen($title) - 10; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); - break; - case 'DOL_LINE_FEED': - $this->printer->feed(); - break; - case 'DOL_LINE_FEED_REVERSE': - $this->printer->feedReverse(); - break; - case 'DOL_ALIGN_CENTER': - $this->printer->setJustification(Printer::JUSTIFY_CENTER); - break; - case 'DOL_ALIGN_RIGHT': - $this->printer->setJustification(Printer::JUSTIFY_RIGHT); - break; - case 'DOL_ALIGN_LEFT': - $this->printer->setJustification(Printer::JUSTIFY_LEFT); - break; - case 'DOL_OPEN_DRAWER': - $this->printer->pulse(); - break; - case 'DOL_ACTIVATE_BUZZER': - //$this->printer->buzzer(); - break; - case 'DOL_PRINT_BARCODE': - // $vals[$tplline]['value'] -> barcode($content, $type) - // var_dump($vals[$tplline]['value']); - try { - $this->printer->barcode($vals[$tplline]['value']); - } catch (Exception $e) { - $this->errors[] = 'Invalid Barcode value: '.$vals[$tplline]['value']; - $error++; - } - break; - case 'DOL_PRINT_LOGO': - $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); - $this->printer->graphics($img); - break; - case 'DOL_PRINT_LOGO_OLD': - $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); - $this->printer->bitImage($img); - break; - case 'DOL_PRINT_QRCODE': - // $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model) - $this->printer->qrcode($vals[$tplline]['value']); - break; - case 'DOL_CUT_PAPER_FULL': - $this->printer->cut(Printer::CUT_FULL); - break; - case 'DOL_CUT_PAPER_PARTIAL': - $this->printer->cut(Printer::CUT_PARTIAL); - break; - case 'DOL_USE_FONT_A': - $this->printer->setFont(Printer::FONT_A); - break; - case 'DOL_USE_FONT_B': - $this->printer->setFont(Printer::FONT_B); - break; - case 'DOL_USE_FONT_C': - $this->printer->setFont(Printer::FONT_C); - break; + // parse template + $this->template = str_replace("{", "<", $this->template); + $this->template = str_replace("}", ">", $this->template); + $p = xml_parser_create(); + xml_parse_into_struct($p, $this->template, $vals, $index); + xml_parser_free($p); + //print '
    '.print_r($index, true).'
    '; + //print '
    '.print_r($vals, true).'
    '; + // print ticket + $level = 0; + $nbcharactbyline = (!empty($conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE) ? $conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE : 48); + $ret = $this->initPrinter($printerid); + if ($ret > 0) { + setEventMessages($this->error, $this->errors, 'errors'); + } else { + $nboflines = count($vals); + for ($tplline = 0; $tplline < $nboflines; $tplline++) { + //var_dump($vals[$tplline]['value']); + switch ($vals[$tplline]['tag']) { + case 'DOL_PRINT_TEXT': + $this->printer->text($vals[$tplline]['value']); + break; + case 'DOL_PRINT_OBJECT_LINES': + foreach ($object->lines as $line) { + //var_dump($line); + $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); + $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TAX': + //var_dump($object); + $vatarray = array(); + foreach ($object->lines as $line) { + $vatarray[$line->tva_tx] += $line->total_tva; + } + foreach ($vatarray as $vatkey => $vatvalue) { + $spacestoadd = $nbcharactbyline - strlen($vatkey) - 12; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($spaces.$vatkey.'% '.str_pad(price($vatvalue), 10, ' ', STR_PAD_LEFT)."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TAX1': + //var_dump($object); + $total_localtax1 = 0; + foreach ($object->lines as $line) { + $total_localtax1 += $line->total_localtax1; + } + foreach ($vatarray as $vatkey => $vatvalue) { + $this->printer->text(str_pad(price($total_localtax1), 10, ' ', STR_PAD_LEFT)."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TAX2': + //var_dump($object); + $total_localtax2 = 0; + foreach ($object->lines as $line) { + $total_localtax2 += $line->total_localtax2; + } + foreach ($vatarray as $vatkey => $vatvalue) { + $this->printer->text(str_pad(price($total_localtax2), 10, ' ', STR_PAD_LEFT)."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TOTAL': + $title = $langs->trans('TotalHT'); + $spacestoadd = $nbcharactbyline - strlen($title) - 10; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($title.$spaces.str_pad(price($object->total_ht), 10, ' ', STR_PAD_LEFT)."\n"); + $title = $langs->trans('TotalVAT'); + $spacestoadd = $nbcharactbyline - strlen($title) - 10; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($title.$spaces.str_pad(price($object->total_tva), 10, ' ', STR_PAD_LEFT)."\n"); + $title = $langs->trans('TotalTTC'); + $spacestoadd = $nbcharactbyline - strlen($title) - 10; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); + break; + case 'DOL_LINE_FEED': + $this->printer->feed(); + break; + case 'DOL_LINE_FEED_REVERSE': + $this->printer->feedReverse(); + break; + case 'DOL_ALIGN_CENTER': + $this->printer->setJustification(Printer::JUSTIFY_CENTER); + break; + case 'DOL_ALIGN_RIGHT': + $this->printer->setJustification(Printer::JUSTIFY_RIGHT); + break; + case 'DOL_ALIGN_LEFT': + $this->printer->setJustification(Printer::JUSTIFY_LEFT); + break; + case 'DOL_OPEN_DRAWER': + $this->printer->pulse(); + break; + case 'DOL_ACTIVATE_BUZZER': + //$this->printer->buzzer(); + break; + case 'DOL_PRINT_BARCODE': + // $vals[$tplline]['value'] -> barcode($content, $type) + // var_dump($vals[$tplline]['value']); + try { + $this->printer->barcode($vals[$tplline]['value']); + } catch (Exception $e) { + $this->errors[] = 'Invalid Barcode value: '.$vals[$tplline]['value']; + $error++; + } + break; + case 'DOL_PRINT_LOGO': + $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); + $this->printer->graphics($img); + break; + case 'DOL_PRINT_LOGO_OLD': + $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); + $this->printer->bitImage($img); + break; + case 'DOL_PRINT_QRCODE': + // $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model) + $this->printer->qrcode($vals[$tplline]['value']); + break; + case 'DOL_CUT_PAPER_FULL': + $this->printer->cut(Printer::CUT_FULL); + break; + case 'DOL_CUT_PAPER_PARTIAL': + $this->printer->cut(Printer::CUT_PARTIAL); + break; + case 'DOL_USE_FONT_A': + $this->printer->setFont(Printer::FONT_A); + break; + case 'DOL_USE_FONT_B': + $this->printer->setFont(Printer::FONT_B); + break; + case 'DOL_USE_FONT_C': + $this->printer->setFont(Printer::FONT_C); + break; case 'DOL_BOLD': - $this->printer->setEmphasis(true); - break; + $this->printer->setEmphasis(true); + break; case 'DOL_BOLD_DISABLED': - $this->printer->setEmphasis(false); - break; + $this->printer->setEmphasis(false); + break; case 'DOL_DOUBLE_HEIGHT': - $this->printer->setTextSize(1, 2); - break; + $this->printer->setTextSize(1, 2); + break; case 'DOL_DOUBLE_WIDTH': - $this->printer->setTextSize(2, 1); - break; + $this->printer->setTextSize(2, 1); + break; case 'DOL_DEFAULT_HEIGHT_WIDTH': - $this->printer->setTextSize(1, 1); - break; + $this->printer->setTextSize(1, 1); + break; case 'DOL_UNDERLINE': - $this->printer->setUnderline(true); - break; + $this->printer->setUnderline(true); + break; case 'DOL_UNDERLINE_DISABLED': - $this->printer->setUnderline(false); - break; + $this->printer->setUnderline(false); + break; case 'DOL_BEEP': - $this->printer->getPrintConnector() -> write("\x1e"); - break; + $this->printer->getPrintConnector() -> write("\x1e"); + break; case 'DOL_PRINT_ORDER_LINES': foreach ($object->lines as $line) { if ($line->special_code == $this->orderprinter) @@ -773,7 +775,7 @@ class dolReceiptPrinter extends Printer $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); $this->printer->text(strip_tags(htmlspecialchars_decode($line->desc))."\n"); } - } + } break; case 'DOL_PRINT_PAYMENT': $sql = "SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; @@ -791,10 +793,10 @@ class dolReceiptPrinter extends Printer $row = $this->db->fetch_object($resql); $spacestoadd = $nbcharactbyline - strlen($langs->transnoentitiesnoconv("PaymentTypeShort".$row->code)) - 12; $spaces = str_repeat(' ', $spacestoadd); - $amount_payment=($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; + $amount_payment = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment $this->printer->text($spaces.$langs->transnoentitiesnoconv("PaymentTypeShort".$row->code).' '.str_pad(price($amount_payment), 10, ' ', STR_PAD_LEFT)."\n"); - if ($row->code == "LIQ" && $row->pos_change>0) // Print change only in cash payments + if ($row->code == "LIQ" && $row->pos_change > 0) // Print change only in cash payments { $spacestoadd = $nbcharactbyline - strlen($langs->trans("Change")) - 12; $spaces = str_repeat(' ', $spacestoadd); @@ -804,114 +806,119 @@ class dolReceiptPrinter extends Printer } } break; - default: - $this->printer->text($vals[$tplline]['tag']); - $this->printer->text($vals[$tplline]['value']); - $this->errors[] = 'UnknowTag: <'.strtolower($vals[$tplline]['tag']).'>'; - $error++; - break; - } - } - // If is DummyPrintConnector send to log to debugging - if ($this->printer->connector instanceof DummyPrintConnector) + default: + $this->printer->text($vals[$tplline]['tag']); + $this->printer->text($vals[$tplline]['value']); + $this->errors[] = 'UnknowTag: <'.strtolower($vals[$tplline]['tag']).'>'; + $error++; + break; + } + } + // If is DummyPrintConnector send to log to debugging + if ($this->printer->connector instanceof DummyPrintConnector || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { $data = $this->printer->connector->getData(); if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") echo base64_encode($data); dol_syslog($data); } // Close and print - $this->printer->close(); - } - return $error; - } + $this->printer->close(); + } + return $error; + } - /** - * Function to load Template - * - * @param int $templateid Template id - * @return int 0 if OK; >0 if KO - */ - public function loadTemplate($templateid) - { - global $conf; - $error = 0; - $sql = 'SELECT template'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' WHERE rowid='.$templateid; - $sql .= ' AND entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $obj = $this->db->fetch_array($resql); - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - if (empty($obj)) { - $error++; - $this->errors[] = 'TemplateDontExist'; - } else { - $this->template = $obj['0']; - } + /** + * Function to load Template + * + * @param int $templateid Template id + * @return int 0 if OK; >0 if KO + */ + public function loadTemplate($templateid) + { + global $conf; + $error = 0; + $sql = 'SELECT template'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' WHERE rowid='.$templateid; + $sql .= ' AND entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_array($resql); + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + if (empty($obj)) { + $error++; + $this->errors[] = 'TemplateDontExist'; + } else { + $this->template = $obj['0']; + } - return $error; - } + return $error; + } - /** - * Function Init Printer - * - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function initPrinter($printerid) - { - global $conf; - $error = 0; - $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE rowid = '.$printerid; - $sql .= ' AND entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $obj = $this->db->fetch_array($resql); - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - if (empty($obj)) { - $error++; - $this->errors[] = 'PrinterDontExist'; - } - if (!$error) { - $parameter = $obj['parameter']; - try { - switch ($obj['fk_type']) { - case 1: - $this->connector = new DummyPrintConnector(); - break; - case 2: - $this->connector = new FilePrintConnector($parameter); - break; - case 3: - $parameters = explode(':', $parameter); - $this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]); - break; - case 4: - $this->connector = new WindowsPrintConnector($parameter); - break; + /** + * Function Init Printer + * + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function initPrinter($printerid) + { + global $conf; + if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { + $this->connector = new DummyPrintConnector(); + $this->printer = new Printer($this->connector, $this->profile); + return; + } + $error = 0; + $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE rowid = '.$printerid; + $sql .= ' AND entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_array($resql); + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + if (empty($obj)) { + $error++; + $this->errors[] = 'PrinterDontExist'; + } + if (!$error) { + $parameter = $obj['parameter']; + try { + switch ($obj['fk_type']) { + case 1: + $this->connector = new DummyPrintConnector(); + break; + case 2: + $this->connector = new FilePrintConnector($parameter); + break; + case 3: + $parameters = explode(':', $parameter); + $this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]); + break; + case 4: + $this->connector = new WindowsPrintConnector($parameter); + break; case 5: - $this->connector = new CupsPrintConnector($parameter); - break; - default: - $this->connector = 'CONNECTOR_UNKNOWN'; - break; - } - $this->printer = new Printer($this->connector, $this->profile); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $error++; - } - } - return $error; - } + $this->connector = new CupsPrintConnector($parameter); + break; + default: + $this->connector = 'CONNECTOR_UNKNOWN'; + break; + } + $this->printer = new Printer($this->connector, $this->profile); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + $error++; + } + } + return $error; + } } diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 7cf18ae4801..efb2e554da9 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -114,21 +114,20 @@ class EmailSenderProfile extends CommonObject public $entity; /** - * @var string Email Sender Profile label - */ - public $label; + * @var string Email Sender Profile label + */ + public $label; public $email; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; public $tms; - //public $fk_user_creat; - //public $fk_user_modif; + public $private; public $signature; public $position; public $active; @@ -306,9 +305,9 @@ class EmailSenderProfile extends CommonObject $result = ''; $companylink = ''; - $label = $this->label; + $label = $this->label; - $url = ''; + $url = ''; //$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id; $linkstart = ''; @@ -333,7 +332,7 @@ class EmailSenderProfile extends CommonObject return $this->LibStatut($this->active, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -357,8 +356,8 @@ class EmailSenderProfile extends CommonObject return dolGetStatus($label, $labelshort, '', $statusType, $mode); } - /** - * Charge les informations d'ordre info dans l'objet commande + /** + * Charge les informations d'ordre info dans l'objet commande * * @param int $id Id of order * @return void diff --git a/htdocs/core/class/evalmath.class.php b/htdocs/core/class/evalmath.class.php index 7e02aa57032..c30c37266c1 100644 --- a/htdocs/core/class/evalmath.class.php +++ b/htdocs/core/class/evalmath.class.php @@ -149,8 +149,8 @@ class EvalMath $expr = trim($expr); if (substr($expr, - 1, 1) == ';') $expr = substr($expr, 0, strlen($expr) - 1); // strip semicolons at the end - // =============== - // is it a variable assignment? + // =============== + // is it a variable assignment? $matches = array(); if (preg_match('/^\s*([a-z]\w*)\s*=\s*(.+)$/', $expr, $matches)) { if (in_array($matches[1], $this->vb)) { // make sure we're not assigning to a constant @@ -160,8 +160,8 @@ class EvalMath return false; // get the result and make sure it's good $this->v[$matches[1]] = $tmp; // if so, stick it in the variable array return $this->v[$matches[1]]; // and return the resulting value - // =============== - // is it a function assignment? + // =============== + // is it a function assignment? } elseif (preg_match('/^\s*([a-z]\w*)\s*\(\s*([a-z]\w*(?:\s*,\s*[a-z]\w*)*)\s*\)\s*=\s*(.+)$/', $expr, $matches)) { $fnn = $matches[1]; // get the function name if (in_array($matches[1], $this->fb)) { // make sure it isn't built in @@ -235,7 +235,7 @@ class EvalMath $ops_p = array('+' => 0, '-' => 0, '*' => 1, '/' => 1, '_' => 1, '^' => 2); // operator precedence $expecting_op = false; // we use this in syntax-checking the expression - // and determining when a - is a negation + // and determining when a - is a negation $matches = array(); if (preg_match("/[^\w\s+*^\/()\.,-]/", $expr, $matches)) { // make sure the characters are all good @@ -244,7 +244,7 @@ class EvalMath while (1) { // 1 Infinite Loop ;) $op = substr($expr, $index, 1); // get the first character at the current index - // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand + // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand $match = array(); $ex = preg_match('/^([a-z]\w*\(?|\d+(?:\.\d*)?|\.\d+|\()/', substr($expr, $index), $match); // =============== @@ -253,7 +253,7 @@ class EvalMath $index++; } elseif ($op == '_') { // we have to explicitly deny this, because it's legal on the stack return $this->trigger(4, "illegal character '_'", "_"); // but not in the input expression - // =============== + // =============== } elseif ((in_array($op, $ops) or $ex) and $expecting_op) { // are we putting an operator on the stack? if ($ex) { // are we expecting an operator but have a number/variable/function/opening parethesis? $op = '*'; @@ -372,7 +372,7 @@ class EvalMath $stack = new EvalMathStack(); foreach ($tokens as $token) { // nice and easy - // if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on + // if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on $matches = array(); if (in_array($token, array('+', '-', '*', '/', '^'))) { if (is_null($op2 = $stack->pop())) @@ -412,7 +412,7 @@ class EvalMath $fnn = 'log'; eval('$stack->push('.$fnn.'($op1));'); // perfectly safe eval() } elseif (array_key_exists($fnn, $this->f)) { // user function - // get args + // get args $args = array(); for ($i = count($this->f[$fnn]['args']) - 1; $i >= 0; $i--) { if (is_null($args[$this->f[$fnn]['args'][$i]] = $stack->pop())) diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index bffd23f05d2..1b8a9eb3291 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -43,10 +43,10 @@ class Events // extends CommonObject */ public $id; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -58,7 +58,7 @@ class Events // extends CommonObject */ public $tms; - /** + /** * @var string Type */ public $type; @@ -94,7 +94,7 @@ class Events // extends CommonObject public $eventstolog = array( array('id'=>'USER_LOGIN', 'test'=>1), array('id'=>'USER_LOGIN_FAILED', 'test'=>1), - array('id'=>'USER_LOGOUT', 'test'=>1), + array('id'=>'USER_LOGOUT', 'test'=>1), array('id'=>'USER_CREATE', 'test'=>1), array('id'=>'USER_MODIFY', 'test'=>1), array('id'=>'USER_NEW_PASSWORD', 'test'=>1), @@ -141,7 +141,7 @@ class Events // extends CommonObject // Clean parameters $this->description = trim($this->description); - if (empty($this->user_agent) && !empty($_SERVER['HTTP_USER_AGENT'])) $this->user_agent = $_SERVER['HTTP_USER_AGENT']; + if (empty($this->user_agent)) $this->user_agent = (empty($_SERVER['HTTP_USER_AGENT'])?'':$_SERVER['HTTP_USER_AGENT']); // Check parameters if (empty($this->description)) { $this->error = 'ErrorBadValueForParameterCreateEventDesc'; return -1; } @@ -187,7 +187,7 @@ class Events // extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - public function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { // Clean parameters $this->id = (int) $this->id; @@ -222,7 +222,7 @@ class Events // extends CommonObject * @param User $user User that load * @return int <0 if KO, >0 if OK */ - public function fetch($id, $user = null) + public function fetch($id, $user = null) { $sql = "SELECT"; $sql .= " t.rowid,"; @@ -271,7 +271,7 @@ class Events // extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - public function delete($user) + public function delete($user) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."events"; $sql .= " WHERE rowid=".$this->id; @@ -289,13 +289,13 @@ class Events // extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() { $this->id = 0; @@ -306,5 +306,5 @@ class Events // extends CommonObject $this->ip = '1.2.3.4'; $this->user_agent = 'Mozilla specimen User Agent X.Y'; $this->prefix_session = dol_getprefix(); - } + } } diff --git a/htdocs/core/class/extralanguages.class.php b/htdocs/core/class/extralanguages.class.php index a57fa20f510..34c2e34dc82 100644 --- a/htdocs/core/class/extralanguages.class.php +++ b/htdocs/core/class/extralanguages.class.php @@ -28,13 +28,13 @@ class ExtraLanguages { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** - * @var array New array to store extralanguages definition - */ + * @var array New array to store extralanguages definition + */ public $attributes; /** @@ -47,7 +47,7 @@ class ExtraLanguages */ public $errors = array(); - /** + /** * @var string DB Error number */ public $errno; @@ -57,7 +57,7 @@ class ExtraLanguages * Constructor * * @param DoliDB $db Database handler - */ + */ public function __construct($db) { $this->db = $db; @@ -67,7 +67,7 @@ class ExtraLanguages } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array this->attributes with list of fields per object that need an alternate translation. The object and field must be managed with * the widgetForTranslation() method. @@ -80,7 +80,7 @@ class ExtraLanguages */ public function fetch_name_extralanguages($elementtype, $forceload = false) { - // phpcs:enable + // phpcs:enable global $conf; if (empty($elementtype)) return array(); diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index c941a3a0745..b601994536e 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -176,16 +176,16 @@ class FileUpload ) ); - $hookmanager->executeHooks( - 'overrideUploadOptions', - array( - 'options' => &$options, - 'element' => $element - ), - $object, - $action, - $hookmanager - ); + $hookmanager->executeHooks( + 'overrideUploadOptions', + array( + 'options' => &$options, + 'element' => $element + ), + $object, + $action, + $hookmanager + ); if ($options) { $this->options = array_replace_recursive($this->options, $options); @@ -504,26 +504,26 @@ class FileUpload // param_name is an array identifier like "files[]", // $_FILES is a multi-dimensional array: foreach ($upload['tmp_name'] as $index => $value) { - $info[] = $this->handleFileUpload( - $upload['tmp_name'][$index], - isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index], - isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index], - isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index], - $upload['error'][$index], - $index - ); + $info[] = $this->handleFileUpload( + $upload['tmp_name'][$index], + isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index], + isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index], + isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index], + $upload['error'][$index], + $index + ); } } elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) { // param_name is a single object identifier like "file", // $_FILES is a one-dimensional array: - $info[] = $this->handleFileUpload( - isset($upload['tmp_name']) ? $upload['tmp_name'] : null, - isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ? $upload['name'] : null), - isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ? $upload['size'] : null), - isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ? $upload['type'] : null), - isset($upload['error']) ? $upload['error'] : null, - 0 - ); + $info[] = $this->handleFileUpload( + isset($upload['tmp_name']) ? $upload['tmp_name'] : null, + isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ? $upload['name'] : null), + isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ? $upload['size'] : null), + isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ? $upload['type'] : null), + isset($upload['error']) ? $upload['error'] : null, + 0 + ); } header('Vary: Accept'); $json = json_encode($info); diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index c0216f16a19..0e822076641 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -69,25 +69,25 @@ class Fiscalyear extends CommonObject public $label; /** - * Date start (date_start) - * - * @var integer - */ + * Date start (date_start) + * + * @var integer + */ public $date_start; /** - * Date end (date_end) - * - * @var integer - */ + * Date end (date_end) + * + * @var integer + */ public $date_end; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; public $statut; // 0=open, 1=closed @@ -214,11 +214,11 @@ class Fiscalyear extends CommonObject } /** - * Load an object from database - * - * @param int $id Id of record to load - * @return int <0 if KO, >0 if OK - */ + * Load an object from database + * + * @param int $id Id of record to load + * @return int <0 if KO, >0 if OK + */ public function fetch($id) { $sql = "SELECT rowid, label, date_start, date_end, statut"; @@ -245,7 +245,7 @@ class Fiscalyear extends CommonObject } } - /** + /** * Delete record * * @param int $id Id of record to delete diff --git a/htdocs/core/class/genericobject.class.php b/htdocs/core/class/genericobject.class.php index 25f3dc6af11..e27e45de954 100644 --- a/htdocs/core/class/genericobject.class.php +++ b/htdocs/core/class/genericobject.class.php @@ -29,13 +29,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; class GenericObject extends CommonObject { - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } } diff --git a/htdocs/core/class/google.class.php b/htdocs/core/class/google.class.php index 117b8e30e02..ee122ff7cb5 100644 --- a/htdocs/core/class/google.class.php +++ b/htdocs/core/class/google.class.php @@ -26,63 +26,63 @@ */ class GoogleAPI { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - public $key; + public $key; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $key Google key - */ - public function __construct($db, $key) - { - $this->db = $db; - $this->key = $key; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $key Google key + */ + public function __construct($db, $key) + { + $this->db = $db; + $this->key = $key; + } - /** - * Return geo coordinates of an address - * - * @param string $address Address - * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France - * Example: 188, rue de Fontenay,+94300,+Vincennes,+France - * @return string Coordinates - */ - public function getGeoCoordinatesOfAddress($address) - { - global $conf; + /** + * Return geo coordinates of an address + * + * @param string $address Address + * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France + * Example: 188, rue de Fontenay,+94300,+Vincennes,+France + * @return string Coordinates + */ + public function getGeoCoordinatesOfAddress($address) + { + global $conf; - $i = 0; + $i = 0; - // Desired address - $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; + // Desired address + $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; - // Retrieve the URL contents - $page = file_get_contents($urladdress); + // Retrieve the URL contents + $page = file_get_contents($urladdress); - $code = strstr($page, ''); - $code = strstr($code, '>'); - $val = strpos($code, "<"); - $code = substr($code, 1, $val - 1); - //print $code; - //print "
    "; - $latitude = substr($code, 0, strpos($code, ",")); - $longitude = substr($code, strpos($code, ",") + 1, dol_strlen(strpos($code, ",")) - 3); + $code = strstr($page, ''); + $code = strstr($code, '>'); + $val = strpos($code, "<"); + $code = substr($code, 1, $val - 1); + //print $code; + //print "
    "; + $latitude = substr($code, 0, strpos($code, ",")); + $longitude = substr($code, strpos($code, ",") + 1, dol_strlen(strpos($code, ",")) - 3); - // Output the coordinates - //echo "Longitude: $longitude ',' Latitude: $latitude"; + // Output the coordinates + //echo "Longitude: $longitude ',' Latitude: $latitude"; - $i++; - } + $i++; + } } diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 3c094ff5a6b..89b5a79df4b 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -105,7 +105,7 @@ class HookManager if (in_array($context, $arrayhooks) || in_array('all', $arrayhooks)) // We instantiate action class only if initialized hook is handled by module { // Include actions class overwriting hooks - if (!is_object($this->hooks[$context][$module])) // If set, class was already loaded + if (empty($this->hooks[$context][$module]) || !is_object($this->hooks[$context][$module])) // If set to an object value, class was already loaded { $path = '/'.$module.'/class/'; $actionfile = 'actions_'.$module.'.class.php'; @@ -144,7 +144,7 @@ class HookManager */ public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') { - if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing. + if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing. $parameters['context'] = join(':', $this->contextarray); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); @@ -167,6 +167,7 @@ class HookManager 'doActions', 'doMassActions', 'formatEvent', + 'formConfirm', 'formCreateThirdpartyOptions', 'formObjectOptions', 'formattachOptions', diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e58ba5d5a8e..68b5f7966ad 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -264,6 +264,7 @@ class Form elseif (preg_match('/^(amount|numeric)/', $typeofdata)) $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) $ret .= dol_htmlentitiesbr($value); elseif (preg_match('/^safehtmlstring/', $typeofdata)) $ret .= dol_string_onlythesehtmltags($value); + elseif (preg_match('/^restricthtml/', $typeofdata)) $ret .= dol_string_onlythesehtmltags($value); elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret .= dol_print_date($value, 'day'); elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') $ret .= dol_print_date($value, 'dayhour'); elseif (preg_match('/^select;/', $typeofdata)) @@ -508,7 +509,6 @@ class Form * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) * @return string Code html du tooltip (texte+picto) * @see textwithpicto() Use thisfunction if you can. - * TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip */ public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0) { @@ -810,7 +810,7 @@ class Form $out .= ''; if ($mysoc->isInEEC()) $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; } foreach ($countryArray as $row) @@ -823,7 +823,7 @@ class Form if (empty($row['favorite']) && $atleastonefavorite) { $atleastonefavorite = 0; - $out .= ''; + $out .= ''; } if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label'])) { @@ -1185,19 +1185,17 @@ class Form } } - // On recherche les societes + // We search companies $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; - - if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $sql .= ", s.address, s.zip, s.town"; $sql .= ", dictp.code as country_code"; } - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { - $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid=s.fk_pays"; + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid = s.fk_pays"; } + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (!empty($user->socid)) $sql .= " AND s.rowid = ".$user->socid; if ($filter) $sql .= " AND (".$filter.")"; @@ -1250,7 +1248,7 @@ class Form if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); else $textifempty .= $langs->trans("All"); } - if ($showempty) $out .= ''."\n"; + if ($showempty) $out .= '
    ').'">'.$textifempty.''."\n"; $num = $this->db->num_rows($resql); $i = 0; @@ -1285,10 +1283,10 @@ class Form if ($obj->client || $obj->fournisseur) $label .= ')'; } - if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { - $label .= '-'.$obj->address.'-'.$obj->zip.' '.$obj->town; + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { + $label .= ($obj->address ? ' - '.$obj->address : '').($obj->zip ? ' - '.$obj->zip : '').($obj->town ? ' '.$obj->town : ''); if (!empty($obj->country_code)) { - $label .= ' '.$langs->trans('Country'.$obj->country_code); + $label .= ', '.$langs->trans('Country'.$obj->country_code); } } @@ -1647,7 +1645,7 @@ class Form $outarray = array(); // Forge request to select users - $sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; + $sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut as status, u.login, u.admin, u.entity, u.photo"; if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) { $sql .= ", e.label"; @@ -1711,6 +1709,10 @@ class Form $userstatic->id = $obj->rowid; $userstatic->lastname = $obj->lastname; $userstatic->firstname = $obj->firstname; + $userstatic->photo = $obj->photo; + $userstatic->statut = $obj->status; + $userstatic->entity = $obj->entity; + $userstatic->admin = $obj->admin; $disableline = ''; if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) $disableline = ($enableonlytext ? $enableonlytext : '1'); @@ -1724,6 +1726,7 @@ class Form $fullNameMode = 1; //Firstname+lastname } $labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength); + if (empty($obj->firstname) && empty($obj->lastname)) $labeltoshow .= $obj->login; // Complete name with more info $moreinfo = ''; @@ -1733,11 +1736,11 @@ class Form } if ($showstatus >= 0) { - if ($obj->statut == 1 && $showstatus == 1) + if ($obj->status == 1 && $showstatus == 1) { $moreinfo .= ($moreinfo ? ' - ' : ' (').$langs->trans('Enabled'); } - if ($obj->statut == 0 && $showstatus == 1) + if ($obj->status == 0 && $showstatus == 1) { $moreinfo .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled'); } @@ -1763,10 +1766,17 @@ class Form if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) { $out .= ' selected'; } - if ($showstatus >= 0 && $obj->statut == 0) { - $out .= ' data-html="'.dol_escape_htmltag(''.$labeltoshow.'').'"'; + $out .= ' data-html="'; + $outhtml = ''; + if (!empty($obj->photo)) + { + $outhtml .= $userstatic->getNomUrl(-3, '', 0, 1, 24, 1, 'login', '', 1).' '; } - $out .= '>'; + if ($showstatus >= 0 && $obj->status == 0) $outhtml .= ''; + $outhtml .= $labeltoshow; + if ($showstatus >= 0 && $obj->status == 0) $outhtml .= ''; + $out .= dol_escape_htmltag($outhtml); + $out .= '">'; $out .= $labeltoshow; $out .= ''; @@ -1864,9 +1874,15 @@ class Form if ($action != 'view') { $out .= ''; - $out .= ''; + $out .= ''; $out .= $this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); - $out .= ' '; + $out .= ' '; $out .= '
    '; } @@ -3264,6 +3280,7 @@ class Form } print ''; if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ajax_combobox($htmlname); } /** @@ -3347,6 +3364,7 @@ class Form } print ''; if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ajax_combobox('select_'.$htmlname); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -3549,106 +3567,106 @@ class Form return $return; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load in cache list of transport mode - * - * @return int Nb of lines loaded, <0 if KO - */ - public function load_cache_transport_mode() - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load in cache list of transport mode + * + * @return int Nb of lines loaded, <0 if KO + */ + public function load_cache_transport_mode() + { + // phpcs:enable + global $langs; - $num=count($this->cache_transport_mode); - if ($num > 0) return $num; // Cache already loaded + $num = count($this->cache_transport_mode); + if ($num > 0) return $num; // Cache already loaded - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $this->cache_transport_mode = array(); + $this->cache_transport_mode = array(); - $sql = "SELECT rowid, code, label, active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; - $sql.= " WHERE entity IN (".getEntity('c_transport_mode').")"; - //if ($active >= 0) $sql.= " AND active = ".$active; + $sql = "SELECT rowid, code, label, active"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; + $sql .= " WHERE entity IN (".getEntity('c_transport_mode').")"; + //if ($active >= 0) $sql.= " AND active = ".$active; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); - // If traduction exist, we use it else we take the default label - $label=($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code):($obj->label!='-'?$obj->label:'')); - $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; - $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; - $this->cache_transport_mode[$obj->rowid]['label']= $label; - $this->cache_transport_mode[$obj->rowid]['active'] = $obj->active; - $i++; - } + // If traduction exist, we use it else we take the default label + $label = ($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code) != ("PaymentTypeShort".$obj->code) ? $langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); + $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; + $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; + $this->cache_transport_mode[$obj->rowid]['label'] = $label; + $this->cache_transport_mode[$obj->rowid]['active'] = $obj->active; + $i++; + } - $this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1); + $this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1); - return $num; - } - else { - dol_print_error($this->db); - return -1; - } - } + return $num; + } + else { + dol_print_error($this->db); + return -1; + } + } - /** - * Return list of transport mode for intracomm report - * - * @param string $selected Id of the transport mode pre-selected - * @param string $htmlname Name of the select field - * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code - * @param int $empty 1=can be empty, 0 else - * @param int $noadmininfo 0=Add admin info, 1=Disable admin info - * @param int $maxlength Max length of label - * @param int $active Active or not, -1 = all - * @param string $morecss Add more CSS on select tag - * @return void - */ - public function selectTransportMode($selected = '', $htmlname = 'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') - { - global $langs,$user; + /** + * Return list of transport mode for intracomm report + * + * @param string $selected Id of the transport mode pre-selected + * @param string $htmlname Name of the select field + * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code + * @param int $empty 1=can be empty, 0 else + * @param int $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int $maxlength Max length of label + * @param int $active Active or not, -1 = all + * @param string $morecss Add more CSS on select tag + * @return void + */ + public function selectTransportMode($selected = '', $htmlname = 'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') + { + global $langs, $user; - dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$format, LOG_DEBUG); + dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$format, LOG_DEBUG); - $this->load_cache_transport_mode(); + $this->load_cache_transport_mode(); - print ''; + if ($empty) print ''; + foreach ($this->cache_transport_mode as $id => $arraytypes) + { + // If not good status + if ($active >= 0 && $arraytypes['active'] != $active) continue; - // We discard empty line if showempty is on because an empty line has already been output. - if ($empty && empty($arraytypes['code'])) continue; + // We discard empty line if showempty is on because an empty line has already been output. + if ($empty && empty($arraytypes['code'])) continue; - if ($format == 0) print ''; - } - print ''; - if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } + if ($format == 0) print ''; + } + print ''; + if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } /** * Return a HTML select list of shipping mode @@ -3696,6 +3714,8 @@ class Form } print ""; if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + + print ajax_combobox('select'.$htmlname); } else { print $langs->trans("NoShippingMethodDefined"); } @@ -3881,7 +3901,7 @@ class Form while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($selected == $obj->rowid) + if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) { print ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $out .= ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $out .= ''; - } else { - $menuarray[$prefix.'_'.$file] = ''; - } - } - } - closedir($handle); - } - } - } - } + if ($file == $selected) + { + $menuarray[$prefix.'_'.$file] = ''; + } else { + $menuarray[$prefix.'_'.$file] = ''; + } + } + } + closedir($handle); + } + } + } + } ksort($menuarray); // Output combo list of menus - print ''; + $oldprefix = ''; foreach ($menuarray as $key => $val) { $tab = explode('_', $key); @@ -208,7 +208,7 @@ class FormAdmin // Affiche titre print ''; @@ -217,69 +217,69 @@ class FormAdmin print $val."\n"; // Show menu entry } print ''; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return combo list of available menu families - * - * @param string $selected Menu pre-selected - * @param string $htmlname Name of html select - * @param string[] $dirmenuarray Directories to scan - * @return void - */ - public function select_menu_families($selected, $htmlname, $dirmenuarray) - { - // phpcs:enable - global $langs, $conf; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return combo list of available menu families + * + * @param string $selected Menu pre-selected + * @param string $htmlname Name of html select + * @param string[] $dirmenuarray Directories to scan + * @return void + */ + public function select_menu_families($selected, $htmlname, $dirmenuarray) + { + // phpcs:enable + global $langs, $conf; - //$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php'); // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set - $expdevmenu = array(); + //$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php'); // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set + $expdevmenu = array(); $menuarray = array(); foreach ($dirmenuarray as $dirmenu) { - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot.$dirmenu; - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - $filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file); - if (preg_match('/^index/i', $filelib)) continue; - if (preg_match('/^default/i', $filelib)) continue; - if (preg_match('/^empty/i', $filelib)) continue; - if (preg_match('/\.lib/i', $filelib)) continue; - if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) continue; + foreach ($conf->file->dol_document_root as $dirroot) + { + $dir = $dirroot.$dirmenu; + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + $filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file); + if (preg_match('/^index/i', $filelib)) continue; + if (preg_match('/^default/i', $filelib)) continue; + if (preg_match('/^empty/i', $filelib)) continue; + if (preg_match('/\.lib/i', $filelib)) continue; + if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) continue; - $menuarray[$filelib] = 1; - } - $menuarray['all'] = 1; - } - closedir($handle); - } - } - } + $menuarray[$filelib] = 1; + } + $menuarray['all'] = 1; + } + closedir($handle); + } + } + } } ksort($menuarray); // Affichage liste deroulante des menus - print ''; + $oldprefix = ''; foreach ($menuarray as $key => $val) { $tab = explode('_', $key); $newprefix = $tab[0]; print ''; - $arraytz = array( + $arraytz = array( "Pacific/Midway"=>"GMT-11:00", "Pacific/Fakaofo"=>"GMT-10:00", "America/Anchorage"=>"GMT-09:00", @@ -335,17 +335,17 @@ class FormAdmin "Pacific/Auckland"=>"GMT+12:00", "Pacific/Enderbury"=>"GMT+13:00" ); - foreach ($arraytz as $lib => $gmt) { - print ''."\n"; - } - print ''; - } + foreach ($arraytz as $lib => $gmt) { + print ''."\n"; + } + print ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return html select list with available languages (key='en_US', value='United States' for example) * @@ -365,23 +365,23 @@ class FormAdmin $sql = "SELECT code, label, width, height, unit"; $sql .= " FROM ".MAIN_DB_PREFIX."c_paper_format"; $sql .= " WHERE active=1"; - if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'"; + if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'"; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $unitKey = $langs->trans('SizeUnit'.$obj->unit); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $unitKey = $langs->trans('SizeUnit'.$obj->unit); - $paperformat[$obj->code] = $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey); + $paperformat[$obj->code] = $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey); - $i++; - } - } else { + $i++; + } + } else { dol_print_error($this->db); return ''; } @@ -396,7 +396,7 @@ class FormAdmin } foreach ($paperformat as $key => $value) { - if ($selected == $key) + if ($selected == $key) { $out .= ''; } else { diff --git a/htdocs/core/class/html.formbank.class.php b/htdocs/core/class/html.formbank.class.php index a359bd194f7..9d50a0bb60b 100644 --- a/htdocs/core/class/html.formbank.class.php +++ b/htdocs/core/class/html.formbank.class.php @@ -31,40 +31,40 @@ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; */ class FormBank { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Retourne la liste des types de comptes financiers - * - * @param integer $selected Type pre-selectionne - * @param string $htmlname Nom champ formulaire - * @return void - */ - public function selectTypeOfBankAccount($selected = Account::TYPE_CURRENT, $htmlname = 'type') - { - $account = new Account($this->db); + /** + * Retourne la liste des types de comptes financiers + * + * @param integer $selected Type pre-selectionne + * @param string $htmlname Nom champ formulaire + * @return void + */ + public function selectTypeOfBankAccount($selected = Account::TYPE_CURRENT, $htmlname = 'type') + { + $account = new Account($this->db); - print Form::selectarray($htmlname, $account->type_lib, $selected); - } + print Form::selectarray($htmlname, $account->type_lib, $selected); + } /** * Returns the name of the Iban label. India uses 'IFSC' and the rest of the world 'IBAN' name. diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index 104daf6de0e..52d4c795c85 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -29,198 +29,198 @@ */ class FormBarCode { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Return HTML select with list of bar code generators - * - * @param int $selected Id code pre-selected - * @param array $barcodelist Array of barcodes generators - * @param int $code_id Id du code barre - * @param int $idForm Id du formulaire - * @return string HTML select string - */ - public function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm = 'formbarcode') - { - global $conf, $langs; + /** + * Return HTML select with list of bar code generators + * + * @param int $selected Id code pre-selected + * @param array $barcodelist Array of barcodes generators + * @param int $code_id Id du code barre + * @param int $idForm Id du formulaire + * @return string HTML select string + */ + public function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm = 'formbarcode') + { + global $conf, $langs; - $disable = ''; + $disable = ''; - if (!empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - //onChange="barcode_coder_save(\''.$idForm.'\') - } + print ''."\n"; + //onChange="barcode_coder_save(\''.$idForm.'\') + } - // We check if barcode is already selected by default - if (((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE == $code_id) || - (!empty($conf->societe->enabled) && $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY == $code_id)) - { - $disable = 'disabled'; - } + // We check if barcode is already selected by default + if (((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE == $code_id) || + (!empty($conf->societe->enabled) && $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY == $code_id)) + { + $disable = 'disabled'; + } - if (!empty($conf->use_javascript_ajax)) - { - $select_encoder = '
    '; - $select_encoder .= ''; - $select_encoder .= ''; - $select_encoder .= ''; - } + if (!empty($conf->use_javascript_ajax)) + { + $select_encoder = ''; + $select_encoder .= ''; + $select_encoder .= ''; + $select_encoder .= ''; + } - $selectname = (!empty($conf->use_javascript_ajax) ? 'coder' : 'coder'.$code_id); - $select_encoder .= ''; + $selectname = (!empty($conf->use_javascript_ajax) ? 'coder' : 'coder'.$code_id); + $select_encoder .= ''; - if (!empty($conf->use_javascript_ajax)) - { - $select_encoder .= '
    '; - } + if (!empty($conf->use_javascript_ajax)) + { + $select_encoder .= ''; + } - return $select_encoder; - } + return $select_encoder; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Print form to select type of barcode - * - * @param int $selected Id code pre-selected - * @param string $htmlname Name of HTML select field - * @param int $useempty Affiche valeur vide dans liste - * @return void - * @deprecated - */ - public function select_barcode_type($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) - { - // phpcs:enable - print $this->selectBarcodeType($selected, $htmlname, $useempty); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Print form to select type of barcode + * + * @param int $selected Id code pre-selected + * @param string $htmlname Name of HTML select field + * @param int $useempty Affiche valeur vide dans liste + * @return void + * @deprecated + */ + public function select_barcode_type($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) + { + // phpcs:enable + print $this->selectBarcodeType($selected, $htmlname, $useempty); + } - /** - * Return html form to select type of barcode - * - * @param int $selected Id code pre-selected - * @param string $htmlname Name of HTML select field - * @param int $useempty Display empty value in select - * @return string - */ - public function selectBarcodeType($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) - { - global $langs, $conf; + /** + * Return html form to select type of barcode + * + * @param int $selected Id code pre-selected + * @param string $htmlname Name of HTML select field + * @param int $useempty Display empty value in select + * @return string + */ + public function selectBarcodeType($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) + { + global $langs, $conf; - $out = ''; + $out = ''; - $sql = "SELECT rowid, code, libelle"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; - $sql .= " WHERE coder <> '0'"; - $sql .= " AND entity = ".$conf->entity; - $sql .= " ORDER BY code"; + $sql = "SELECT rowid, code, libelle"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; + $sql .= " WHERE coder <> '0'"; + $sql .= " AND entity = ".$conf->entity; + $sql .= " ORDER BY code"; - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; - if ($useempty && $num > 0) { - $out .= ''; - $out .= ''; - } + if ($useempty && $num > 0) { + $out .= ''; + $out .= ''; + } - while ($i < $num) { - $obj = $this->db->fetch_object($result); - if ($selected == $obj->rowid) { - $out .= ''; - $i++; - } - $out .= ""; - $out .= ajax_combobox("select_".$htmlname); - } else { - dol_print_error($this->db); - } - return $out; - } + while ($i < $num) { + $obj = $this->db->fetch_object($result); + if ($selected == $obj->rowid) { + $out .= ''; + $i++; + } + $out .= ""; + $out .= ajax_combobox("select_".$htmlname); + } else { + dol_print_error($this->db); + } + return $out; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Show form to select type of barcode - * - * @param string $page Page - * @param int $selected Id condition preselected - * @param string $htmlname Nom du formulaire select - * @return void - * @deprecated - */ - public function form_barcode_type($page, $selected = '', $htmlname = 'barcodetype_id') - { - // phpcs:enable - print $this->formBarcodeType($page, $selected, $htmlname); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show form to select type of barcode + * + * @param string $page Page + * @param int $selected Id condition preselected + * @param string $htmlname Nom du formulaire select + * @return void + * @deprecated + */ + public function form_barcode_type($page, $selected = '', $htmlname = 'barcodetype_id') + { + // phpcs:enable + print $this->formBarcodeType($page, $selected, $htmlname); + } - /** - * Return html form to select type of barcode - * - * @param string $page Page - * @param int $selected Id condition preselected - * @param string $htmlname Nom du formulaire select - * @return string - */ - public function formBarcodeType($page, $selected = '', $htmlname = 'barcodetype_id') - { - global $langs, $conf; - $out = ''; - if ($htmlname != "none") { - $out .= '
    '; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= '
    '; - $out .= $this->selectBarcodeType($selected, $htmlname, 1); - $out .= ''; - $out .= '
    '; - } - return $out; - } + /** + * Return html form to select type of barcode + * + * @param string $page Page + * @param int $selected Id condition preselected + * @param string $htmlname Nom du formulaire select + * @return string + */ + public function formBarcodeType($page, $selected = '', $htmlname = 'barcodetype_id') + { + global $langs, $conf; + $out = ''; + if ($htmlname != "none") { + $out .= '
    '; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
    '; + $out .= $this->selectBarcodeType($selected, $htmlname, 1); + $out .= ''; + $out .= '
    '; + } + return $out; + } } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index b43df3753dc..ee9e8564933 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -186,13 +186,13 @@ class FormCompany extends Form { global $user, $langs; - print '
    '; + print ''; print ''; - print ''; + print ''; dol_syslog(__METHOD__, LOG_DEBUG); $sql = "SELECT code, label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_prospectcontactlevel"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); @@ -220,8 +220,8 @@ class FormCompany extends Form print Form::selectarray($htmlname, $options, $selected); } else dol_print_error($this->db); - if (!empty($htmlname) && $user->admin) print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print ''; + if (!empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ''; print '
    '; } @@ -375,7 +375,7 @@ class FormCompany extends Form $resql = $this->db->query($sql); if ($resql) { - print ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -407,6 +407,7 @@ class FormCompany extends Form } } print ''; + print ajax_combobox($htmlname); } else { dol_print_error($this->db); } @@ -1003,6 +1004,7 @@ class FormCompany extends Form } } $out .= ''; + $out .= ajax_combobox($htmlidname); return $out; } diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index b2e32b8c063..7c91c1a4148 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -27,29 +27,29 @@ */ class FormContract { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a combo list with contracts qualified for a third party * @@ -61,9 +61,9 @@ class FormContract * @param int $showRef Show customer and supplier reference on each contract (when found) * @return int Nbr of project if OK, <0 if KO */ - public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) - { - // phpcs:enable + public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) + { + // phpcs:enable global $db, $user, $conf, $langs; $hideunselectables = false; @@ -78,12 +78,12 @@ class FormContract if ($socid > 0) { // CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. - if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { - $sql .= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; + if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { + $sql .= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; } elseif ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { - $sql .= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; + $sql .= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; $sql .= " OR c.fk_soc IS NULL)"; - } + } } if ($socid == 0) $sql .= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; $sql .= " ORDER BY c.ref "; @@ -164,30 +164,30 @@ class FormContract dol_print_error($this->db); return -1; } - } + } - /** - * Show a form to select a contract - * - * @param int $page Page - * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) - * @param int $selected Id contract preselected - * @param string $htmlname Nom de la zone html - * @param int $maxlength Maximum length of label - * @param int $showempty Show empty line - * @param int $showRef Show customer and supplier reference on each contract (when found) - * @return int Nbr of project if OK, <0 if KO - */ - public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) - { - global $langs; + /** + * Show a form to select a contract + * + * @param int $page Page + * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) + * @param int $selected Id contract preselected + * @param string $htmlname Nom de la zone html + * @param int $maxlength Maximum length of label + * @param int $showempty Show empty line + * @param int $showRef Show customer and supplier reference on each contract (when found) + * @return int Nbr of project if OK, <0 if KO + */ + public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) + { + global $langs; - print "\n"; - print '
    '; - print ''; - print ''; - $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); - print ''; - print '
    '; - } + print "\n"; + print '
    '; + print ''; + print ''; + $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); + print ''; + print '
    '; + } } diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 2701d126331..b6a9140cf58 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -28,75 +28,75 @@ */ class FormCron extends Form { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display On Off selector - * - * @param string $htmlname Html control name - * @param integer $selected selected value - * @param integer $readonly Select is read only or not - * @return string HTML select field - */ - public function select_typejob($htmlname, $selected = 0, $readonly = 0) - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Display On Off selector + * + * @param string $htmlname Html control name + * @param integer $selected selected value + * @param integer $readonly Select is read only or not + * @return string HTML select field + */ + public function select_typejob($htmlname, $selected = 0, $readonly = 0) + { + // phpcs:enable + global $langs; - $langs->load('cron@cron'); - $out = ''; - if (!empty($readonly)) { - if ($selected == 'command') { - $out = $langs->trans('CronType_command'); - $out .= ''; - } elseif ($selected == 'method') { - $out = $langs->trans('CronType_method'); - $out .= ''; - } - } else { - $out = ''; + $out .= ''; + $out .= ''; + } elseif ($selected == 'method') { + $out = $langs->trans('CronType_method'); + $out .= ''; + } + } else { + $out = ''; - } + $out .= ''; + } - return $out; - } + return $out; + } } diff --git a/htdocs/core/class/html.formexpensereport.class.php b/htdocs/core/class/html.formexpensereport.class.php index e8079b77ed6..d65f68423b2 100644 --- a/htdocs/core/class/html.formexpensereport.class.php +++ b/htdocs/core/class/html.formexpensereport.class.php @@ -27,110 +27,111 @@ */ class FormExpenseReport { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Retourne la liste deroulante des differents etats d'une note de frais. - * Les valeurs de la liste sont les id de la table c_expensereport_statuts - * - * @param int $selected preselect status - * @param string $htmlname Name of HTML select - * @param int $useempty 1=Add empty line - * @param int $useshortlabel Use short labels - * @return string HTML select with status - */ - public function selectExpensereportStatus($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0) - { - global $langs; + /** + * Retourne la liste deroulante des differents etats d'une note de frais. + * Les valeurs de la liste sont les id de la table c_expensereport_statuts + * + * @param int $selected preselect status + * @param string $htmlname Name of HTML select + * @param int $useempty 1=Add empty line + * @param int $useshortlabel Use short labels + * @return string HTML select with status + */ + public function selectExpensereportStatus($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0) + { + global $langs; - $tmpep = new ExpenseReport($this->db); + $tmpep = new ExpenseReport($this->db); - print ''; - } + print ''; + print ajax_combobox($htmlname); + } - /** - * Return list of types of notes with select value = id - * - * @param int $selected Preselected type - * @param string $htmlname Name of field in form - * @param int $showempty Add an empty field - * @param int $active 1=Active only, 0=Unactive only, -1=All - * @return string Select html - */ - public function selectTypeExpenseReport($selected = '', $htmlname = 'type', $showempty = 0, $active = 1) - { - // phpcs:enable - global $langs, $user; - $langs->load("trips"); + /** + * Return list of types of notes with select value = id + * + * @param int $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $showempty Add an empty field + * @param int $active 1=Active only, 0=Unactive only, -1=All + * @return string Select html + */ + public function selectTypeExpenseReport($selected = '', $htmlname = 'type', $showempty = 0, $active = 1) + { + // phpcs:enable + global $langs, $user; + $langs->load("trips"); - $out = ''; + $out = ''; - $out .= ''; - $out .= ajax_combobox($htmlname); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $out .= '