diff --git a/.travis.yml b/.travis.yml index 6cb27e2307f..5551c6d1605 100644 --- a/.travis.yml +++ b/.travis.yml @@ -107,9 +107,9 @@ install: - | echo "Update Composer version and Install tools - PHP Unit, Parallel Lint, PHP CodeSniffer, PHP Vardump check - for $TRAVIS_PHP_VERSION" echo "(version 2.5 is bugged and generate phpunit error Exception: Serialization of 'Closure' is not allowed)" - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then composer self-update 2.2.18 - composer -n require phpunit/phpunit ^6 \ + composer -n require phpunit/phpunit ^7.5 \ php-parallel-lint/php-parallel-lint ^1 \ php-parallel-lint/php-console-highlighter ^0 \ php-parallel-lint/php-var-dump-check ~0.4 \ @@ -117,7 +117,7 @@ install: fi if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then composer self-update 2.2.18 - composer -n require phpunit/phpunit ^7 \ + composer -n require phpunit/phpunit ^7.5 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ php-parallel-lint/php-var-dump-check ~0.4 \ diff --git a/ChangeLog b/ChangeLog index c9aef18d710..6cd8025ebe9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,15 +9,16 @@ For uses: --------- NEW: PHP 8.2 compatibility (test not yet completed). -NEW: #22740 Add OpenID Connect impl NEW: #23436 Group social networks fields NEW: Accountancy - Add specific page to export accounting data rather than the journals page NEW: Accountancy - Add sub-account balance FPC22 NEW: Accountancy - Manage customer retained warranty FPC21+ NEW: Accountancy - Manage intra-community VAT on supplier invoices - FPC22 NEW: Can upload a file with drag and drop on purchase invoice, vats, salaries and social contributions -NEW: adapt category and product pictures sizes on takepos -NEW: Add ability of ODT support to supplier invoices +NEW: authentication mode: #22740 Add OpenID Connect impl +NEW: authentication mode: Add experimental support for Google OAuth2 connexion +NEW: adapt category and product pictures sizes on TakePOS +NEW: Supplier Invoices: add ability of ODT support to supplier invoices NEW: Add a public virtual card page for each user NEW: Add a status on supplier price ref (WIP to close a supplier ref) NEW: Add a trigger when create a shipping line batch and fix propagate missing errors @@ -31,7 +32,7 @@ NEW: Add Customer Order delivered (ORDER_NEW) in module Notification NEW: add customize CSS in admin/ihm settings NEW: Add date due and labels into customer comm card NEW: Add dropdown button actions (example on Create button on project) -NEW: added an option to display the progress of tickets on the public interface +NEW: Tickets: added an option to display the progress of tickets on the public interface NEW: Add field reply-to in email collector as possible filter NEW: Add filter on nb of generation done in list of recurring invoices NEW: Add filters and sort on product unit column @@ -41,7 +42,7 @@ NEW: add link to thirdparty tickets history NEW: add margin in paiement/card.php NEW: Add mass action delete on VAT NEW: Add more zip, town, country for owner of a bank account -NEW: add numbering modules for members +NEW: Members: add numbering modules for members NEW: add option keepspace into dol_string_nospecialchar() NEW: Add origin info when create a product batch when created from a movement stock NEW: Add possibility to choose format #21426 @@ -61,15 +62,15 @@ NEW: Can add any contact on events if global MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT NEW: Can add the add now link on date into addfieldvalue() NEW: Can bin accounting line for a given month NEW: Can edit account on miscellaneous payment (if not transfered) -NEW: Can edit inline the vat number from supplier tab +NEW: Can edit inline the VAT number from supplier tab NEW: Can fill date of salary payment with date of start of salary NEW: Can filter on a custom group of accounts. Perf or ledger list. NEW: Can go back to draft on shipment when stock change not on validate NEW: Can modify bank account of sepa payment (if file not sent yet) -NEW: Can modify margin rates in offers like VAT rates. -NEW: Can modify the date of payment of a salary (if not reconciled) -NEW: Can now edit service name for oauth token -NEW: Can receive more than qty ordered on reception +NEW: Proposals: Can modify margin rates in offers like VAT rates. +NEW: Salary: Can modify the date of payment of a salary (if not reconciled) +NEW: OAuth: Can now edit service name for oauth token +NEW: Reception: Can receive more than qty ordered on reception NEW: Can select several warehouses into the view stock at date in past NEW: Can select the export format during export of journals NEW: Can set a checkbox in formconfirm by clicking on the label @@ -78,8 +79,8 @@ NEW: Can set flag default value on email templates NEW: Can set the page "List of opportunities" as landing page NEW: Can show the sql request used on emailing selection NEW: can stay on edit field when errors occurs -NEW: Can test a geoip conversion from the geoip setup page -NEW: Captcha for public member's subscription form +NEW: GeoIP: Can test a geoip conversion from the geoip setup page +NEW: Members: Captcha for public member's subscription form NEW: category of operation for crabe PDF model NEW: color for start date and owner NEW: comment in api_mymodule for seperate methods @@ -92,24 +93,24 @@ NEW: Disable bad reputation product price NEW: dolExplodeIntoArray can accept regex NEW: dol_sort_array can sort on alphabetical order even if val is num NEW: don't have closed contact proposed as receiver for the mails -NEW: Dynamic choice of warehouse and batch in MO production. +NEW: MO: Dynamic choice of warehouse and batch in MO production. NEW: element time integration code + sql NEW: events list with color NEW: expend/collapse list of social networks -NEW: filter for Signed+Billed in proposals +NEW: Proposals: filter for Signed+Billed in proposals NEW: Filter on amount and qty on list of service's contracts -NEW: filter on entity in import +NEW: Import: filter on entity in import NEW: formconfirm can support field with format datetime NEW: getCommonSubstitutionArray to have more substitute keys NEW: helper functions for dates + small demo case NEW: hook printFieldListFrom in contact list NEW: inc.php: handle parameters from argv -NEW: Increment website counter on each page access in website module +NEW: Website Module: Increment website counter on each page access in website module NEW: Invalidate all sessions of a user when password is modified. -NEW: Invoice - Show Category of operations +NEW: Invoice - show category of operations NEW: iSuiteExpert export model NEW: Keep a link between user created from recruitment and application -NEW: limit load products in takepos +NEW: limit load products in TakePOS NEW: List product in orders NEW: Make it possible to select hours and minutes in form_confirm NEW: map table to element for get entity in import @@ -134,7 +135,7 @@ NEW: Possibility to link to German pages in help NEW: presend mass action in contact list NEW: product images on popup are cached NEW: Provide the oldcopy value when calling setValueFrom() function with a trigger key -NEW: Quadratus export with attachments in accountancy export +NEW: Accountancy: Quadratus export with attachments in accountancy export NEW: referential objects of batch NEW: remove default percentage for event creation url NEW: remove keys whose table element is the same as element in map list @@ -145,8 +146,8 @@ NEW: Send an email when ticket assigned NEW: Send a notification email when ticket assigned NEW: sepaStripe now creates the payment mode with type pm_ using new API NEW: set payment default values when supplier order created from reception -NEW: set ticket status to answered if the client has answered from the public interface -NEW: set today start time at begining +NEW: Tickets: set ticket status to answered if the client has answered from the public interface +NEW: set today start time at beginning NEW: Setup emailcollector easier. Can also use ! for negative search. NEW: Show counter of access of website in website list NEW: Show main currency in company info user tooltip @@ -171,23 +172,29 @@ NEW: use more recent model by default NEW: VAT can be modified during add of line NEW: write all fields and their properties in asciidoc format NEW: Can add an array of several links in date selector -NEW: Implement MAIN_ACTIVATE_FILECACHE on bithday widget -NEW: Add widget "The next upcoming events" -NEW: Add widget of open opportunities +NEW: Add option PDF_SHOW_PHONE_AFTER_USER_CONTACT to show phone after specific assigned contact on PDF +NEW: Add option PDF_SHOW_EMAIL_AFTER_USER_CONTACT to show email after specific assigned contact on PDF +NEW: Widgets: Implement MAIN_ACTIVATE_FILECACHE on birthday widget +NEW: Widgets: Add widget "The next upcoming events" +NEW: Widgets: Add widget of open opportunities +NEW: Use an ajax component to swith prospection status on thidparty list +NEW: Comment on survey is possible only after vote. +NEW: Add partial payment reason "withholding tax" For developers or integrators: ------------------------------ -NEW: triggers on mailing +NEW: add triggers on mailing NEW: add function for listiong objects from directory -NEW: Add helplist property to describe fields of obects -NEW: Add hook in loadLotStock() in html.formproduct.class.php file, add hook 'llxFooter', Add hook online sign -NEW: Update lib parsedownto 1.7.4, phpspreadsheet lib to v1.12, ESCPOS v3.0 +NEW: add helplist property to describe fields of objects +NEW: add hook in loadLotStock() in html.formproduct.class.php file, add hook 'llxFooter', Add hook online sign +NEW: Update lib parsedownto 1.7.4, phpspreadsheet lib to v1.12, ESCPOS v3.0, jquery, Stripe. NEW: Support contact in post() document API -NEW: updating in modulbuilder on tab Menu when adding object -NEW: Add/Edit permissions in ModuleBuilder -NEW: Better generated documentation for modulebuilder -NEW: Add sent info in the parameters provided to the hook sendMailAfter +NEW: More APIs (update currency rate, upload of supplier documents, ...) +NEW: ModuleBuilder: updating in modulbuilder on tab Menu when adding object +NEW: ModuleBuilder: add/edit permissions +NEW: ModuleBuilder: better generated documentation +NEW: add sent info in the parameters provided to the hook sendMailAfter NEW: add setAsSelectUser into factory for generic setup page diff --git a/build/docker/README.md b/build/docker/README.md index 007b5db6ace..fbf9b05851c 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -1,7 +1,7 @@ # How to use it ? -The docker-compose.yml file is used to build and run Dolibarr in the current workspace. -This docker image intended for developpement usage. +The docker-compose.yml file is a sample of a config file to use to build and run Dolibarr in the current workspace with Docker. +This docker image is intended for developpement usage. For production usage you should consider other contributor reference like https://hub.docker.com/r/tuxgasy/dolibarr Before build/run, define the variable HOST_USER_ID as following: diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index e197d5dd06e..ddcdc58560a 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -10,7 +10,7 @@ services: mariadb: image: mariadb:latest environment: - MYSQL_ROOT_PASSWORD: root + MYSQL_ROOT_PASSWORD: rootpassfordev MYSQL_DATABASE: dolibarr ports: - "3306:3306" diff --git a/composer.json.disabled b/composer.json.disabled index adeaffd2334..a38347122cd 100644 --- a/composer.json.disabled +++ b/composer.json.disabled @@ -24,17 +24,16 @@ "vendor-dir" : "htdocs/includes" }, "require" : { - "php" : ">=5.6.0", - "ext-curl" : "*", + "php" : ">=7.1.0", "ckeditor/ckeditor" : "4.12.1", - "mike42/escpos-php" : "2.2", - "mobiledetect/mobiledetectlib" : "2.8.39", - "phpoffice/phpexcel" : "1.8.2", + "mike42/escpos-php" : "3.0", + "mobiledetect/mobiledetectlib" : "2.8.41", + "phpoffice/phpspreadsheet" : "1.12", "restler/framework" : "3.0.0-RC6", "tecnickcom/tcpdf" : "6.3.2", - "nnnick/chartjs" : "^2.9", - "stripe/stripe-php" : "6.43.1", - "maximebf/debugbar" : "1.15.1", + "nnnick/chartjs" : "^3.7.1", + "stripe/stripe-php" : "10.7.0", + "maximebf/debugbar" : "1.18.2", "symfony/var-dumper" : "3.2" }, "require-dev" : { @@ -43,13 +42,12 @@ "phpunit/phpunit" : "^4", "squizlabs/php_codesniffer" : "^2", "phpunit/phpunit-selenium" : "^2" + "rector/rector" : "^0.16.0" }, "suggest" : { "ext-mysqlnd" : "To use with MySQL or MariaDB", "ext-mysqli" : "To use with MySQL or MariaDB", "ext-pgsql" : "To use with PostgreSQL", - "ext-mssql" : "To use with MSSQL (experimental)", - "ext-pdo_sqlite" : "To use with SQLite (experimental)", "ext-gd" : "Image manipulation (Required but maybe built-in PHP)", "ext-imagick" : "Generation of thumbs from PDF", "ext-mcrypt" : "(Required but maybe built-in PHP)", diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 272c067807d..67eee9022b5 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -692,6 +692,9 @@ class Lettering extends BookKeeping // Clean parameters $document_ids = is_array($document_ids) ? $document_ids : array(); + //remove empty entries + $document_ids = array_filter($document_ids); + $doc_type = trim($doc_type); if (empty($document_ids)) { @@ -742,10 +745,13 @@ class Lettering extends BookKeeping // Clean parameters $document_ids = is_array($document_ids) ? $document_ids : array(); $doc_type = trim($doc_type); + //remove empty entries + $document_ids = array_filter($document_ids); if (empty($document_ids)) { return array(); } + if (!is_array(self::$doc_type_infos[$doc_type])) { $langs->load('errors'); $this->errors[] = $langs->trans('ErrorBadParameters'); diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 76f25557662..94d2ca576bc 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -5,6 +5,7 @@ * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2022 Open-DSI + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2017-2023 Frédéric France @@ -805,12 +806,6 @@ if (!$error && $action == 'writebookkeeping') { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); - - if ($nb_lettering < 0) { - $error++; - $errorforline++; - setEventMessages($lettering_static->error, $lettering_static->errors, 'errors'); - } } } } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 319328cdc6e..5e30325d2c7 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -437,13 +437,8 @@ if ($action == 'writebookkeeping') { if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); - $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); - if ($nb_lettering < 0) { - $error++; - $errorforline++; - setEventMessages($lettering_static->error, $lettering_static->errors, 'errors'); - } + $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); } } } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 96555b960c0..e8178ad63d3 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -4,7 +4,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2014 Raphaël Doursenaud @@ -465,13 +465,6 @@ if ($action == 'writebookkeeping') { $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); - - if ($nb_lettering < 0) { - $error++; - $errorforline++; - $errorforinvoice[$key] = 'other'; - setEventMessages($lettering_static->error, $lettering_static->errors, 'errors'); - } } } } diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 767f95cb252..ca375d1c4cc 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -55,10 +55,10 @@ if (($accountancyexport->getFormatCode($formatexportset) == 'fec' || $accountanc $tmparray = dol_getdate($datetouseforfilename); $fiscalmonth = empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START; // Define end of month to use - if ($tmparray['mon'] <= $fiscalmonth) { - $tmparray['mon'] = $fiscalmonth; + if ($tmparray['mon'] < $fiscalmonth || $fiscalmonth == 1) { + $tmparray['mon'] = $fiscalmonth == 1 ? 12 : $fiscalmonth - 1; } else { - $tmparray['mon'] = $fiscalmonth; + $tmparray['mon'] = $fiscalmonth - 1; $tmparray['year']++; } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 3dcc0c7bf48..f70a23dabab 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2510,8 +2510,8 @@ class Adherent extends CommonObject $labelStatusShort = $langs->trans("MemberStatusNoSubscriptionShort"); } elseif (!$date_end_subscription) { $statusType = 'status1'; - $labelStatus = $langs->trans("MemberStatusActive"); - $labelStatusShort = $langs->trans("MemberStatusActiveShort"); + $labelStatus = $langs->trans("WaitingSubscription"); + $labelStatusShort = $langs->trans("WaitingSubscriptionShort"); } elseif ($date_end_subscription < dol_now()) { // expired $statusType = 'status8'; $labelStatus = $langs->trans("MemberStatusActiveLate"); diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index ed2fa05cf51..5124e1ba612 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (c) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2023 Waël Almoman * * 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 @@ -172,15 +173,87 @@ class AdherentStats extends Stats return $this->_getAllByYear($sql); } + /** + * Return count of member by status group by adh type, total and average + * + * @param int $numberYears Number of years to scan (0 = all) + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type + */ + public function countMembersByTypeAndStatus($numberYears = 0) + { + global $user; + $now = dol_now(); + $endYear = date('Y'); + $startYear = $endYear - $numberYears; + + $sql = "SELECT t.rowid as fk_adherent_type, t.libelle as label"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')", "'members_pending'", 'NULL').") as members_pending"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)", "'members_uptodate'", 'NULL').") as members_uptodate"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)", "'members_expired'", 'NULL').") as members_expired"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED, "'members_excluded'", 'NULL').") as members_excluded"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED, "'members_resiliated'", 'NULL').") as members_resiliated"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d ON t.rowid = d.fk_adherent_type AND d.entity IN (" . getEntity('adherent') . ")"; + if ($numberYears) { + $sql .= " AND d.datefin > '".$this->db->idate(dol_get_first_day($startYear))."'"; + } + $sql .= " WHERE t.entity IN (".getEntity('member_type').")"; + $sql .= " AND t.statut = 1"; + $sql .= " GROUP BY t.rowid"; + + dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + $MembersCountArray = []; + $totalstatus = array( + 'label' => 'Total', + 'members_draft' => 0, + 'members_pending' => 0, + 'members_uptodate' => 0, + 'members_expired' => 0, + 'members_excluded' => 0, + 'members_resiliated' => 0 + ); + while ($i < $num) { + $objp = $this->db->fetch_object($result); + $MembersCountArray[$objp->fk_adherent_type] = array( + 'label' => $objp->label, + 'members_draft' => (int) $objp->members_draft, + 'members_pending' => (int) $objp->members_pending, + 'members_uptodate' => (int) $objp->members_uptodate, + 'members_expired' => (int) $objp->members_expired, + 'members_excluded' => (int) $objp->members_excluded, + 'members_resiliated' => (int) $objp->members_resiliated + ); + $totalrow = 0; + foreach ($MembersCountArray[$objp->fk_adherent_type] as $key=>$nb) { + if ($key!='label') { + $totalrow += $nb; + $totalstatus[$key] += $nb; + } + } + $MembersCountArray[$objp->fk_adherent_type]['total_adhtype'] = $totalrow; + $i++; + } + $this->db->free($result); + $MembersCountArray['total'] = $totalstatus; + $MembersCountArray['total']['all'] = array_sum($totalstatus); + } + return $MembersCountArray; + } /** * Return count of member by status group by adh type, total and average * - * @param int $numberYears Years to scan - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag + * @param int $numberYears Number of years to scan (0 = all) + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag */ - public function countMembersByTagAndStatus($numberYears = 2) + public function countMembersByTagAndStatus($numberYears = 0) { global $user; @@ -202,9 +275,11 @@ class AdherentStats extends Stats $sql .= " WHERE c.entity IN (".getEntity('member_type').")"; $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; $sql .= " AND t.entity IN (" . getEntity('adherent') . ")"; - $sql .= " AND d.datefin > '".$this->db->idate(dol_get_first_day($startYear))."'"; + if ($numberYears) { + $sql .= " AND d.datefin > '".$this->db->idate(dol_get_first_day($startYear))."'"; + } $sql .= " AND c.fk_parent = 0"; - $sql .= " GROUP BY c.rowid"; + $sql .= " GROUP BY c.rowid ORDER BY label ASC"; dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); $result = $this->db->query($sql); @@ -240,7 +315,7 @@ class AdherentStats extends Stats $totalstatus[$key] += $nb; } } - $MembersCountArray[$objp->fk_categorie]['total_adhtype'] = $totalrow; + $MembersCountArray[$objp->fk_categorie]['total_adhtag'] = $totalrow; $i++; } $this->db->free($result); diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index fd031421c8b..3d737cd1763 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -4,8 +4,8 @@ * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI - * Copyright (C) 2021 Frédéric France - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021-2023 Frédéric France + * Copyright (C) 2021-2023 Waël Almoman * * 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 @@ -27,7 +27,6 @@ * \brief Home page of membership module */ - // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -54,11 +53,11 @@ $result = restrictedArea($user, 'adherent'); * Actions */ +$userid = GETPOST('userid', 'int'); if (GETPOST('addbox')) { // Add box (when submit is done from a form when ajax disabled) require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; $zone = GETPOST('areacode', 'int'); - $userid = GETPOST('userid', 'int'); $boxorder = GETPOST('boxorder', 'aZ09'); $boxorder .= GETPOST('boxcombo', 'aZ09'); $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); @@ -85,173 +84,34 @@ $subscriptionstatic = new Subscription($db); print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist'], 'members'); -$MembersValidated = array(); -$MembersToValidate = array(); -$MembersWaitingSubscription = array(); -$MembersUpToDate = array(); -$MembersExpired = array(); -$MembersExcluded = array(); -$MembersResiliated = array(); - -$AdherentType = array(); - -// Type of membership -$sql = "SELECT t.rowid, t.libelle as label, t.subscription,"; -$sql .= " d.statut, count(d.rowid) as somme"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; -$sql .= " ON t.rowid = d.fk_adherent_type"; -$sql .= " AND d.entity IN (".getEntity('adherent').")"; -$sql .= " WHERE t.entity IN (".getEntity('member_type').")"; -$sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; - -dol_syslog("index.php::select nb of members per type", LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($resql); - - $adhtype = new AdherentType($db); - $adhtype->id = $objp->rowid; - $adhtype->subscription = $objp->subscription; - $adhtype->label = $objp->label; - $AdherentType[$objp->rowid] = $adhtype; - - if ($objp->statut == -1) { - $MembersToValidate[$objp->rowid] = $objp->somme; - } - if ($objp->statut == 1) { - $MembersValidated[$objp->rowid] = $objp->somme; - } - if ($objp->statut == -2) { - $MembersExcluded[$objp->rowid] = $objp->somme; - } - if ($objp->statut == 0) { - $MembersResiliated[$objp->rowid] = $objp->somme; - } - - $i++; - } - $db->free($resql); -} - -$now = dol_now(); - -// Members waiting subscription -$sql = "SELECT count(*) as somme , d.fk_adherent_type"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; -$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut = 1"; // validated -$sql .= " AND (d.datefin IS NULL AND t.subscription = '1')"; -$sql .= " AND t.rowid = d.fk_adherent_type"; -$sql .= " GROUP BY d.fk_adherent_type"; - -dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($resql); - $MembersWaitingSubscription[$objp->fk_adherent_type] = $objp->somme; - $i++; - } - $db->free($resql); -} - -// Members up to date list -// current rule: uptodate = the end date is in future or no subcription required -// old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) -$sql = "SELECT count(*) as somme , d.fk_adherent_type"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; -$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut = 1"; // validated -$sql .= " AND (d.datefin >= '".$db->idate($now)."' OR t.subscription = '0')"; // end date in future -$sql .= " AND t.rowid = d.fk_adherent_type"; -$sql .= " GROUP BY d.fk_adherent_type"; - -dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($resql); - $MembersUpToDate[$objp->fk_adherent_type] = $objp->somme; - $i++; - } - $db->free($resql); -} - -// Members expired list -$sql = "SELECT count(*) as somme , d.fk_adherent_type"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; -$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut = 1"; // validated -$sql .= " AND (d.datefin < '".$db->idate($now)."' AND t.subscription = '1')"; -$sql .= " AND t.rowid = d.fk_adherent_type"; -$sql .= " GROUP BY d.fk_adherent_type"; - -dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($resql); - $MembersExpired[$objp->fk_adherent_type] = $objp->somme; - $i++; - } - $db->free($resql); -} - /* * Statistics */ $boxgraph = ''; if ($conf->use_javascript_ajax) { + $year = date('Y'); + $numberyears = getDolGlobalInt("MAIN_NB_OF_YEAR_IN_MEMBERSHIP_WIDGET_GRAPH"); + $boxgraph .='
'; $boxgraph .=''; - $boxgraph .=''; + $boxgraph .=''; $boxgraph .=''; $boxgraph .= ''; $boxgraph .= '
'.$langs->trans("Statistics").'
'.$langs->trans("Statistics").($numberyears ? ' ('.($year-$numberyears).' - '.$year.')' : '').'
'; - $SumToValidate = 0; - $SumWaitingSubscription = 0; - $SumUpToDate = 0; - $SumExpired = 0; - $SumResiliated = 0; - $SumExcluded = 0; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; + $stats = new AdherentStats($db, 0, $userid); - $total = 0; - $dataval = array(); - $i = 0; - foreach ($AdherentType as $key => $adhtype) { - $dataval['draft'][] = array($i, isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0); - $dataval['waitingsubscription'][] = array($i, isset($MembersWaitingSubscription[$key]) ? $MembersWaitingSubscription[$key] : 0); - $dataval['uptodate'][] = array($i, isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0); - $dataval['expired'][] = array($i, isset($MembersExpired[$key]) ? $MembersExpired[$key] : 0); - $dataval['excluded'][] = array($i, isset($MembersExcluded[$key]) ? $MembersExcluded[$key] : 0); - $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); + // Show array + $sumMembers = $stats->countMembersByTypeAndStatus($numberyears); + $total = $sumMembers['total']['members_draft'] + $sumMembers['total']['members_pending'] + $sumMembers['total']['members_uptodate'] + $sumMembers['total']['members_expired'] + $sumMembers['total']['members_excluded'] + $sumMembers['total']['members_resiliated']; - $SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0; - $SumWaitingSubscription += isset($MembersWaitingSubscription[$key]) ? $MembersWaitingSubscription[$key] : 0; - $SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0; - $SumExpired += isset($MembersExpired[$key]) ? $MembersExpired[$key] : 0; - $SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0; - $SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; - $i++; - } - $total = $SumToValidate + $SumWaitingSubscription + $SumUpToDate + $SumExpired + $SumExcluded + $SumResiliated; $dataseries = array(); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SumToValidate)); // Draft, not yet validated - $dataseries[] = array($langs->transnoentitiesnoconv("WaitingSubscription"), round($SumWaitingSubscription)); - $dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), round($SumUpToDate)); - $dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), round($SumExpired)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusExcluded"), round($SumExcluded)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SumResiliated)); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), $sumMembers['total']['members_draft']); // Draft, not yet validated + $dataseries[] = array($langs->transnoentitiesnoconv("WaitingSubscription"), $sumMembers['total']['members_pending']); + $dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), $sumMembers['total']['members_uptodate']); + $dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), $sumMembers['total']['members_expired']); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusExcluded"), $sumMembers['total']['members_excluded']); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), $sumMembers['total']['members_resiliated']); include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; @@ -268,7 +128,7 @@ if ($conf->use_javascript_ajax) { $boxgraph .= '
'.$langs->trans("Total").''; - $boxgraph .= $SumToValidate + $SumWaitingSubscription + $SumUpToDate + $SumExpired + $SumExcluded + $SumResiliated; + $boxgraph .= $total; $boxgraph .= '
'; $boxgraph .= '
'; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 8296fd5591d..1f553f387c8 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -584,6 +584,19 @@ if ($rowid > 0) { // Birth Date print ''.$langs->trans("DateOfBirth").''.dol_print_date($object->birth, 'day').''; + // Default language + if (getDolGlobalInt('MAIN_MULTILANGS')) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print ''.$langs->trans("DefaultLang").''; + //$s=picto_from_langcode($object->default_lang); + //print ($s?$s.' ':''); + $langs->load("languages"); + $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); + print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); + print $labellang; + print ''; + } + // Public print ''.$langs->trans("Public").''.yn($object->public).''; @@ -755,7 +768,7 @@ if ($rowid > 0) { print ''; print ''.dol_print_date($db->jdate($objp->dateh), 'day')."\n"; print ''.dol_print_date($db->jdate($objp->datef), 'day')."\n"; - print ''.price($objp->subscription).''; + print ''.price($objp->subscription).''; if (isModEnabled('banque')) { print ''; if ($objp->bid) { diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 833c0518d9a..9a2243f4fea 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -176,7 +176,7 @@ $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d. $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,"; +$sql .= " c.fk_bank as bank, c.note as note_private,"; $sql .= " b.fk_account"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -471,7 +471,7 @@ if (!empty($arrayfields['t.libelle']['checked'])) { if (!empty($arrayfields['d.bank']['checked'])) { print ''; - $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth150'); + $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth100'); print ''; } @@ -692,14 +692,14 @@ while ($i < $imaxinloop) { // Lastname if (!empty($arrayfields['d.lastname']['checked'])) { - print ''.$adherent->getNomUrl(-1, 0, 'card', 'lastname').''; + print ''.$adherent->getNomUrl(-1, 0, 'card', 'lastname').''; if (!$i) { $totalarray['nbfield']++; } } // Firstname if (!empty($arrayfields['d.firstname']['checked'])) { - print ''.$adherent->firstname.''; + print ''.dol_escape_htmltag($adherent->firstname).''; if (!$i) { $totalarray['nbfield']++; } @@ -707,7 +707,7 @@ while ($i < $imaxinloop) { // Login if (!empty($arrayfields['d.login']['checked'])) { - print ''.$adherent->login.''; + print ''.dol_escape_htmltag($adherent->login).''; if (!$i) { $totalarray['nbfield']++; } @@ -716,7 +716,7 @@ while ($i < $imaxinloop) { // Label if (!empty($arrayfields['t.libelle']['checked'])) { print ''; - print $obj->note; + print dol_escape_htmltag(dolGetFirstLineOfText($obj->note_private)); print ''; if (!$i) { $totalarray['nbfield']++; @@ -725,7 +725,7 @@ while ($i < $imaxinloop) { // Banque if (!empty($arrayfields['d.bank']['checked'])) { - print ''; + print ''; if ($obj->fk_account > 0) { $accountstatic->id = $obj->fk_account; $accountstatic->fetch($obj->fk_account); diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index 9094762f68d..a901b0790b5 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -165,7 +165,7 @@ if ($action == 'set') { if ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->DELIVERY_ADDON_PDF == "$value") { + if (getDolGlobalString('DELIVERY_ADDON_PDF') == $value) { dolibarr_del_const($db, 'DELIVERY_ADDON_PDF', $conf->entity); } } @@ -420,7 +420,7 @@ if (!empty($conf->global->MAIN_SUBMODULE_DELIVERY)) { // Default print ""; - if ($conf->global->DELIVERY_ADDON_PDF == "$name") { + if (getDolGlobalString('DELIVERY_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').''; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 210413b87f2..4cefb9630c5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1250,6 +1250,8 @@ if ($id > 0) { $sql .= natural_search("f.code", $search_code); } elseif ($search_code != '' && $id == 2) { $sql .= natural_search("d.code_departement", $search_code); + } elseif ($search_code != '' && $id == 14) { + $sql .= natural_search("e.code", $search_code); } elseif ($search_code != '' && $id != 9) { $sql .= natural_search("code", $search_code); } diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 63481f777b1..ee0ae57e0e2 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -121,6 +121,8 @@ class Documents extends DolibarrApi * * Test sample 1: { "modulepart": "invoice", "original_file": "FA1701-001/FA1701-001.pdf", "doctemplate": "crabe", "langcode": "fr_FR" }. * + * Supported modules: invoice, order, proposal, contract + * * @param string $modulepart Name of module or area concerned by file download ('thirdparty', 'member', 'proposal', 'supplier_proposal', 'order', 'supplier_order', 'invoice', 'supplier_invoice', 'shipment', 'project', ...) * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf). * @param string $doctemplate Set here the doc template to use for document generation (If not set, use the default template). @@ -198,6 +200,19 @@ class Documents extends DolibarrApi if ($result <= 0) { throw new RestException(500, 'Error generating document'); } + } elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier') { + require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; + $this->supplier_invoice = new FactureFournisseur($this->db); + $result = $this->supplier_invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); + if (!$result) { + throw new RestException(404, 'Supplier invoice not found'); + } + + $templateused = $doctemplate ? $doctemplate : $this->supplier_invoice->model_pdf; + $result = $this->supplier_invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) { + throw new RestException(500, 'Error generating document'); + } } elseif ($modulepart == 'commande' || $modulepart == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $this->order = new Commande($this->db); @@ -256,6 +271,8 @@ class Documents extends DolibarrApi /** * Return the list of documents of a dedicated element (from its ID or Ref) * + * Supported modules: thirdparty, user, member, proposal, order, supplier_order, shipment, invoice, supplier_invoice, product, event, expensereport, knowledgemanagement, category, contract + * * @param string $modulepart Name of module or area concerned ('thirdparty', 'member', 'proposal', 'order', 'invoice', 'supplier_invoice', 'shipment', 'project', ...) * @param int $id ID of element * @param string $ref Ref of element @@ -583,6 +600,8 @@ class Documents extends DolibarrApi * Test sample for supplier invoice: { "filename": "mynewfile.txt", "modulepart": "supplier_invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. * Test sample for medias file: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }. * + * Supported modules: invoice, order, supplier_order, task/project_task, product/service, expensereport, fichinter, member, propale, agenda, contact + * * @param string $filename Name of file to create ('FA1705-0123.txt') * @param string $modulepart Name of module or area concerned by file upload ('product', 'service', 'invoice', 'proposal', 'project', 'project_task', 'supplier_invoice', 'expensereport', 'member', ...) * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index ca9f3d97ce6..75edc096ac9 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -25,6 +25,7 @@ use Luracast\Restler\RestException; require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/cstate.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/cregion.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; @@ -236,6 +237,107 @@ class Setup extends DolibarrApi return $list; } + /** + * Get the list of regions. + * + * The returned list is sorted by region ID. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param int $country To filter on country + * @param string $filter To filter the regions by name + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return array List of regions + * + * @url GET dictionary/regions + * + * @throws RestException + */ + public function getListOfRegions($sortfield = "code_region", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $filter = '', $sqlfilters = '') + { + $list = array(); + + // Note: The filter is not applied in the SQL request because it must + // be applied to the translated names, not to the names in database. + $sql = "SELECT t.rowid FROM ".MAIN_DB_PREFIX."c_regions as t"; + $sql .= " WHERE 1 = 1"; + if ($country) { + $sql .= " AND t.fk_pays = ".((int) $country); + } + // Add sql filters + if ($sqlfilters) { + $errormessage = ''; + if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) { + throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage); + } + $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->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $obj = $this->db->fetch_object($result); + $region = new Cregion($this->db); + if ($region->fetch($obj->rowid) > 0) { + if (empty($filter) || stripos($region->name, $filter) !== false) { + $list[] = $this->_cleanObjectDatas($region); + } + } + } + } else { + throw new RestException(503, 'Error when retrieving list of regions'); + } + + return $list; + } + + /** + * Get region by ID. + * + * @param int $id ID of region + * @return array Array of cleaned object properties + * + * @url GET dictionary/regions/{id} + * + * @throws RestException + */ + public function getRegionByID($id) + { + return $this->_fetchCregion($id, ''); + } + + /** + * Get region by Code. + * + * @param string $code Code of region + * @return array Array of cleaned object properties + * + * @url GET dictionary/regions/byCode/{code} + * + * @throws RestException + */ + public function getRegionByCode($code) + { + return $this->_fetchCregion('', $code); + } + /** * Get the list of states/provinces. * @@ -464,6 +566,29 @@ class Setup extends DolibarrApi return $this->_fetchCcountry('', '', $iso, $lang); } + /** + * Get region. + * + * @param int $id ID of region + * @param string $code Code of region + * @return array Array of cleaned object properties + * + * @throws RestException + */ + private function _fetchCregion($id, $code = '') + { + $region = new Cregion($this->db); + + $result = $region->fetch($id, $code); + if ($result < 0) { + throw new RestException(503, 'Error when retrieving region : '.$region->error); + } elseif ($result == 0) { + throw new RestException(404, 'Region not found'); + } + + return $this->_cleanObjectDatas($region); + } + /** * Get state. * diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index b0f32910498..5d05c42622f 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -204,7 +204,7 @@ function printDropdownBookmarksList() '; $html .= ' - + diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index a299da1c3ee..d2d3812400d 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -408,7 +408,7 @@ while ($i < $imaxinloop) { print "\n"; // Target - print ''; + print ''; if ($obj->target == 0) { print $langs->trans("BookmarkTargetReplaceWindowShort"); } @@ -418,7 +418,7 @@ while ($i < $imaxinloop) { print "\n"; // Author - print ''; + print ''; if ($obj->fk_user > 0) { if (empty($conf->cache['users'][$obj->fk_user])) { $tmpuser = new User($db); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 942d4d2e75e..17f77a6f644 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1221,7 +1221,7 @@ if ($action == 'create') { print ''.$langs->trans("Date").''; // Recurring event - $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); + $userepeatevent = (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0); if ($userepeatevent) { // Repeat //print ''; @@ -1477,6 +1477,7 @@ if ($action == 'create') { print ''; + // Task print ''.$langs->trans("Task").''; print img_picto('', 'projecttask', 'class="paddingrightonly"'); $projectsListId = false; @@ -1486,7 +1487,7 @@ if ($action == 'create') { $tid = GETPOSTISSET("projecttaskid") ? GETPOST("projecttaskid", 'int') : (GETPOSTISSET("taskid") ? GETPOST("taskid", 'int') : ''); - $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500', $projectsListId); + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500 widthcentpercentminusxx', $projectsListId); print ''; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 16491ce4f88..8879e48edd6 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -454,15 +454,15 @@ class ActionComm extends CommonObject if ($this->percentage > 100) { $this->percentage = 100; } - //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; + if (empty($this->datep) && $this->datep != '0') { // We should not insert event in calendar without a start date + $this->datep = $now; + } if (!empty($this->datep) && !empty($this->datef)) { $this->durationp = ($this->datef - $this->datep); // deprecated } - //if (!empty($this->date) && !empty($this->dateend)) $this->durationa=($this->dateend - $this->date); if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) { $this->datef = $this->datep; } - //if (!empty($this->date) && !empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; if (!isset($this->fk_project) || $this->fk_project < 0) { $this->fk_project = 0; } @@ -559,8 +559,8 @@ class ActionComm extends CommonObject $sql .= "ip"; $sql .= ") VALUES ("; $sql .= "'(PROV)', "; - $sql .= "'".$this->db->idate($now)."', "; - $sql .= (strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : "null").", "; + $sql .= "'".$this->db->idate($now)."', "; // date creation + $sql .= "'".$this->db->idate($this->datep)."', "; // date start event $sql .= (strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : "null").", "; $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '') ? "'".$this->db->escape($this->durationp)."'" : "null").", "; // deprecated $sql .= (isset($this->type_id) ? $this->type_id : "null").","; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index ed96199e4c3..d9089f03c14 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -584,8 +584,16 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on // Local calendar $s .= '
'.$langs->trans("LocalAgenda").'  
'; - // Holiday calendar - $s .= '
 
'; + if ($user->rights->holiday->read) { + // Holiday calendar + $s .= ' +
+   +
'; + } // External calendars if (is_array($showextcals) && count($showextcals) > 0) { @@ -1003,80 +1011,82 @@ if ($showbirthday) { } } -// LEAVE-HOLIDAY CALENDAR -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; -$sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; -$sql .= " WHERE u.rowid = x.fk_user"; -$sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) -$sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) +if ($user->rights->holiday->read) { + // LEAVE-HOLIDAY CALENDAR + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.rowid = x.fk_user"; + $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) + $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) -if ($mode == 'show_day') { - // Request only leaves for the current selected day - $sql .= " AND '".$db->escape($year)."-".$db->escape($month)."-".$db->escape($day)."' BETWEEN x.date_debut AND x.date_fin"; // date_debut and date_fin are date without time -} elseif ($mode == 'show_week') { - // Restrict on current month (we get more, but we will filter later) - $sql .= " AND date_debut < '".$db->idate(dol_get_last_day($year, $month))."'"; - $sql .= " AND date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'"; -} elseif ($mode == 'show_month') { - // Restrict on current month - $sql .= " AND date_debut <= '".$db->idate(dol_get_last_day($year, $month))."'"; - $sql .= " AND date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'"; -} + if ($mode == 'show_day') { + // Request only leaves for the current selected day + $sql .= " AND '".$db->escape($year)."-".$db->escape($month)."-".$db->escape($day)."' BETWEEN x.date_debut AND x.date_fin"; // date_debut and date_fin are date without time + } elseif ($mode == 'show_week') { + // Restrict on current month (we get more, but we will filter later) + $sql .= " AND date_debut < '".$db->idate(dol_get_last_day($year, $month))."'"; + $sql .= " AND date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'"; + } elseif ($mode == 'show_month') { + // Restrict on current month + $sql .= " AND date_debut <= '".$db->idate(dol_get_last_day($year, $month))."'"; + $sql .= " AND date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'"; + } -$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); - $event = new ActionComm($db); + $event = new ActionComm($db); - // Need the id of the leave object for link to it - $event->id = $obj->rowid; - $event->ref = $event->id; + // Need the id of the leave object for link to it + $event->id = $obj->rowid; + $event->ref = $event->id; - $event->type_code = 'HOLIDAY'; - $event->type_label = ''; - $event->type_color = ''; - $event->type = 'holiday'; - $event->type_picto = 'holiday'; + $event->type_code = 'HOLIDAY'; + $event->type_label = ''; + $event->type_color = ''; + $event->type = 'holiday'; + $event->type_picto = 'holiday'; - $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1); - $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1; - $event->date_start_in_calendar = $event->datep; - $event->date_end_in_calendar = $event->datef; + $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1); + $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1; + $event->date_start_in_calendar = $event->datep; + $event->date_end_in_calendar = $event->datef; - if ($obj->status == 3) { - // Show no symbol for leave with state "leave approved" - $event->percentage = -1; - } elseif ($obj->status == 2) { - // Show TO-DO symbol for leave with state "leave wait for approval" - $event->percentage = 0; + if ($obj->status == 3) { + // Show no symbol for leave with state "leave approved" + $event->percentage = -1; + } elseif ($obj->status == 2) { + // Show TO-DO symbol for leave with state "leave wait for approval" + $event->percentage = 0; + } + + if ($obj->halfday == 1) { + $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; + } elseif ($obj->halfday == -1) { + $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; + } else { + $event->label = $obj->lastname; + } + + $daycursor = $event->date_start_in_calendar; + $annee = dol_print_date($daycursor, '%Y', 'tzuserrel'); + $mois = dol_print_date($daycursor, '%m', 'tzuserrel'); + $jour = dol_print_date($daycursor, '%d', 'tzuserrel'); + + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); + do { + $eventarray[$daykey][] = $event; + + $daykey += 60 * 60 * 24; + } while ($daykey <= $event->date_end_in_calendar); + + $i++; } - - if ($obj->halfday == 1) { - $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; - } elseif ($obj->halfday == -1) { - $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; - } else { - $event->label = $obj->lastname; - } - - $daycursor = $event->date_start_in_calendar; - $annee = dol_print_date($daycursor, '%Y', 'tzuserrel'); - $mois = dol_print_date($daycursor, '%m', 'tzuserrel'); - $jour = dol_print_date($daycursor, '%d', 'tzuserrel'); - - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); - do { - $eventarray[$daykey][] = $event; - - $daykey += 60 * 60 * 24; - } while ($daykey <= $event->date_end_in_calendar); - - $i++; } } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 32f6e571fcd..b6713c5e257 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -170,7 +170,7 @@ if (empty($reshook)) { } // Payment terms of the settlement - if ($action == 'setconditions' && $user->rights->societe->creer) { + if ($action == 'setconditions' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), GETPOST('cond_reglement_id_deposit_percent', 'alpha')); if ($result < 0) { @@ -179,7 +179,7 @@ if (empty($reshook)) { } // Payment mode - if ($action == 'setmode' && $user->rights->societe->creer) { + if ($action == 'setmode' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) { @@ -188,7 +188,7 @@ if (empty($reshook)) { } // Transport mode - if ($action == 'settransportmode' && $user->rights->societe->creer) { + if ($action == 'settransportmode' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setTransportMode(GETPOST('transport_mode_id', 'alpha')); if ($result < 0) { @@ -197,7 +197,7 @@ if (empty($reshook)) { } // Bank account - if ($action == 'setbankaccount' && $user->rights->societe->creer) { + if ($action == 'setbankaccount' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) { @@ -206,7 +206,7 @@ if (empty($reshook)) { } // customer preferred shipping method - if ($action == 'setshippingmethod' && $user->rights->societe->creer) { + if ($action == 'setshippingmethod' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); if ($result < 0) { @@ -215,7 +215,7 @@ if (empty($reshook)) { } // assujetissement a la TVA - if ($action == 'setassujtva' && $user->rights->societe->creer) { + if ($action == 'setassujtva' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $object->tva_assuj = GETPOST('assujtva_value'); $result = $object->update($object->id); @@ -225,7 +225,7 @@ if (empty($reshook)) { } // set prospect level - if ($action == 'setprospectlevel' && $user->rights->societe->creer) { + if ($action == 'setprospectlevel' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha'); $result = $object->update($object->id, $user); @@ -267,7 +267,7 @@ if (empty($reshook)) { } // Set sales representatives - if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) { + if ($action == 'set_salesrepresentatives' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setSalesRep(GETPOST('commercial', 'array')); } @@ -295,7 +295,7 @@ if (empty($reshook)) { } // warehouse - if ($action == 'setwarehouse' && $user->rights->societe->creer) { + if ($action == 'setwarehouse' && $user->hasRight('societe', 'creer')) { $result = $object->setWarehouse(GETPOST('fk_warehouse', 'int')); } } @@ -360,9 +360,9 @@ if ($object->id > 0) { print ''; print ''; - print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer); + print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->hasRight('societe', 'creer')); print ''; - print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer); + print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->hasRight('societe', 'creer')); print ''; print ''; } @@ -408,7 +408,7 @@ if ($object->id > 0) { print ''; } print '
'; print $langs->trans('PaymentConditions'); print ''; - if (($action != 'editconditions') && $user->rights->societe->creer) { + if (($action != 'editconditions') && $user->hasRight('societe', 'creer')) { print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; @@ -426,7 +426,7 @@ if ($object->id > 0) { print ''; } print '
'; print $langs->trans('PaymentMode'); print ''; - if (($action != 'editmode') && $user->rights->societe->creer) { + if (($action != 'editmode') && $user->hasRight('societe', 'creer')) { print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; @@ -445,7 +445,7 @@ if ($object->id > 0) { print ''; } print '
'; print $langs->trans('PaymentBankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->societe->creer) { + if (($action != 'editbankaccount') && $user->hasRight('societe', 'creer')) { print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; @@ -467,7 +467,7 @@ if ($object->id > 0) { print '
'; print $langs->trans("CustomerRelativeDiscountShort"); print ''; - if ($user->rights->societe->creer && !$user->socid > 0) { + if ($user->hasRight('societe', 'creer') && !$user->socid > 0) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; @@ -480,7 +480,7 @@ if ($object->id > 0) { print ''; print $langs->trans("CustomerAbsoluteDiscountShort"); print ''; - if ($user->rights->societe->creer && !$user->socid > 0) { + if ($user->hasRight('societe', 'creer') && !$user->socid > 0) { print ''.img_edit($langs->trans("Modify")).''; } print ''; @@ -502,10 +502,10 @@ if ($object->id > 0) { if ($object->client) { print ''; print ''; - print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer); + print $form->editfieldkey("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->hasRight('societe', 'creer')); print ''; $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; - print $form->editfieldval("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->rights->societe->creer, $limit_field_type, ($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); + print $form->editfieldval("OutstandingBill", 'outstanding_limit', $object->outstanding_limit, $object, $user->hasRight('societe', 'creer'), $limit_field_type, ($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); print ''; print ''; } @@ -515,9 +515,9 @@ if ($object->id > 0) { print ''."\n"; print ''; print ''; - print $form->editfieldkey("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $user->rights->societe->creer); + print $form->editfieldkey("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $user->hasRight('societe', 'creer')); print ''; - print $form->editfieldval("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $user->rights->societe->creer, $limit_field_type, ($object->order_min_amount != '' ? price($object->order_min_amount) : '')); + print $form->editfieldval("OrderMinAmount", 'order_min_amount', $object->order_min_amount, $object, $user->hasRight('societe', 'creer'), $limit_field_type, ($object->order_min_amount != '' ? price($object->order_min_amount) : '')); print ''; print ''; } @@ -530,7 +530,7 @@ if ($object->id > 0) { print '
'; print $langs->trans("PriceLevel"); print ''; - if ($user->rights->societe->creer) { + if ($user->hasRight('societe', 'creer')) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; @@ -551,7 +551,7 @@ if ($object->id > 0) { $formproduct = new FormProduct($db); print ''; print ''; - print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $user->rights->societe->creer); + print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $user->hasRight('societe', 'creer')); print ''; if ($action == 'editwarehouse') { $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_warehouse, 'fk_warehouse', 1); @@ -571,7 +571,7 @@ if ($object->id > 0) { print ''; } print '
'; print $langs->trans('SendingMethod'); print ''; - if (($action != 'editshipping') && $user->rights->societe->creer) { + if (($action != 'editshipping') && $user->hasRight('societe', 'creer')) { print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; @@ -591,7 +591,7 @@ if ($object->id > 0) { print ''; } print '
'; print $langs->trans('IntracommReportTransportMode'); print ''; - if (($action != 'edittransportmode') && $user->rights->societe->creer) { + if (($action != 'edittransportmode') && $user->hasRight('societe', 'creer')) { print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; @@ -654,7 +654,7 @@ if ($object->id > 0) { print ''; } print '
'; print $langs->trans('ProspectLevel'); print ''; - if ($action != 'editlevel' && $user->rights->societe->creer) { + if ($action != 'editlevel' && $user->hasRight('societe', 'creer')) { print 'id.'">'.img_edit($langs->trans('Modify'), 1).'
'; @@ -695,7 +695,7 @@ if ($object->id > 0) { $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; // Lien recap - $boxstat .= '
'; + $boxstat .= '
'; $boxstat .= ''; $boxstat .= ''; - print '
'; @@ -1026,7 +1026,7 @@ if ($object->id > 0) { /* * Latest shipments */ - if (isModEnabled("expedition") && $user->rights->expedition->lire) { + if (isModEnabled("expedition") && $user->hasRight('expedition', 'lire')) { $sql = 'SELECT e.rowid as id'; $sql .= ', e.ref, e.entity'; $sql .= ', e.date_creation'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a7963191627..b3f3d387df3 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1289,6 +1289,10 @@ class Propal extends CommonObject dol_print_error($this->db); break; } + + // Set the id on created row + $line->id = $result; + // Defined the new fk_parent_line if ($result > 0 && $line->product_type == 9) { $fk_parent_line = $result; @@ -1423,6 +1427,8 @@ class Propal extends CommonObject } foreach ($object->lines as $line) { + $line->id = 0; + if ($line->fk_product > 0) { $prod = new Product($this->db); $res = $prod->fetch($line->fk_product); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 11278a3dbaa..e998f8487b3 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -245,10 +245,10 @@ $arrayfields = array( 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>isModEnabled("multicurrency") && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>-1), - 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)), - 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)), - 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), - 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), + 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), + 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), @@ -285,17 +285,17 @@ foreach ($object->fields as $key => $val) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; // Permissions -$permissiontoread = $user->rights->propal->lire; -$permissiontoadd = $user->rights->propal->creer; -$permissiontodelete = $user->rights->propal->supprimer; +$permissiontoread = $user->hasRight('propal', 'lire'); +$permissiontoadd = $user->hasRight('propal', 'creer'); +$permissiontodelete = $user->hasRight('propal', 'supprimer'); if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { - $permissiontovalidate = $user->rights->propal->propal_advance->validate; - $permissiontoclose = $user->rights->propal->propal_advance->close; - $permissiontosendbymail = $user->rights->propal->propal_advance->send; + $permissiontovalidate = $user->hasRight('propal', 'propal_advance', 'validate'); + $permissiontoclose = $user->hasRight('propal', 'propal_advance', 'close'); + $permissiontosendbymail = $user->hasRight('propal', 'propal_advance', 'send'); } else { - $permissiontovalidate = $user->rights->propal->creer; - $permissiontoclose = $user->rights->propal->creer; - $permissiontosendbymail = $user->rights->propal->lire; + $permissiontovalidate = $user->hasRight('propal', 'creer'); + $permissiontoclose = $user->hasRight('propal', 'creer'); + $permissiontosendbymail = $user->hasRight('propal', 'lire'); } @@ -1082,7 +1082,7 @@ if ($resql) { $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton = dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', $url, '', $user->rights->propal->creer); + $newcardbutton = dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('propal', 'creer')); // Fields title search print '
'; @@ -1151,7 +1151,7 @@ if ($resql) { $formcategory = new FormCategory($db); $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PRODUCT, array($search_product_category), 'maxwidth300', $searchCategoryProductOperator, 0, 0, $tmptitle); } - if (isModEnabled('categorie') && $user->rights->categorie->lire) { + if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); @@ -2335,8 +2335,8 @@ if ($resql) { $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; - $genallowed = $user->rights->propal->lire; - $delallowed = $user->rights->propal->creer; + $genallowed = $user->hasRight('propal', 'lire'); + $delallowed = $user->hasRight('propal', 'creer'); print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } else { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 332d9d13e0b..778df650514 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2692,52 +2692,65 @@ if ($action == 'create' && $usercancreate) { print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount HT - print ''; - print ''; - print ''; - - // Multicurrency Amount VAT - print ''; - print ''; - print ''; - - // Multicurrency Amount TTC - print ''; - print ''; - print ''; - } - - // Total HT $alert = ''; if (!empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) { - $alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount)); + $alert = ' ' . img_warning($langs->trans('OrderMinAmount') . ': ' . price($object->thirdparty->order_min_amount)); } - print ''; - print ''; - // Total VAT - print ''; + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount HT + print ''; + } + print ''; + + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount VAT + print ''; + } + print ''; // Amount Local Taxes - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { // Localtax1 - print ''; - print ''; - } - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { // Localtax2 IRPF - print ''; - print ''; + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + + print ''; + // Amount Local Taxes + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + } } - // Total TTC - print ''; + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount TTC + print ''; + } + print ''; + + print '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$langs->trans('AmountHT').''.price($object->total_ht, 1, '', 1, -1, -1, $conf->currency).$alert.'
'.$langs->trans('AmountVAT').''.price($object->total_tva, 1, '', 1, -1, -1, $conf->currency).'
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, 1, '', 1, -1, -1, $conf->currency).'
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($object->total_localtax2, 1, '', 1, -1, -1, $conf->currency).'
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'.$langs->trans('AmountTTC').''.price($object->total_ttc, 1, '', 1, -1, -1, $conf->currency).'
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, -1, -1, $conf->currency) . '' . price($object->total_ttc, 1, '', 1, -1, -1, $object->multicurrency_code) . '
'; // Statut //print '
' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '
'; - // Margin Infos if (isModEnabled('margin')) { $formmargin->displayMarginInfos($object); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index bb51b8c2111..ae9625fbcb5 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -184,7 +184,7 @@ class Orders extends DolibarrApi 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."facture AS t LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields + $sql .= " FROM ".MAIN_DB_PREFIX."commande AS t LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields 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 diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f9cb9cfb03f..2f58c5576c7 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; /** diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index ff0666e0d81..5956cbf4a3a 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -37,6 +37,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'multicurrency')); +$action = GETPOST('action', 'aZ09'); + +$hookmanager->initHooks(array('banktransfer')); + $socid = 0; if ($user->socid > 0) { $socid = $user->socid; @@ -45,12 +49,10 @@ if (!$user->rights->banque->transfer) { accessforbidden(); } -$action = GETPOST('action', 'aZ09'); - -$hookmanager->initHooks(array('banktransfer')); - $MAXLINES = 10; +$error = 0; + /* * Actions @@ -61,10 +63,20 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } -if ($action == 'add') { +if ($action == 'add' && !empty($user->rights->banque->transfer)) { $langs->load('errors'); $i = 1; + $dateo = array(); + $label = array(); + $amount = array(); + $amountto = array(); + $accountfrom = array(); + $accountto = array(); + $type = array(); + $tabnum = array(); + $maxtab = 1; + while ($i < $MAXLINES) { $dateo[$i] = dol_mktime(12, 0, 0, GETPOST($i.'_month', 'int'), GETPOST($i.'_day', 'int'), GETPOST($i.'_year', 'int')); $label[$i] = GETPOST($i.'_label', 'alpha'); @@ -73,75 +85,71 @@ if ($action == 'add') { $accountfrom[$i] = intval(GETPOST($i.'_account_from', 'int')); $accountto[$i] = intval(GETPOST($i.'_account_to', 'int')); $type[$i] = GETPOST($i.'_type', 'int'); - $errori[$i] = 0; $tabnum[$i] = 0; if (!empty($label[$i]) || !($amount[$i] <= 0) || !($accountfrom[$i] < 0) || !($accountto[$i] < 0)) { $tabnum[$i] = 1; + $maxtab = $i; } $i++; } + $db->begin(); + $n = 1; while ($n < $MAXLINES) { if ($tabnum[$n] === 1) { if ($accountfrom[$n] < 0) { - $errori[$n]++; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' .$langs->transnoentities("TransferFrom")), null, 'errors'); } if ($accountto[$n] < 0) { - $errori[$n]++; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' .$langs->transnoentities("TransferTo")), null, 'errors'); } if (!$type[$n]) { - $errori[$n]++; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' .$langs->transnoentities("Type")), null, 'errors'); } if (!$dateo[$n]) { - $errori[$n]++; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' .$langs->transnoentities("Date")), null, 'errors'); } if (!($label[$n])) { - $errori[$n]++; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' . $langs->transnoentities("Description")), null, 'errors'); } if (!($amount[$n])) { - $errori[$n]++; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n. ' ' .$langs->transnoentities("Amount")), null, 'errors'); } - if (!$errori[$n]) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $tmpaccountfrom = new Account($db); + $tmpaccountfrom->fetch(GETPOST($n.'_account_from', 'int')); - $tmpaccountfrom = new Account($db); - $tmpaccountfrom->fetch(GETPOST($n.'_account_from', 'int')); + $tmpaccountto = new Account($db); + $tmpaccountto->fetch(GETPOST($n.'_account_to', 'int')); - $tmpaccountto = new Account($db); - $tmpaccountto->fetch(GETPOST($n.'_account_to', 'int')); - - if ($tmpaccountto->currency_code == $tmpaccountfrom->currency_code) { - $amountto[$n] = $amount[$n]; - } else { - if (!$amountto[$n]) { - $errori[$n]++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")).' #'.$n, null, 'errors'); - } - } - if ($amountto[$n] < 0) { - $errori[$n]++; - setEventMessages($langs->trans("AmountMustBePositive").' #'.$n, null, 'errors'); - } - - if ($tmpaccountto->id == $tmpaccountfrom->id) { - $errori[$n]++; - setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers").' #'.$n, null, 'errors'); + if ($tmpaccountto->currency_code == $tmpaccountfrom->currency_code) { + $amountto[$n] = $amount[$n]; + } else { + if (!$amountto[$n]) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", '#'.$n.' '.$langs->transnoentities("AmountToOthercurrency")), null, 'errors'); } } + if ($amountto[$n] < 0) { + $error++; + setEventMessages($langs->trans("AmountMustBePositive").' #'.$n, null, 'errors'); + } - if ($errori[$n] == 0) { - $db->begin(); + if ($tmpaccountto->id == $tmpaccountfrom->id) { + $error++; + setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers").' #'.$n, null, 'errors'); + } + if (!$error) { $bank_line_id_from = 0; $bank_line_id_to = 0; $result = 0; @@ -155,47 +163,56 @@ if ($action == 'add') { $typeto = 'LIQ'; } - if (!$errori[$n]) { + if (!$error) { $bank_line_id_from = $tmpaccountfrom->addline($dateo[$n], $typefrom, $label[$n], price2num(-1 * $amount[$n]), '', '', $user); } if (!($bank_line_id_from > 0)) { - $errori[$n]++; + $error++; } - if (!$errori[$n]) { + if (!$error) { $bank_line_id_to = $tmpaccountto->addline($dateo[$n], $typeto, $label[$n], $amountto[$n], '', '', $user); } if (!($bank_line_id_to > 0)) { - $errori[$n]++; + $error++; } - if (!$errori[$n]) { + if (!$error) { $result = $tmpaccountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); } if (!($result > 0)) { - $errori[$n]++; + $error++; } - if (!$errori[$n]) { + if (!$error) { $result = $tmpaccountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); } if (!($result > 0)) { - $errori[$n]++; + $error++; } - if (!$errori[$n]) { + if (!$error) { $mesgs = $langs->trans("TransferFromToDone", '{s1}', '{s2}', $amount[$n], $langs->transnoentitiesnoconv("Currency".$conf->currency)); $mesgs = str_replace('{s1}', ''.$tmpaccountfrom->label.'', $mesgs); $mesgs = str_replace('{s2}', ''.$tmpaccountto->label.'', $mesgs); setEventMessages($mesgs, null, 'mesgs'); - $db->commit(); } else { + $error++; setEventMessages($tmpaccountfrom->error.' '.$tmpaccountto->error, null, 'errors'); - $db->rollback(); } } } $n++; } + + if (!$error) { + $db->commit(); + + header("Location: ".DOL_URL_ROOT.'/compta/bank/transfer.php'); + exit; + } else { + $db->rollback(); + } } + /* * View */ @@ -208,7 +225,7 @@ $title = $langs->trans('MenuBankInternalTransfer'); llxHeader('', $title, $help_url); -print ' + '; // End of page diff --git a/htdocs/compta/facture/agenda.php b/htdocs/compta/facture/agenda.php index 45f495c1723..2442f9ce662 100644 --- a/htdocs/compta/facture/agenda.php +++ b/htdocs/compta/facture/agenda.php @@ -194,7 +194,7 @@ if ($object->id > 0) { $out = '&origin='.urlencode($object->element.(property_exists($object, 'module') ? '@'.$object->module : '')).'&originid='.urlencode($object->id); $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('paymentbagendaybanktransfer', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='trans("ConfirmClassifyPaidPartiallyReasonWithholdingTaxDesc"); + $i++; $close[$i]['label'] = $langs->trans("Other"); $i++; // Texte @@ -4268,6 +4272,8 @@ if ($action == 'create') { $i++; $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBankCharge", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1); $i++; + $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonWithholdingTax"), $close[$i]['label'], 1); + $i++; $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("Other"), $close[$i]['label'], 1); $i++; // arrayreasons[code]=reason @@ -4278,7 +4284,7 @@ if ($action == 'create') { // Cree un tableau formulaire $formquestion = array('text' => $langs->trans("ConfirmClassifyPaidPartiallyQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300')); // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidPartially', $object->ref), 'confirm_paid_partially', $formquestion, "yes", 1, 340, 600); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidPartially', $object->ref), 'confirm_paid_partially', $formquestion, "yes", 1, 380, 600); } // Confirmation du classement abandonne @@ -4788,6 +4794,7 @@ if ($action == 'create') { print ''."\n"; print '
'."\n"; + print ''; $sign = 1; @@ -4795,44 +4802,61 @@ if ($action == 'create') { $sign = -1; // We invert sign for output } - if (isModEnabled('multicurrency') && ($object->multicurrency_code != $conf->currency)) { + print ''; + // Amount HT + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print ''; - print ''; - print ''; - - // Multicurrency Amount VAT - print ''; - print ''; - print ''; - - // Multicurrency Amount TTC - print ''; - print ''; - print ''; + print ''; } + print ''; - // Amount - print ''; - print ''; - - // Vat - print ''; + print ''; + // Amount VAT + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount VAT + print ''; + } print ''; // Amount Local Taxes - if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { // Localtax1 - print ''; - print ''; - } - if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { // Localtax2 - print ''; - print ''; + if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + + if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + } } - // Revenue stamp - if ($selleruserevenustamp) { // Test company use revenue stamp - print ''; + // Amount TTC + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount TTC + print ''; + } + print ''; + + print '
' . $langs->trans('AmountHT') . '' . price($sign * $object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($sign * $object->multicurrency_total_ttc, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
' . price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'.$langs->trans('AmountHT').''.price($sign * $object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans('AmountVAT').''.price($sign * $object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'
' . $langs->trans('AmountVAT') . '' . price($sign * $object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($sign * $object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($sign * $object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; + print '
' . $langs->trans('AmountTTC') . '' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; + + // Ajouter la première condition + if ($selleruserevenustamp) { print ''; @@ -4852,43 +4876,37 @@ if ($action == 'create') { print ' '; print ''; print " "; + } + $('#revenuestamp_val').val(revenue); + $('#revenuestamp_span').html(revenue); + } + "; } else { - print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); + print price($object->revenuestamp, 1, '', 1, -1, -1, $conf->currency); } print ''; } - // Total with tax - print ''; - - print '
'; print $langs->trans('RevenueStamp'); print '
'.$langs->trans('AmountTTC').''.price($sign * $object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'
'; - - $nbrows = 8; $nbcols = 3; if (isModEnabled('project')) { @@ -5111,7 +5129,7 @@ if ($action == 'create') { } print ''; $label = ($langs->trans("PaymentType".$objp->payment_code) != ("PaymentType".$objp->payment_code)) ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_label; - print ''.$label.' '.$objp->num_payment.''; + print ''.dol_escape_htmltag($label.' '.$objp->num_payment).''; if (isModEnabled("banque")) { $bankaccountstatic->id = $objp->baid; $bankaccountstatic->ref = $objp->baref; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1821d43cce8..ff4658e96b0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5698,7 +5698,11 @@ class Facture extends CommonInvoice $resql = $this->db->query($sql); $stmpidate = dol_print_date($tmpidate, 'day', 'gmt'); - $this->output .= $langs->transnoentitiesnoconv("SearchUnpaidInvoicesWithDueDate", $stmpidate); + if ($datetouse == 'invoicedate') { + $this->output .= $langs->transnoentitiesnoconv("SearchValidatedInvoicesWithDate", $stmpidate); + } else { + $this->output .= $langs->transnoentitiesnoconv("SearchUnpaidInvoicesWithDueDate", $stmpidate); + } if (!empty($paymentmode) && $paymentmode != 'all') { $this->output .= ' ('.$langs->transnoentitiesnoconv("PaymentMode").' '.$paymentmode.')'; } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 948bb42337a..b571c8550f1 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -747,10 +747,10 @@ if ($object->id > 0) { print "\n".'
'."\n"; $buttonlabel = $langs->trans("MakeWithdrawRequest"); - $user_perms = $user->rights->prelevement->bons->creer; + $user_perms = $user->hasRight('prelevement', 'bons', 'creer'); if ($type == 'bank-transfer') { $buttonlabel = $langs->trans("MakeBankTransferOrder"); - $user_perms = $user->rights->paymentbybanktransfer->create; + $user_perms = $user->hasRight('paymentbybanktransfer', 'create'); } // Add a transfer request diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index f62768bdff9..9d1e3b39a03 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -9,6 +9,7 @@ * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -223,6 +224,7 @@ if (empty($reshook)) { } $multicurrency_code = array(); + $multicurrency_tx = array(); // Clean parameters amount if payment is for a credit note foreach ($amounts as $key => $value) { // How payment is dispatched @@ -233,6 +235,7 @@ if (empty($reshook)) { $amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched @@ -243,6 +246,7 @@ if (empty($reshook)) { $multicurrency_amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } if (isModEnabled("banque")) { @@ -259,6 +263,7 @@ if (empty($reshook)) { $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching + $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of 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'); @@ -470,6 +475,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; + print ''; print dol_get_fiche_head(); @@ -863,7 +869,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $langs->load("withdrawals"); if (!empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '
'.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed"); }*/ - print '


'; + print '


'; print '
'; } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index dbb63e20cb8..7df61ebefcb 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2020 Andreu Bisquerra Gaya * Copyright (C) 2021 OpenDsi * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2023 Sylvain Legrand * * 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,6 +77,7 @@ class Paiement extends CommonObject public $multicurrency_amount; // Total amount of payment (in the currency of the bank account) public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency) public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency) + public $multicurrency_tx = array(); // array: invoice ID => currency tx for that invoice public $multicurrency_code = array(); // array: invoice ID => currency code for that invoice public $pos_change = 0; // Excess received in TakePOS cash payment @@ -262,8 +264,9 @@ class Paiement extends CommonObject } $currencyofpayment = ''; + $currencytxofpayment = ''; - foreach ($amounts as $key => $value) { // How payment is dispatch + foreach ($amounts as $key => $value) { // How payment is dispatched if (empty($value)) { continue; } @@ -282,6 +285,9 @@ class Paiement extends CommonObject $this->error = 'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment'; return -1; } + if (empty($currencytxofpayment)) { + $currencytxofpayment = isset($this->multicurrency_tx[$key]) ? $this->multicurrency_tx[$key] : ""; + } $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); @@ -294,6 +300,10 @@ class Paiement extends CommonObject } } + if (empty($currencyofpayment)) { // Should not happen. For the case the multicurrency_code was not saved into invoices + $currencyofpayment = $conf->currency; + } + if (!empty($currencyofpayment)) { // We must check that the currency of invoices is the same than the currency of the bank $bankaccount = new Account($this->db); @@ -351,9 +361,8 @@ class Paiement extends CommonObject $facid = $key; if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)"; - // TODO Add multicurrency_code and multicurrency_tx - $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)"; + $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).", ".($currencyofpayment ? "'".$this->db->escape($currencyofpayment)."'" : 'NULL').", ".(!empty($this->multicurrency_tx) ? (double) $currencytxofpayment : 1).")"; dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index d2a34bc8d2c..85d8b0be4bf 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -80,9 +80,7 @@ if (empty($action) && empty($id) && empty($ref)) { } // Load object -if ($id > 0 || $ref) { - $object->fetch($id, $ref); -} +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. $permissiontoread = $user->rights->tax->charges->lire; $permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php @@ -93,7 +91,7 @@ $upload_dir = $conf->tax->multidir_output[isset($object->entity) ? $object->enti // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) { +if (!empty($user->socid)) { $socid = $user->socid; } $result = restrictedArea($user, 'tax', $object->id, 'tva', 'charges'); diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 5325523f8e5..bbfc452556f 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -215,6 +215,8 @@ $dolibarr_main_instance_unique_id='84b5bc91f83b56e458db71e0adac2b62'; // $dolibarr_main_authentication='ldap,dolibarr'; // You can set several mode using a comma as a separator. // $dolibarr_main_authentication='forceuser'; // This need to add also $dolibarr_auto_user='loginforuser'; // $dolibarr_main_authentication='twofactor'; // To use Google Authenticator. This need the non official external module "Two Factor" available on www.dolistore.com +// $dolibarr_main_authentication='openid_connect'; // See https://wiki.dolibarr.org/index.php?title=Authentication,_SSO_and_SSL +// $dolibarr_main_authentication='googleoauth'; // See https://wiki.dolibarr.org/index.php?title=Authentication,_SSO_and_SSL // $dolibarr_main_authentication='dolibarr'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 0d7ce191058..8bed3de23f7 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1537,7 +1537,7 @@ class Contact extends CommonObject $linkend = '
'; } - $result .= $linkstart; + $result .= (($option == 'nolink') ? '' : $linkstart); if ($withpicto) { if ($withpicto < 0) { $result .= ''.Form::showphoto('contact', $this, 0, 0, 0, 'userphoto'.($withpicto == -3 ? 'small' : ''), 'mini', 0, 1).''; @@ -1548,7 +1548,7 @@ class Contact extends CommonObject if ($withpicto != 2 && $withpicto != -2) { $result .= ''.($maxlen ? dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)).''; } - $result .= $linkend; + $result .= (($option == 'nolink') ? '' : $linkend); global $action; $hookmanager->initHooks(array('contactdao')); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index b89dea64cc7..d5d0858ab38 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1867,7 +1867,7 @@ if ($action == 'create') { // Area with status and activation info of line if ($object->statut > 0) { - print ''; + print '
'; print ''; print ''; @@ -1938,7 +1938,7 @@ if ($action == 'create') { print ''; print ''; - print '
'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline - 1]->getLibStatut(4).'
'; + print '
'; // Definie date debut et fin par defaut $dateactstart = $objp->date_start; @@ -1995,7 +1995,7 @@ if ($action == 'create') { print ''; print ''; - print '
'; + print '
'; // Definie date debut et fin par defaut $dateactstart = $objp->date_start_real; diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 83fd8d47c4f..a74f9c4c5a8 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -367,7 +367,7 @@ if ($action == 'update') { $computedvalue, (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile'), - GETPOST('enabled', 'alpha'), + GETPOST('enabled', 'nohtml'), (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha'), array('css' => $css, 'cssview' => $cssview, 'csslist' => $csslist) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index f47d8bcdf2d..da7f2f43740 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -554,9 +554,13 @@ if (!$error && $massaction == 'confirm_presend') { $sendcontext = 'standard'; } + // Set tmp user directory (used to convert images embedded as img src=data:image) + $vardir = $conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path + // 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); + $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext, '', $upload_dir_tmp); if ($mailfile->error) { $resaction .= '
'.$mailfile->error.'
'; } else { diff --git a/htdocs/core/ajax/ajaxstatusprospect.php b/htdocs/core/ajax/ajaxstatusprospect.php new file mode 100644 index 00000000000..e5719b98d8b --- /dev/null +++ b/htdocs/core/ajax/ajaxstatusprospect.php @@ -0,0 +1,76 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2010 Cyrille de Lambert + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/ajax/ajaxstatusprospect.php + * \brief File to return Ajax response on third parties request + */ + +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); + +// Load Dolibarr environment +require '../../main.inc.php'; + +$idstatus = GETPOST('id', 'int'); +$idprospect = GETPOST('prospectid', 'int'); +$action = GETPOST('action', 'aZ09'); + +// Security check +if ($user->socid > 0) { + if ($idprospect != $user->socid) { + accessforbidden('Not allowed on this thirdparty'); + } +} + +// var_dump( $user, 'societe', $idprospect, '&societe'); +$result = restrictedArea($user, 'societe', $idprospect, '&societe'); + +$permisstiontoupdate = $user->hasRight('societe', 'creer'); + +/* + * View + */ + +top_httphead(); + + +if ($action === "updatestatusprospect" && $permisstiontoupdate) { + $response = ''; + + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; + $sql .= "fk_stcomm=".(int) $db->escape($idstatus); + $sql .= " WHERE rowid = ".(int) $db->escape($idprospect); + + $resql = $db->query($sql); + + if (!$resql) { + dol_print_error($db); + } else { + $num = $db->affected_rows($resql); + $response = http_response_code(200); + } + + $response =json_encode($response); + echo $response; +} diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index 6341fb9f899..c4f192e7490 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015-2023 Frédéric France - * Copyright (C) 2021-2022 Waël Almoman + * Copyright (C) 2021-2023 Waël Almoman * * 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 @@ -79,7 +79,7 @@ class box_members_by_tags extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $conf; + global $user, $langs; $langs->load("boxes"); $this->max = $max; @@ -89,9 +89,9 @@ class box_members_by_tags extends ModeleBoxes $now = dol_now(); $year = date('Y'); - $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); + $numberyears = getDolGlobalInt("MAIN_NB_OF_YEAR_IN_MEMBERSHIP_WIDGET_GRAPH", 0); - $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByTags").' ('.($year - $numberyears).' - '.$year.')'); + $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByTags").($numberyears ? ' ('.($year - $numberyears).' - '.$year.')' : '')); if ($user->rights->adherent->lire) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; @@ -119,13 +119,13 @@ class box_members_by_tags extends ModeleBoxes 'text' => $labelstatus, ); // Up to date - $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() + 86400, 1); + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, $now + 86400, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus, ); // Expired - $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() - 86400, 1); + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, $now - 86400, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus @@ -143,25 +143,24 @@ class box_members_by_tags extends ModeleBoxes 'text' => $labelstatus ); // Total row - $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($langs->trans("Total")).'"', 'text' => $langs->trans("Total") ); $line++; foreach ($sumMembers as $key => $data) { - $adhtype = new AdherentType($this->db); - $adhtype->id = $key; + $adhtag = new Categorie($this->db); + $adhtag->id = $key; if ($key=='total') { break; } - $adhtype->label = $data['label']; - $AdherentType[$key] = $adhtype; + $adhtag->label = $data['label']; + $AdherentTag[$key] = $adhtag; $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $adhtype->getNomUrl(1, dol_size(32)), + 'text' => ''.dol_trunc(($adhtag->ref ? $adhtag->ref : $adhtag->label), dol_size(32)).'', 'asis' => 1, ); $this->info_box_contents[$line][] = array( @@ -171,17 +170,17 @@ class box_members_by_tags extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($data['members_pending']) && $data['members_pending'] > 0 ? $data['members_pending'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), + 'text' => (isset($data['members_pending']) && $data['members_pending'] > 0 ? $data['members_pending'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($data['members_uptodate']) && $data['members_uptodate'] > 0 ? $data['members_uptodate'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 0, 0, 3), + 'text' => (isset($data['members_uptodate']) && $data['members_uptodate'] > 0 ? $data['members_uptodate'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 0, $now + 86400, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($data['members_expired']) && $data['members_expired'] > 0 ? $data['members_expired'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'text' => (isset($data['members_expired']) && $data['members_expired'] > 0 ? $data['members_expired'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now - 86400, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( @@ -196,7 +195,7 @@ class box_members_by_tags extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($data['total_adhtype']) && $data['total_adhtype'] > 0 ? $data['total_adhtype'] : ''), + 'text' => (isset($data['total_adhtag']) && $data['total_adhtag'] > 0 ? $data['total_adhtag'] : ''), 'asis' => 1, ); $line++; diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index f400ae6fb3d..046c7031ece 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -2,8 +2,8 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2020 Frederic France - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2015-2023 Frederic France + * Copyright (C) 2021-2023 Waël Almoman * * 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,7 +68,7 @@ class box_members_by_type extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = !(isModEnabled('adherent') && $user->rights->adherent->lire); + $this->hidden = !(isModEnabled('adherent') && $user->hasRight('adherent', 'lire')); } /** @@ -79,7 +79,7 @@ class box_members_by_type extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $conf; + global $user, $langs; $langs->loadLangs(array("boxes", "members")); $this->max = $max; @@ -88,160 +88,75 @@ class box_members_by_type extends ModeleBoxes require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php'; $staticmember = new Adherent($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType", $max)); + $now = dol_now(); + $year = date('Y'); + $numberyears = getDolGlobalInt("MAIN_NB_OF_YEAR_IN_MEMBERSHIP_WIDGET_GRAPH"); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType").($numberyears ? ' ('.($year-$numberyears).' - '.$year.')' : '')); if ($user->rights->adherent->lire) { - $MembersToValidate = array(); - $MembersPending = array(); - $MembersValidated = array(); - $MembersUpToDate = array(); - $MembersExcluded = array(); - $MembersResiliated = array(); - - $SumToValidate = 0; - $SumPending = 0; - $SumExpired = 0; - $SumUpToDate = 0; - $SumResiliated = 0; - $SumExcluded = 0; - - $AdherentType = array(); - - // Type of membership - $sql = "SELECT t.rowid, t.libelle as label, t.subscription,"; - $sql .= " d.statut, count(d.rowid) as somme"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as t"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "adherent as d"; - $sql .= " ON t.rowid = d.fk_adherent_type"; - $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; - $sql .= " WHERE t.entity IN (" . getEntity('member_type') . ")"; - $sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; - - dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $this->db->fetch_object($result); - - $adhtype = new AdherentType($this->db); - $adhtype->id = $objp->rowid; - $adhtype->subscription = $objp->subscription; - $adhtype->label = $objp->label; - $AdherentType[$objp->rowid] = $adhtype; - - if ($objp->statut == Adherent::STATUS_DRAFT) { - $MembersToValidate[$objp->rowid] = $objp->somme; - } - if ($objp->statut == Adherent::STATUS_VALIDATED) { - $MembersValidated[$objp->rowid] = $objp->somme; - } - if ($objp->statut == Adherent::STATUS_EXCLUDED) { - $MembersExcluded[$objp->rowid] = $objp->somme; - } - if ($objp->statut == Adherent::STATUS_RESILIATED) { - $MembersResiliated[$objp->rowid] = $objp->somme; - } - - $i++; - } - $this->db->free($result); - $now = dol_now(); - - // Members up to date list - // current rule: uptodate = the end date is in future whatever is type - // old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) - $sql = "SELECT count(*) as somme , d.fk_adherent_type"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "adherent_type as t"; - $sql .= " WHERE d.entity IN (" . getEntity('adherent') . ")"; - $sql .= " AND d.statut = 1 AND (d.datefin >= '" . $this->db->idate($now) . "' OR t.subscription = 0)"; - $sql .= " AND t.rowid = d.fk_adherent_type"; - $sql .= " GROUP BY d.fk_adherent_type"; - - dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $num2 = $this->db->num_rows($result); - $i = 0; - while ($i < $num2) { - $objp = $this->db->fetch_object($result); - $MembersUpToDate[$objp->fk_adherent_type] = $objp->somme; - $i++; - } - $this->db->free($result); - } - // Members pendding (Waiting for first subscription) - $sql = "SELECT count(*) as somme , d.fk_adherent_type"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "adherent_type as t"; - $sql .= " WHERE d.entity IN (" . getEntity('adherent') . ")"; - $sql .= " AND d.statut = 1 AND (d.datefin IS NULL AND t.subscription = 1)"; - $sql .= " AND t.rowid = d.fk_adherent_type"; - $sql .= " GROUP BY d.fk_adherent_type"; - - dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $num2 = $this->db->num_rows($result); - $i = 0; - while ($i < $num2) { - $objp = $this->db->fetch_object($result); - $MembersPending[$objp->fk_adherent_type] = $objp->somme; - $i++; - } - $this->db->free($result); - } - + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; + $stats = new AdherentStats($this->db, $user->socid, $user->id); + // Show array + $sumMembers = $stats->countMembersByTypeAndStatus($numberyears); + if ($sumMembers) { $line = 0; $this->info_box_contents[$line][] = array( 'td' => 'class=""', 'text' => '', ); - // Draft + // Members Status To Valid $labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); - // Pending (Waiting for first subscription) + // Waiting for subscription $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, 0, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', - 'text' => $labelstatus + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus, ); // Up to date - $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() + 86400, 1); + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, $now + 86400, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus, ); // Expired - $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() - 86400, 1); + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, $now - 86400, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); // Excluded $labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); // Resiliated $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); + // Total row + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($langs->trans("Total")).'"', + 'text' => $langs->trans("Total") + ); $line++; + foreach ($sumMembers as $key => $data) { + $adhtype = new AdherentType($this->db); + $adhtype->id = $key; - foreach ($AdherentType as $key => $adhtype) { - $SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0; - $SumPending += isset($MembersPending[$key]) ? $MembersPending[$key] : 0; - $SumExpired += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) - (isset($MembersPending[$key]) ? $MembersPending[$key] : 0): 0; - $SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0; - $SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0; - $SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + if ($key=='total') { + break; + } + $adhtype->label = $data['label']; + $AdherentType[$key] = $adhtype; $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', @@ -250,39 +165,43 @@ class box_members_by_type extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersToValidate[$key]) && $MembersToValidate[$key] > 0 ? $MembersToValidate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), + 'text' => (isset($data['members_draft']) && $data['members_draft'] > 0 ? $data['members_draft'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersPending[$key]) && $MembersPending[$key] > 0 ? $MembersPending[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3), + 'text' => (isset($data['members_pending']) && $data['members_pending'] > 0 ? $data['members_pending'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersUpToDate[$key]) && $MembersUpToDate[$key] > 0 ? $MembersUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), + 'text' => (isset($data['members_uptodate']) && $data['members_uptodate'] > 0 ? $data['members_uptodate'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 0, 0, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'text' => (isset($data['members_expired']) && $data['members_expired'] > 0 ? $data['members_expired'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersExcluded[$key]) && $MembersExcluded[$key] > 0 ? $MembersExcluded[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, $now, 3), + 'text' => (isset($data['members_excluded']) && $data['members_excluded'] > 0 ? $data['members_excluded'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, $now, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersResiliated[$key]) && $MembersResiliated[$key] > 0 ? $MembersResiliated[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), + 'text' => (isset($data['members_resiliated']) && $data['members_resiliated'] > 0 ? $data['members_resiliated'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['total_adhtype']) && $data['total_adhtype'] > 0 ? $data['total_adhtype'] : ''), 'asis' => 1, ); - $line++; } - if ($num == 0) { + if (count($sumMembers) == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'colspan="7" class="center"', 'text' => $langs->trans("NoRecordedMembersByType") @@ -295,32 +214,37 @@ class box_members_by_type extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumToValidate.' '.$staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), + 'text' => $sumMembers['total']['members_draft'].' '.$staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumPending.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3), + 'text' => $sumMembers['total']['members_pending'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumUpToDate.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), + 'text' => $sumMembers['total']['members_uptodate'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 0, 0, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumExpired.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'text' => $sumMembers['total']['members_expired'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumExcluded.' '.$staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, 0, 3), + 'text' => $sumMembers['total']['members_excluded'].' '.$staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, 0, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumResiliated.' '.$staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), + 'text' => $sumMembers['total']['members_resiliated'].' '.$staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['all'], 'asis' => 1 ); } diff --git a/htdocs/core/boxes/box_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php index 52bc75e1fd1..5c6082f1032 100644 --- a/htdocs/core/boxes/box_members_last_modified.php +++ b/htdocs/core/boxes/box_members_last_modified.php @@ -67,7 +67,7 @@ class box_members_last_modified extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = !(isModEnabled('adherent') && $user->rights->adherent->lire); + $this->hidden = !(isModEnabled('adherent') && $user->hasRight('adherent', 'lire')); } /** diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php index b5472b979a2..e7f1d99137d 100644 --- a/htdocs/core/boxes/box_members_last_subscriptions.php +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -67,7 +67,7 @@ class box_members_last_subscriptions extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = !(isModEnabled('adherent') && $user->rights->adherent->lire); + $this->hidden = !(isModEnabled('adherent') && $user->hasRight('adherent', 'lire')); } /** @@ -146,9 +146,10 @@ class box_members_last_subscriptions extends ModeleBoxes 'asis' => 1, ); + $daterange = get_date_range($this->db->jdate($obj->date_start), $this->db->jdate($obj->date_end)); $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => get_date_range($this->db->jdate($obj->date_start), $this->db->jdate($obj->date_end)), + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone" title="'.dol_escape_htmltag($daterange).'"', + 'text' => $daterange, ); $this->info_box_contents[$line][] = array( @@ -157,7 +158,7 @@ class box_members_last_subscriptions extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax150 maxwidth150onsmartphone"', + 'td' => 'class="right tdoverflowmax150 maxwidth150onsmartphone" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($obj->datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($this->db->jdate($obj->datem ? $obj->datem : $obj->datec), 'dayhour', 'tzuserrel'), ); @@ -167,7 +168,7 @@ class box_members_last_subscriptions extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedCustomers"), + 'text'=> ''.$langs->trans("NoRecordedMembers").'', ); } diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index 6c3a8b54f7a..fe406ad29a3 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -67,7 +67,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = !(isModEnabled('adherent') && $user->rights->adherent->lire); + $this->hidden = !(isModEnabled('adherent') && $user->hasRight('adherent', 'lire')); } /** @@ -191,8 +191,8 @@ class box_members_subscriptions_by_year extends ModeleBoxes if ($num == 0) { $this->info_box_contents[$line][0] = array( - 'td' => 'colspan="4"', - 'text' => $langs->trans("NoRecordedMembers"), + 'td' => 'colspan="4" class="center"', + 'text' => ''.$langs->trans("NoRecordedMembers").'', ); } else { $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 1208ab4f95d..c6dd0f5d4ad 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -178,7 +178,7 @@ class box_project extends ModeleBoxes $i++; } if ($max < $num) { - $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $this->info_box_contents[$i][] = array('td' => 'colspan="6"', 'text' => '...'); $i++; } } @@ -207,6 +207,10 @@ class box_project extends ModeleBoxes 'td' => 'class="liste_total"', 'text' => " ", ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); } /** diff --git a/htdocs/core/boxes/box_project_opportunities.php b/htdocs/core/boxes/box_project_opportunities.php index c1ff71b2088..733e57db831 100644 --- a/htdocs/core/boxes/box_project_opportunities.php +++ b/htdocs/core/boxes/box_project_opportunities.php @@ -167,7 +167,7 @@ class box_project_opportunities extends ModeleBoxes $i++; } if ($max < $num) { - $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $this->info_box_contents[$i][] = array('td' => 'colspan="6"', 'text' => '...'); $i++; } } @@ -196,6 +196,10 @@ class box_project_opportunities extends ModeleBoxes 'td' => 'class="liste_total"', 'text' => " ", ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); } /** diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index 915884d6f43..f0868036e9d 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -63,7 +63,7 @@ class box_scheduled_jobs extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->hasRight('service', 'lire') && $user->hasRight('contrat', 'lire')); + $this->hidden = !($user->hasRight('cron', 'read')); } /** @@ -79,7 +79,7 @@ class box_scheduled_jobs extends ModeleBoxes $langs->load("cron"); $this->info_box_head = array('text' => $langs->trans("BoxScheduledJobs", $max)); - if ($user->rights->cron->read) { + if ($user->hasRight('cron', 'read')) { include_once DOL_DOCUMENT_ROOT . '/cron/class/cronjob.class.php'; $cronstatic = new Cronjob($this->db); $resultarray = array(); diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 1c18264618d..03020da8de5 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -213,7 +213,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box $out .= "\n\n"; - $out .= '
'."\n"; + $out .= '
'."\n"; if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) { $out .= '
'."\n"; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 418ef0612ba..7b801a78cd0 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2019-2022 Frédéric France + * Copyright (C) 2019-2023 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 @@ -512,7 +512,7 @@ class CMailFile // Give the message a subject try { - $result = $this->message->setSubject($this->subject); + $this->message->setSubject($this->subject); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } @@ -557,6 +557,14 @@ class CMailFile } } + if (!empty($this->errors_to)) { + try { + $headers->addTextHeader('Errors-To', $this->getArrayAddress($this->errors_to)); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } + try { $this->message->setCharSet($conf->file->character_set_client); } catch (Exception $e) { @@ -1237,8 +1245,8 @@ class CMailFile $encoded = chunk_split(base64_encode($contents), 76, $this->eol); // 76 max is defined into http://tools.ietf.org/html/rfc2047 return $encoded; } else { - $this->error = "Error: Can't read file '".$sourcefile."' into _encode_file"; - dol_syslog("CMailFile::encode_file: ".$this->error, LOG_ERR); + $this->error = "Error in _encode_file() method: Can't read file '".$sourcefile."'"; + dol_syslog("CMailFile::_encode_file: ".$this->error, LOG_ERR); return -1; } } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index d93f25522ae..f23a26678fe 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -1001,6 +1001,7 @@ abstract class CommonInvoice extends CommonObject $this->db->begin(); // Create a prelevement_bon + require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; $bon = new BonPrelevement($this->db); if (!$error) { if (empty($obj->fk_prelevement_bons)) { diff --git a/htdocs/core/class/cregion.class.php b/htdocs/core/class/cregion.class.php new file mode 100644 index 00000000000..7c57e19033a --- /dev/null +++ b/htdocs/core/class/cregion.class.php @@ -0,0 +1,328 @@ + + * Copyright (C) 2007-2011 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/class/cregion.class.php + * \ingroup core + * \brief This file is a CRUD class file (Create/Read/Update/Delete) for c_regions dictionary + */ + +/** + * Class to manage dictionary Regions + */ +class Cregion +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); + + //public $element = 'cregion'; //!< Id that identify managed objects + //public $table_element = 'c_regions'; //!< Name of table without prefix where object is stored + + /** + * @var int ID + */ + public $id; + + public $code_region; + public $fk_pays; + + /** + * @var string Region name + */ + public $name; + + /** + * @var string Region chef lieu + */ + public $cheflieu; + + 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; + $error = 0; + + // Clean parameters + if (isset($this->code_region)) { + $this->code_region = trim($this->code_region); + } + if (isset($this->fk_pays)) { + $this->fk_pays = trim($this->fk_pays); + } + if (isset($this->nom)) { + $this->nom = trim($this->nom); + } + if (isset($this->cheflieu)) { + $this->cheflieu = trim($this->cheflieu); + } + if (isset($this->active)) { + $this->active = trim($this->active); + } + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = "INSERT INTO ".$this->db->prefix()."c_regions("; + $sql .= "rowid,"; + $sql .= "code_region,"; + $sql .= "fk_pays,"; + $sql .= "nom,"; + $sql .= "cheflieu,"; + $sql .= "active"; + $sql .= ") VALUES ("; + $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; + $sql .= " ".(!isset($this->code_region) ? 'NULL' : "'".$this->db->escape($this->code_region)."'").","; + $sql .= " ".(!isset($this->fk_pays) ? 'NULL' : "'".$this->db->escape($this->fk_pays)."'").","; + $sql .= " ".(!isset($this->name) ? 'NULL' : "'".$this->db->escape($this->name)."'").","; + $sql .= " ".(!isset($this->cheflieu) ? 'NULL' : "'".$this->db->escape($this->cheflieu)."'").","; + $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").""; + $sql .= ")"; + + $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(); + } + + if (!$error) { + $this->id = $this->db->last_insert_id($this->db->prefix()."c_regions"); + } + + // 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); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return $this->id; + } + } + + + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code_region Code + * @param string $fk_pays Country Id + * @return int >0 if OK, 0 if not found, <0 if KO + */ + public function fetch($id, $code_region = '', $fk_pays = '') + { + $sql = "SELECT"; + $sql .= " t.rowid,"; + $sql .= " t.code_region,"; + $sql .= " t.fk_pays,"; + $sql .= " t.nom,"; + $sql .= " t.cheflieu,"; + $sql .= " t.active"; + $sql .= " FROM ".$this->db->prefix()."c_regions as t"; + if ($id) { + $sql .= " WHERE t.rowid = ".((int) $id); + } elseif ($code_region) { + $sql .= " WHERE t.code_region = '".$this->db->escape(strtoupper($code_region))."'"; + } elseif ($fk_pays) { + $sql .= " WHERE t.fk_pays = '".$this->db->escape(strtoupper($fk_pays))."'"; + } + + 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); + + if ($obj) { + $this->id = $obj->rowid; + $this->code_region = $obj->code_region; + $this->fk_pays = $obj->fk_pays; + $this->name = $obj->nom; + $this->cheflieu = $obj->cheflieu; + $this->active = $obj->active; + } + + $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; + $error = 0; + + // Clean parameters + if (isset($this->code_region)) { + $this->code_region = trim($this->code_region); + } + if (isset($this->fk_pays)) { + $this->fk_pays = trim($this->fk_pays); + } + if (isset($this->name)) { + $this->name = trim($this->name); + } + if (isset($this->cheflieu)) { + $this->cheflieu = trim($this->cheflieu); + } + if (isset($this->active)) { + $this->active = trim($this->active); + } + + + // Check parameters + // Put here code to add control on parameters values + + // Update request + $sql = "UPDATE ".$this->db->prefix()."c_regions SET"; + $sql .= " code_region=".(isset($this->code_region) ? "'".$this->db->escape($this->code_region)."'" : "null").","; + $sql .= " fk_pays=".(isset($this->fk_pays) ? "'".$this->db->escape($this->fk_pays)."'" : "null").","; + $sql .= " nom=".(isset($this->name) ? "'".$this->db->escape($this->name)."'" : "null").","; + $sql .= " cheflieu=".(isset($this->cheflieu) ? "'".$this->db->escape($this->cheflieu)."'" : "null").","; + $sql .= " active=".(isset($this->active) ? $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); + 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; + } + } + + + /** + * 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 ".$this->db->prefix()."c_regions"; + $sql .= " WHERE rowid=".((int) $this->id); + + $this->db->begin(); + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } + + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } + + /** + * 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->name); + } +} diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5c44e140be9..b110f0a4a16 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2306,6 +2306,11 @@ class ExtraFields $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_key = $value_arr; } + } elseif (in_array($key_type, array('html'))) { + if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { + continue; // Value was not provided, we should not set it. + } + $value_key = dol_htmlcleanlastbr(GETPOST($keysuffix."options_".$key.$keyprefix, 'restricthtml')); } else { if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { continue; // Value was not provided, we should not set it. diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 426dfbb60ef..27a62cfe2d2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7728,7 +7728,7 @@ class Form $out = ''; $outarray = array(); - $selectFields = " p.rowid, p.ref, p.firstname, p.lastname"; + $selectFields = " p.rowid, p.ref, p.firstname, p.lastname, p.fk_adherent_type"; $sql = "SELECT "; $sql .= $selectFields; @@ -7770,7 +7770,7 @@ class Form if (!$forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT); + $out .= ajax_combobox($htmlname, $events, !empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT) ? $conf->global->PROJECT_USE_SEARCH_TO_SELECT : ''); } $out .= ' +
  • '.$listoffieldsforselection.' diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 3437d4fa050..965c6c4f13f 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -454,6 +454,7 @@ class FormAccounting extends Form public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'minwidth100 maxwidth300 maxwidthonsmartphone', $usecache = '', $labelhtmlname = '') { // phpcs:enable + global $conf; $aux_account = array(); diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 737e61fa4b1..c983d503126 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -31,7 +31,7 @@ * Only common components are here. */ -require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; /** @@ -56,13 +56,13 @@ class FormCompany extends Form $effs = array(); $sql = "SELECT id, code, libelle"; - $sql .= " FROM ".$this->db->prefix()."c_typent"; - $sql .= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id) ? '0' : $mysoc->country_id).")"; + $sql .= " FROM " . $this->db->prefix() . "c_typent"; + $sql .= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = " . (empty($mysoc->country_id) ? '0' : $mysoc->country_id) . ")"; if ($filter) { - $sql .= " ".$filter; + $sql .= " " . $filter; } $sql .= " ORDER by position, id"; - dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); + dol_syslog(get_class($this) . '::typent_array', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -105,13 +105,13 @@ class FormCompany extends Form $effs = array(); $sql = "SELECT id, code, libelle"; - $sql .= " FROM ".$this->db->prefix()."c_effectif"; + $sql .= " FROM " . $this->db->prefix() . "c_effectif"; $sql .= " WHERE active = 1"; if ($filter) { - $sql .= " ".$filter; + $sql .= " " . $filter; } $sql .= " ORDER BY id ASC"; - dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); + dol_syslog(get_class($this) . '::effectif_array', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -149,13 +149,13 @@ class FormCompany extends Form // phpcs:enable global $user, $langs; - print '
    '; + print ''; print ''; - print ''; + print ''; - dol_syslog(get_class($this).'::form_prospect_level', LOG_DEBUG); + dol_syslog(get_class($this) . '::form_prospect_level', LOG_DEBUG); $sql = "SELECT code, label"; - $sql .= " FROM ".$this->db->prefix()."c_prospectlevel"; + $sql .= " FROM " . $this->db->prefix() . "c_prospectlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); @@ -181,9 +181,9 @@ class FormCompany extends Form dol_print_error($this->db); } if (!empty($htmlname) && $user->admin) { - print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - print ''; + print ''; print ''; } @@ -200,13 +200,13 @@ class FormCompany extends Form { global $user, $langs; - print '
    '; + print ''; print ''; - print ''; + print ''; dol_syslog(__METHOD__, LOG_DEBUG); $sql = "SELECT code, label"; - $sql .= " FROM ".$this->db->prefix()."c_prospectcontactlevel"; + $sql .= " FROM " . $this->db->prefix() . "c_prospectcontactlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); @@ -232,9 +232,9 @@ class FormCompany extends Form dol_print_error($this->db); } if (!empty($htmlname) && $user->admin) { - print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - print ''; + print ''; print ''; } @@ -275,7 +275,7 @@ class FormCompany extends Form // phpcs:enable global $conf, $langs, $user; - dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG); + dol_syslog(get_class($this) . "::select_departement selected=" . $selected . ", country_codeid=" . $country_codeid, LOG_DEBUG); $langs->load("dict"); @@ -283,28 +283,28 @@ class FormCompany extends Form // Serch departements/cantons/province active d'une region et pays actif $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM"; - $sql .= " ".$this->db->prefix()."c_departements as d, ".$this->db->prefix()."c_regions as r,".$this->db->prefix()."c_country as c"; + $sql .= " " . $this->db->prefix() . "c_departements as d, " . $this->db->prefix() . "c_regions as r," . $this->db->prefix() . "c_country as c"; $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; if ($country_codeid && is_numeric($country_codeid)) { - $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; + $sql .= " AND c.rowid = '" . $this->db->escape($country_codeid) . "'"; } if ($country_codeid && !is_numeric($country_codeid)) { - $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; + $sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'"; } $sql .= " ORDER BY c.code, d.code_departement"; $result = $this->db->query($sql); if ($result) { if (!empty($htmlname)) { - $out .= ''; } if ($country_codeid) { $out .= ''; } $num = $this->db->num_rows($result); $i = 0; - dol_syslog(get_class($this)."::select_departement num=".$num, LOG_DEBUG); + dol_syslog(get_class($this) . "::select_departement num=" . $num, LOG_DEBUG); if ($num) { $country = ''; while ($i < $num) { @@ -315,28 +315,30 @@ class FormCompany extends Form if (!$country || $country != $obj->country) { // Show break if we are in list with multiple countries if (!$country_codeid && $obj->country_code) { - $out .= '\n"; + $out .= '\n"; $country = $obj->country; } } if (!empty($selected) && $selected == $obj->rowid) { - $out .= '\n"; + $key = $langs->trans("Country" . strtoupper($obj->country_code)); + $valuetoshow = ($key != "Country" . strtoupper($obj->country_code)) ? $obj->country_code . " - " . $key : $obj->country; + print '\n"; $country = $obj->country; } if ($selected > 0 && $selected == $obj->code) { - print ''; + print ''; } else { - print ''; + print ''; } } $i++; @@ -444,13 +446,13 @@ class FormCompany extends Form $out = ''; - $sql = "SELECT rowid, code, label, active FROM ".$this->db->prefix()."c_civility"; + $sql = "SELECT rowid, code, label, active FROM " . $this->db->prefix() . "c_civility"; $sql .= " WHERE active = 1"; dol_syslog("Form::select_civility", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $out .= ''; $out .= ''; $num = $this->db->num_rows($resql); $i = 0; @@ -458,12 +460,12 @@ class FormCompany extends Form while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($selected == $obj->code) { - $out .= ''; $i++; } @@ -475,7 +477,7 @@ class FormCompany extends Form if ($addjscombo) { // Enhance with select2 - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); } } else { @@ -525,22 +527,22 @@ class FormCompany extends Form // On recherche les formes juridiques actives des pays actifs $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code"; - $sql .= " FROM ".$this->db->prefix()."c_forme_juridique as f, ".$this->db->prefix()."c_country as c"; + $sql .= " FROM " . $this->db->prefix() . "c_forme_juridique as f, " . $this->db->prefix() . "c_country as c"; $sql .= " WHERE f.fk_pays=c.rowid"; $sql .= " AND f.active = 1 AND c.active = 1"; if ($country_codeid) { - $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; + $sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'"; } if ($filter) { - $sql .= " ".$filter; + $sql .= " " . $filter; } $sql .= " ORDER BY c.code"; - dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); + dol_syslog(get_class($this) . "::select_juridicalstatus", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $out .= '
    '; - $out .= ''; if ($country_codeid) { $out .= ''; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. } @@ -554,31 +556,31 @@ class FormCompany extends Form $obj = $this->db->fetch_object($resql); if ($obj->code) { // We exclude empty line, we will add it later - $labelcountry = (($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); - $labeljs = (($langs->trans("JuridicalStatus".$obj->code) != "JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label != '-' ? $obj->label : '')); // $obj->label is already in output charset (converted by database driver) - $arraydata[$obj->code] = array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); + $labelcountry = (($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code) ? $langs->trans("Country" . $obj->country_code) : $obj->country); + $labeljs = (($langs->trans("JuridicalStatus" . $obj->code) != "JuridicalStatus" . $obj->code) ? $langs->trans("JuridicalStatus" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); // $obj->label is already in output charset (converted by database driver) + $arraydata[$obj->code] = array('code' => $obj->code, 'label' => $labeljs, 'label_sort' => $labelcountry . '_' . $labeljs, 'country_code' => $obj->country_code, 'country' => $labelcountry); } $i++; } $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC'); if (empty($country_codeid)) { // Introduce empty value (if $country_codeid not empty, empty value was already added) - $arraydata[0] = array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); + $arraydata[0] = array('code' => 0, 'label' => '', 'label_sort' => '_', 'country_code' => '', 'country' => ''); } foreach ($arraydata as $key => $val) { if (!$country || $country != $val['country']) { // Show break when we are in multi country mode if (empty($country_codeid) && $val['country_code']) { - $out .= '\n"; + $out .= '\n"; $country = $val['country']; } } if ($selected > 0 && $selected == $val['code']) { - $out .= '
    '; @@ -645,13 +647,13 @@ class FormCompany extends Form $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); if (count($events)) { // If there is some ajax events to run once selection is done, we add code here to run events - print ''; } - print "\n".''."\n"; - print ''; - print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT.'/societe/ajax/ajaxcompanies.php', '', $minLength, 0); + print "\n" . '' . "\n"; + print ''; + print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT . '/societe/ajax/ajaxcompanies.php', '', $minLength, 0); return $socid; } else { // Search to list thirdparties @@ -709,14 +711,14 @@ class FormCompany extends Form $sql .= ", s.address, s.zip, s.town"; $sql .= ", dictp.code as country_code"; } - $sql .= " FROM ".$this->db->prefix()."societe as s"; + $sql .= " FROM " . $this->db->prefix() . "societe as s"; if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { - $sql .= " LEFT JOIN ".$this->db->prefix()."c_country as dictp ON dictp.rowid = s.fk_pays"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "c_country as dictp ON dictp.rowid = s.fk_pays"; } - $sql .= " WHERE s.entity IN (".getEntity('societe').")"; + $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")"; // For ajax search we limit here. For combo list, we limit later if (is_array($limitto) && count($limitto)) { - $sql .= " AND s.rowid IN (".$this->db->sanitize(join(',', $limitto)).")"; + $sql .= " AND s.rowid IN (" . $this->db->sanitize(join(',', $limitto)) . ")"; } // Add where from hooks $parameters = array(); @@ -726,10 +728,10 @@ class FormCompany extends Form $resql = $this->db->query($sql); if ($resql) { - print ''; + $out .= '"; if ($user->admin && empty($forcehidetooltip)) { - $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } $out .= ajax_combobox($htmlname); @@ -837,9 +839,9 @@ class FormCompany extends Form if ($rendermode === 'view') { $toprint = array(); foreach ($contact->roles as $key => $val) { - $toprint[] = '
  • '.$val['label'].'
  • '; + $toprint[] = '
  • ' . $val['label'] . '
  • '; } - return '
      '.implode(' ', $toprint).'
    '; + return '
      ' . implode(' ', $toprint) . '
    '; } if ($rendermode === 'edit') { @@ -885,14 +887,14 @@ class FormCompany extends Form $size = ''; if (!empty($fieldsize)) { - $size = 'size="'.$fieldsize.'"'; + $size = 'size="' . $fieldsize . '"'; } if ($conf->use_javascript_ajax && empty($disableautocomplete)) { - $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; + $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT . '/core/ajax/ziptown.php') . "\n"; $moreattrib .= ' autocomplete="off"'; } - $out .= ''."\n"; + $out .= '' . "\n"; return $out; } @@ -965,10 +967,10 @@ class FormCompany extends Form $out = ''; // Execute hook getInputIdProf to complete or replace $out - $parameters = array('formlength'=>$formlength, 'selected'=>$preselected, 'idprof'=>$idprof, 'htmlname'=>$htmlname, 'country_code'=>$country_code); + $parameters = array('formlength' => $formlength, 'selected' => $preselected, 'idprof' => $idprof, 'htmlname' => $htmlname, 'country_code' => $country_code); $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters); if (empty($reshook)) { - $out .= ''; + $out .= ''; } $out .= $hookmanager->resPrint; @@ -999,9 +1001,9 @@ class FormCompany extends Form $i = 0; while ($i < $nbvalues) { if ($selected == $valors[$i]) { - print ''; @@ -1027,10 +1029,10 @@ class FormCompany extends Form { global $conf, $langs; if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && !isModEnabled('fournisseur')) { - return '' ; + return ''; } - $out = ''; if ($typeinput == 'form') { if ($allowempty || ($selected == '' || $selected == '-1')) { $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } - $out .= ''; + $out .= ''; } elseif ($typeinput == 'list') { - $out .= ''; + $out .= ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } if (isModEnabled("fournisseur")) { - $out .= ''; + $out .= ''; } - $out .= ''; + $out .= ''; } elseif ($typeinput == 'admin') { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } } $out .= ''; @@ -1094,12 +1096,12 @@ class FormCompany extends Form $out = ''; if ($htmlname != "none") { - $out .= '
    '; + $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. $out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1); - $out .= ''; + $out .= ''; $out .= ''; } else { if ($selected > 0) { @@ -1117,4 +1119,57 @@ class FormCompany extends Form print $out; } } + + /** + * Output html select to select prospect status + * + * @param string $htmlname Name of HTML select + * @param Societe|null $prospectstatic Prospect object + * @param int $statusprospect status of prospect + * @param int $idprospect id of prospect + * @param string $mode select if we want activate de html part or js + * @return void + */ + public function selectProspectStatus($htmlname, Societe $prospectstatic, $statusprospect, $idprospect, $mode = "html") + { + global $langs; + + if ($mode === "html") { + //print $prospectstatic->LibProspCommStatut($statusprospect, 2, $prospectstatic->cacheprospectstatus[$statusprospect]['label'], $prospectstatic->cacheprospectstatus[$statusprospect]['picto']); + print img_action('', $prospectstatic->cacheprospectstatus[$statusprospect]['code'], $prospectstatic->cacheprospectstatus[$statusprospect]['picto'], 'class="inline-block valignmiddle paddingright"'); + print ''; + print ajax_combobox($htmlname.$idprospect); + } elseif ($mode === "js") { + print ''; + } + } } diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index c763bc1a04e..f4486bfb2b5 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -82,7 +82,7 @@ class FormContract if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { $sql .= " AND (c.fk_soc=".((int) $socid)." OR c.fk_soc IS NULL)"; } elseif ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { - $sql .= " AND (c.fk_soc IN (".$this->db->sanitize($socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY).") "; + $sql .= " AND (c.fk_soc IN (".$this->db->sanitize(((int) $socid).",".((int) $conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)).")"; $sql .= " OR c.fk_soc IS NULL)"; } } diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 2257e563865..dab47e9ce52 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -341,7 +341,8 @@ class FormTicket if ($public) { $filter = 'public=1'; } - $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', $filter, 2, 1, 0, 0, 'minwidth200'); + $selected = (GETPOST('category_code') ? GETPOST('category_code') : $this->category_code); + $this->selectGroupTickets($selected, 'category_code', $filter, 2, 1, 0, 0, 'minwidth200'); print ''; // Severity => Priority @@ -807,8 +808,10 @@ class FormTicket } $outputlangs->load("ticket"); + $publicgroups = ($filtertype == 'public=1' || $filtertype == '(public:=:1)'); + $ticketstat = new Ticket($this->db); - $ticketstat->loadCacheCategoriesTickets(); + $ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1); // get list of active ticket groups if ($use_multilevel <= 0) { print ''; print ''; print ''; @@ -1544,6 +1553,14 @@ class FormTicket $out .= ''."\n"; $out .= ''; + } + print "\n"; } } diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index c5694eeae94..7133167b4dd 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -231,6 +231,22 @@ class SMTPs // @CHANGE LDR public $log = ''; public $lastretval = ''; + + /** + * @var resource + */ + public $socket; + + /** + * @var int + */ + public $errno; + + /** + * @var string + */ + public $errstr; + private $_errorsTo = ''; private $_deliveryReceipt = 0; private $_trackId = ''; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 68906fbf481..cbbe6f61a8a 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -238,6 +238,9 @@ class DoliDBMysqli extends DoliDB // return mysqli::real_connect($host, $user, $pass, $db, $port); $tmp = false; try { + if (!class_exists('mysqli')) { + dol_print_error('', 'Driver mysqli for PHP not available'); + } $tmp = new mysqli($host, $login, $passwd, $name, $port); } catch (Exception $e) { dol_syslog(get_class($this)."::connect failed", LOG_DEBUG); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 0fc2d733a38..83fdc6bc043 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -53,7 +53,7 @@ function societe_prepare_head(Societe $object) $h++; if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) { - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->hasRight('societe', 'contact', 'lire')) { //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); $nbContact = 0; // Enable caching of thirdrparty count Contacts @@ -2367,9 +2367,9 @@ function htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage = 0, $suffi $line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; } - print ''."\n"; + print ''."\n"; - print '
    '."\n"; + print '
    '."\n"; print '
    '; if ($addformmessage) { print ''; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 7a5e69232d4..5def472258c 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -3259,7 +3259,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $partsofdirinoriginalfile = explode('/', $original_file); if (!empty($partsofdirinoriginalfile[1])) { // If original_file is xxx/filename (xxx is a part we will use) $partofdirinoriginalfile = $partsofdirinoriginalfile[0]; - if ($partofdirinoriginalfile && !empty($fuser->rights->$modulepart->$partofdirinoriginalfile) && ($fuser->rights->$modulepart->$partofdirinoriginalfile->{$lire} || $fuser->rights->$modulepart->$partofdirinoriginalfile->{$read})) { + if ($partofdirinoriginalfile && ($fuser->hasRight($modulepart, $partofdirinoriginalfile, 'lire') || $fuser->hasRight($modulepart, $partofdirinoriginalfile, 'read'))) { $accessallowed = 1; } } @@ -3353,6 +3353,17 @@ function dol_readcachefile($directory, $filename) return $object; } +/** + * Return the relative dirname (relative to DOL_DATA_ROOT) of a full path string. + * + * @param string $pathfile Full path of a file + * @return string Path of file relative to DOL_DATA_ROOT + */ +function dirbasename($pathfile) +{ + return preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'\//', '', $pathfile); +} + /** * Function to get list of updated or modified files. @@ -3423,7 +3434,7 @@ function dragAndDropFileUpload($htmlname) $("#'.$htmlname.'").addClass("cssDragDropArea"); $(".cssDragDropArea").on("dragenter", function(ev) { // Entering drop area. Highlight area - console.log("We add class highlightDragDropArea") + console.log("dragAndDropFileUpload: We add class highlightDragDropArea") enterTargetDragDrop = ev.target; $(this).addClass("highlightDragDropArea"); $("#'.$htmlname.'Message").removeClass("hidden"); @@ -3433,7 +3444,7 @@ function dragAndDropFileUpload($htmlname) $(".cssDragDropArea").on("dragleave", function(ev) { // Going out of drop area. Remove Highlight if (enterTargetDragDrop == ev.target){ - console.log("We remove class highlightDragDropArea") + console.log("dragAndDropFileUpload: We remove class highlightDragDropArea") $("#'.$htmlname.'Message").addClass("hidden"); $(this).removeClass("highlightDragDropArea"); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a2b7f99e6f7..e35c9e86e3e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -14,7 +14,7 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018-2023 Frédéric France - * Copyright (C) 2019-2022 Thibault Foucart + * Copyright (C) 2019-2023 Thibault Foucart * Copyright (C) 2020 Open-Dsi * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2022 Anthony Berton @@ -952,7 +952,7 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options } } break; - case 'aZ09arobase': // great to sanitize objecttype parameter + case 'aZ09arobase': // great to sanitize $objecttype parameter if (!is_array($out)) { $out = trim($out); if (preg_match('/[^a-z0-9_\-\.@]+/i', $out)) { @@ -960,7 +960,7 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options } } break; - case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh + case 'aZ09comma': // great to sanitize $sortfield or $sortorder params that can be 't.abc,t.def_gh' if (!is_array($out)) { $out = trim($out); if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) { @@ -968,9 +968,6 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options } } break; - case 'nohtml': // No html - $out = dol_string_nohtmltag($out, 0); - break; case 'alpha': // No html and no ../ and " case 'alphanohtml': // Recommended for most scalar parameters and search parameters if (!is_array($out)) { @@ -1002,6 +999,9 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options } while ($oldstringtoclean != $out); } break; + case 'nohtml': // No html + $out = dol_string_nohtmltag($out, 0); + break; case 'restricthtml': // Recommended for most html textarea case 'restricthtmlnolink': case 'restricthtmlallowunvalid': @@ -1623,6 +1623,7 @@ function dol_strtolower($string, $encoding = "UTF-8") * @param string $string String to encode * @param string $encoding Character set encoding * @return string String converted + * @see dol_ucfirst(), dol_ucwords() */ function dol_strtoupper($string, $encoding = "UTF-8") { @@ -1639,6 +1640,7 @@ function dol_strtoupper($string, $encoding = "UTF-8") * @param string $string String to encode * @param string $encoding Character set encodign * @return string String converted + * @see dol_strtoupper(), dol_ucwords() */ function dol_ucfirst($string, $encoding = "UTF-8") { @@ -1650,11 +1652,12 @@ function dol_ucfirst($string, $encoding = "UTF-8") } /** - * Convert first character of all the words of a string to upper. Never use ucfirst because it does not works with UTF8 strings. + * Convert first character of all the words of a string to upper. * * @param string $string String to encode * @param string $encoding Character set encodign * @return string String converted + * @see dol_strtoupper(), dol_ucfirst() */ function dol_ucwords($string, $encoding = "UTF-8") { @@ -2340,14 +2343,14 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } } elseif ($object->element == 'product') { //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') '; - if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + if (!empty($conf->use_javascript_ajax) && $user->hasRight('produit', 'creer') && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlstatus .= ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { $morehtmlstatus .= ''.$object->getLibStatut(6, 0).''; } $morehtmlstatus .= '   '; //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') '; - if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + if (!empty($conf->use_javascript_ajax) && $user->hasRight('produit', 'creer') && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlstatus .= ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { $morehtmlstatus .= ''.$object->getLibStatut(6, 1).''; @@ -4499,9 +4502,10 @@ function img_picto_common($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0 * Example: picto.png if picto.png is stored into htdocs/theme/mytheme/img * Example: picto.png@mymodule if picto.png is stored into htdocs/mymodule/img * Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1) + * @param string $moreatt More attributes * @return string Return an img tag */ -function img_action($titlealt, $numaction, $picto = '') +function img_action($titlealt, $numaction, $picto = '', $moreatt = '') { global $langs; @@ -4530,7 +4534,7 @@ function img_action($titlealt, $numaction, $picto = '') $numaction = 0; } - return img_picto($titlealt, !empty($picto) ? $picto : 'stcomm'.$numaction.'.png'); + return img_picto($titlealt, (empty($picto) ? 'stcomm'.$numaction.'.png' : $picto), $moreatt); } /** @@ -7391,6 +7395,7 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = ' * @param string $pagecodefrom Pagecode stringtoencode is encoded * @param int $removelasteolbr 1=Remove last br or lasts \n (default), 0=Do nothing * @return string String encoded + * @see dolGetFirstLineOfText() */ function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UTF-8', $removelasteolbr = 1) { @@ -7716,7 +7721,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, '__USER_FULLNAME__' => (string) $user->getFullName($outputlangs), '__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user : '0'), '__USER_JOB__' => (string) $user->job, - '__USER_REMOTE_IP__' => (string) getUserRemoteIP() + '__USER_REMOTE_IP__' => (string) getUserRemoteIP(), + '__USER_VCARD_URL__' => (string) $user->getOnlineVirtualCardUrl('', 'external') )); } } @@ -8931,6 +8937,22 @@ function utf8_check($str) return true; } +/** + * Check if a string is in UTF8 + * + * @param string $str String to check + * @return boolean True if string is valid UTF8 string, false if corrupted + */ +function utf8_valid($str) +{ + /* 2 other methods to test if string is utf8 + $validUTF8 = mb_check_encoding($messagetext, 'UTF-8'); + $validUTF8b = ! (false === mb_detect_encoding($messagetext, 'UTF-8', true)); + */ + return preg_match('//u', $str) ? true : false; +} + + /** * Check if a string is in ASCII * @@ -12122,6 +12144,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $sql .= " a.percent as percent, 'action' as type,"; $sql .= " a.fk_element, a.elementtype,"; $sql .= " a.fk_contact,"; + $sql .= " a.email_from as msg_from,"; $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; if (is_object($filterobj) && get_class($filterobj) == 'Societe') { @@ -12321,6 +12344,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n 'userfirstname'=>$obj->user_firstname, 'userlastname'=>$obj->user_lastname, 'userphoto'=>$obj->user_photo, + 'msg_from'=>$obj->msg_from, 'contact_id'=>$obj->fk_contact, 'socpeopleassigned' => $contactaction->socpeopleassigned, @@ -12384,6 +12408,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $userstatic = new User($db); $contactstatic = new Contact($db); $userGetNomUrlCache = array(); + $contactGetNomUrlCache = array(); $out .= '
    '; $out .= '
    '; @@ -12545,6 +12570,15 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $userGetNomUrlCache[$histo[$key]['userid']] = $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', ''); } $out .= $userGetNomUrlCache[$histo[$key]['userid']]; + } elseif (!empty($histo[$key]['msg_from']) && $actionstatic->code == 'TICKET_MSG') { + if (!isset($contactGetNomUrlCache[$histo[$key]['msg_from']])) { + if ($contactstatic->fetch(0, null, '', $histo[$key]['msg_from']) > 0) { + $contactGetNomUrlCache[$histo[$key]['msg_from']] = $contactstatic->getNomUrl(-1, '', 16); + } else { + $contactGetNomUrlCache[$histo[$key]['msg_from']] = $histo[$key]['msg_from']; + } + } + $out .= $contactGetNomUrlCache[$histo[$key]['msg_from']]; } $out .= '
    '; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 4a8cb27cdef..ce6a76e207e 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1280,7 +1280,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $counter = 0; $sql = "SELECT MAX(".$sqlstring.") as val"; $sql .= " FROM ".MAIN_DB_PREFIX.$table; - $sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike)."'"; + $sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike) . (!empty($conf->global->SEARCH_FOR_NEXT_VAL_ON_START_ONLY) ? "%" : "") . "'"; $sql .= " AND ".$field." NOT LIKE '(PROV%)'"; // To ensure that all variables within the MAX() brackets are integers @@ -1346,7 +1346,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $ref = ''; $sql = "SELECT ".$field." as ref"; $sql .= " FROM ".MAIN_DB_PREFIX.$table; - $sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike)."'"; + $sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike) . (!empty($conf->global->SEARCH_FOR_NEXT_VAL_ON_START_ONLY) ? "%" : "") . "'"; $sql .= " AND ".$field." NOT LIKE '%PROV%'"; if ($bentityon) { // only if entity enable $sql .= " AND entity IN (".getEntity($sharetable).")"; @@ -1408,7 +1408,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskrefclient_sql = "SELECT MAX(".$maskrefclient_sqlstring.") as val"; $maskrefclient_sql .= " FROM ".MAIN_DB_PREFIX.$table; //$sql.= " WHERE ".$field." not like '(%'"; - $maskrefclient_sql .= " WHERE ".$field." LIKE '".$db->escape($maskrefclient_maskLike)."'"; + $maskrefclient_sql .= " WHERE ".$field." LIKE '".$db->escape($maskrefclient_maskLike) . (!empty($conf->global->SEARCH_FOR_NEXT_VAL_ON_START_ONLY) ? "%" : "") . "'"; if ($bentityon) { // only if entity enable $maskrefclient_sql .= " AND entity IN (".getEntity($sharetable).")"; } elseif (!empty($forceentity)) { diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 4371f55d0c5..67c661dbd93 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2547,11 +2547,12 @@ function pdf_getSizeForImage($realpath) * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @return string Return total of line excl tax + * @return float Return total of line excl tax */ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = 0) { global $conf, $hookmanager; + $sign = 1; if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { $sign = -1; @@ -2574,8 +2575,12 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = $action = ''; - if ($hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action) > 0) { - return $hookmanager->resPrint; // Note that $action and $object may have been modified by some hooks + if ($hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action) > 0) { // Note that $action and $object may have been modified by some hooks + if (isset($hookmanager->resArray['linetotalremise'])) { + return $hookmanager->resArray['linetotalremise']; + } else { + return (float) $hookmanager->resPrint; // For backward compatibility + } } } @@ -2583,5 +2588,5 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht); } } - return ''; + return 0; } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 408f661e2b9..aedd01805dc 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -130,7 +130,7 @@ function product_prepare_head($object) } if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { // If physical product we can stock (or service with option) - if (isModEnabled('stock') && $user->rights->stock->lire) { + if (isModEnabled('stock') && $user->hasRight('stock', 'lire')) { $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$object->id; $head[$h][1] = $langs->trans("Stock"); $head[$h][2] = 'stock'; @@ -457,7 +457,7 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier proposals - if (isModEnabled('supplier_proposal') && $user->rights->supplier_proposal->lire) { + if (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire')) { $nblines++; $ret = $product->load_stats_proposal_supplier($socid); if ($ret < 0) { @@ -495,7 +495,7 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier orders - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire)) { + if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire'))) { $nblines++; $ret = $product->load_stats_commande_fournisseur($socid); if ($ret < 0) { @@ -552,7 +552,7 @@ function show_stats_for_company($product, $socid) print ''; } // Supplier invoices - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)) { + if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) { $nblines++; $ret = $product->load_stats_facture_fournisseur($socid); if ($ret < 0) { @@ -592,7 +592,7 @@ function show_stats_for_company($product, $socid) } // BOM - if (isModEnabled('bom') && $user->rights->bom->read) { + if (isModEnabled('bom') && $user->hasRight('bom', 'read')) { $nblines++; $ret = $product->load_stats_bom($socid); if ($ret < 0) { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index dfc4e45a447..b95253bf040 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -456,6 +456,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', if ($featureforlistofmodule == 'produit') { $featureforlistofmodule = 'product'; } + if ($featureforlistofmodule == 'supplier_proposal') { + $featureforlistofmodule = 'supplierproposal'; + } if (!empty($user->socid) && !empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules)) { // If limits on modules for external users, module must be into list of modules for external users $readok = 0; $nbko++; @@ -845,10 +848,13 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $dbtablename = 'actioncomm'; } + if ($feature == 'payment_sc') { + $feature = "chargesociales"; + } $checkonentitydone = 0; // Array to define rules of checks to do - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment'); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment','chargesociales'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for object Societe $checkother = array('agenda', 'contact', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 9b65bf4d877..25967efe057 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -65,11 +65,12 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes } $sql .= ") AND ".$entitycol." IN (0,".($entity ? ((int) $entity) : 1).")"; $sql .= " AND statut = 1"; - // Note: Test on validity is done later // Order is required to firstly found the user into entity, then the superadmin. // For the case (TODO: we must avoid that) a user has renamed its login with same value than a user in entity 0. $sql .= " ORDER BY entity DESC"; + // Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/core/login/functions_googleoauth.php b/htdocs/core/login/functions_googleoauth.php index 9e4bbe72c19..7130f9c6f2a 100644 --- a/htdocs/core/login/functions_googleoauth.php +++ b/htdocs/core/login/functions_googleoauth.php @@ -25,8 +25,6 @@ - - //include_once DOL_DOCUMENT_ROOT.'/core/class/openid.class.php'; @@ -41,34 +39,87 @@ */ function check_user_password_googleoauth($usertotest, $passwordtotest, $entitytotest) { - global $_POST, $db, $conf, $langs; + global $_POST, $conf; - dol_syslog("functions_googleoauth::check_user_password_googleoauth usertotest=".$usertotest); + dol_syslog("functions_googleoauth::check_user_password_googleoauth usertotest=".$usertotest." GETPOST('actionlogin')=".GETPOST('actionlogin')); $login = ''; // Get identity from user and redirect browser to Google OAuth Server - if (GETPOSTISSET('username')) { - /*$openid = new SimpleOpenID(); - $openid->SetIdentity(GETPOST('username')); - $protocol = ($conf->file->main_force_https ? 'https://' : 'http://'); - $openid->SetTrustRoot($protocol . $_SERVER["HTTP_HOST"]); - $openid->SetRequiredFields(array('email','fullname')); - $_SESSION['dol_entity'] = $_POST["entity"]; - //$openid->SetOptionalFields(array('dob','gender','postcode','country','language','timezone')); - if ($openid->sendDiscoveryRequestToGetXRDS()) - { - $openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]); // Send Response from OpenID server to this script - $openid->Redirect(); // This will redirect user to OpenID Server - } - else - { - $error = $openid->GetError(); - return false; - } - return false;*/ - } + if (GETPOST('actionlogin') == 'login') { + if (GETPOST('beforeoauthloginredirect')) { + // We post the form on the login page by clicking on the link to login using Google. + dol_syslog("We post the form on the login page by clicking on the link to login using Google"); + // We save data of form into a variable + $_SESSION['datafromloginform'] = array( + 'entity'=>GETPOST('entity', 'int'), + 'backtopage'=>GETPOST('backtopage'), + 'tz'=>GETPOST('tz'), + 'tzstring'=>GETPOST('tzstring'), + 'dst_observed'=>GETPOST('dst_observed'), + 'dst_first'=>GETPOST('dst_first'), + 'dst_second'=>GETPOST('dst_second'), + 'screenwidth'=>GETPOST('screenwidth'), + 'screenheight'=>GETPOST('screenheight'), + 'dol_hide_topmenu'=>GETPOST('dol_hide_topmenu'), + 'dol_hide_leftmenu'=>GETPOST('dol_hide_leftmenu'), + 'dol_optimize_smallscreen'=>GETPOST('dol_optimize_smallscreen'), + 'dol_no_mouse_hover'=>GETPOST('dol_no_mouse_hover'), + 'dol_use_jmobile'=>GETPOST('dol_use_jmobile') + ); + + // Make the redirect to the google_authcallback.php page to start the redirect to Google OAUTH. + + // Define $urlwithroot + //global $dolibarr_main_url_root; + //$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 + $urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + //$shortscope = 'userinfo_email,userinfo_profile'; + $shortscope = 'openid,email,profile'; // For openid connect + + $oauthstateanticsrf = bin2hex(random_bytes(128/8)); + $_SESSION['oauthstateanticsrf'] = $shortscope.'-'.$oauthstateanticsrf; + + $url = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode('forlogin-'.$shortscope.'-'.$oauthstateanticsrf).'&username='.urlencode($usertotest); + + // we go on oauth provider authorization page + header('Location: '.$url); + exit(); + } + + if (GETPOST('afteroauthloginreturn')) { + // We reach this code after a call of a redirect to the targeted page from the callback url page of Google OAUTH2 + dol_syslog("We reach the code after a call of a redirect to the targeted page from the callback url page of Google OAUTH2"); + + $tmparray = (empty($_SESSION['datafromloginform']) ? array() : $_SESSION['datafromloginform']); + + if (!empty($tmparray)) { + $_POST['entity'] = $tmparray['entity']; + $_POST['backtopage'] = $tmparray['backtopage']; + $_POST['tz'] = $tmparray['tz']; + $_POST['tzstring'] = $tmparray['tzstring']; + $_POST['dst_observed'] = $tmparray['dst_observed']; + $_POST['dst_first'] = $tmparray['dst_first']; + $_POST['dst_second'] = $tmparray['dst_second']; + $_POST['screenwidth'] = $tmparray['screenwidth']; + $_POST['screenwidth'] = $tmparray['screenwidth']; + $_POST['dol_hide_topmenu'] = $tmparray['dol_hide_topmenu']; + $_POST['dol_hide_leftmenu'] = $tmparray['dol_hide_leftmenu']; + $_POST['dol_optimize_smallscreen'] = $tmparray['dol_optimize_smallscreen']; + $_POST['dol_no_mouse_hover'] = $tmparray['dol_no_mouse_hover']; + $_POST['dol_use_jmobile'] = $tmparray['dol_use_jmobile']; + } + + // If googleoauth_login has been set (by google_oauthcallback after a successfull OAUTH2 request on openid scope + if (dol_verifyHash($conf->file->instance_unique_id.$usertotest, $_SESSION['googleoauth_receivedlogin'], '0')) { + unset($_SESSION['googleoauth_receivedlogin']); + $login = $usertotest; + } + } + } return $login; } diff --git a/htdocs/core/login/functions_http.php b/htdocs/core/login/functions_http.php index 73f5824c3cd..1fc4f29d2b2 100644 --- a/htdocs/core/login/functions_http.php +++ b/htdocs/core/login/functions_http.php @@ -43,6 +43,8 @@ function check_user_password_http($usertotest, $passwordtotest, $entitytotest) require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + // Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method + /* $tmpuser = new User($db); $tmpuser->fetch('', $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1)); @@ -59,6 +61,7 @@ function check_user_password_http($usertotest, $passwordtotest, $entitytotest) $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity"); return '--bad-login-validity--'; } + */ } return $login; diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 0db325736a6..bcd854414bc 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -162,6 +162,8 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + // Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method + /* $tmpuser = new User($db); $tmpuser->fetch('', $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1)); @@ -179,7 +181,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) $langs->loadLangs(array('main', 'errors')); $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity"); return '--bad-login-validity--'; - } + }*/ // ldap2dolibarr synchronisation if ($login && !empty($conf->ldap->enabled) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { // ldap2dolibarr synchronization diff --git a/htdocs/core/login/functions_openid.php b/htdocs/core/login/functions_openid.php index d45819cf039..f9172f21c87 100644 --- a/htdocs/core/login/functions_openid.php +++ b/htdocs/core/login/functions_openid.php @@ -80,7 +80,8 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) if ($resql) { $obj = $db->fetch_object($resql); if ($obj) { - $now = dol_now(); + // Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method + /* $now = dol_now(); if ($obj->datestartvalidity && $db->jdate($obj->datestartvalidity) > $now) { // Load translation files required by the page $langs->loadLangs(array('main', 'errors')); @@ -92,8 +93,7 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) $langs->loadLangs(array('main', 'errors')); $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity"); return '--bad-login-validity--'; - } - + } */ $login = $obj->login; } } diff --git a/htdocs/core/login/functions_openid_connect.php b/htdocs/core/login/functions_openid_connect.php index b1980b3419f..ea7c4d1c7fd 100644 --- a/htdocs/core/login/functions_openid_connect.php +++ b/htdocs/core/login/functions_openid_connect.php @@ -76,6 +76,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit $userinfo_headers = array('Authorization: Bearer '.$token_content->access_token); $userinfo_response = getURLContent($conf->global->MAIN_AUTHENTICATION_OIDC_USERINFO_URL, 'GET', '', 1, $userinfo_headers); $userinfo_content = json_decode($userinfo_response['content']); + dol_syslog("functions_openid_connect::check_user_password_openid_connect /userinfo=".print_r($userinfo_response, true), LOG_DEBUG); // Get the user attribute (claim) matching the Dolibarr login @@ -92,12 +93,13 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit $sql .= ' AND entity IN (0,'.(array_key_exists('dol_entity', $_SESSION) ? ((int) $_SESSION["dol_entity"]) : 1).')'; dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG); + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) { - // TODO I think we can remove this because this is done now natively by core after calling check_user_password_openid_connect() - $now = dol_now(); + // Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method + /* $now = dol_now(); if ($obj->datestartvalidity && $db->jdate($obj->datestartvalidity) > $now) { // Load translation files required by the page $langs->loadLangs(array('main', 'errors')); @@ -109,8 +111,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit $langs->loadLangs(array('main', 'errors')); $_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity"); return '--bad-login-validity--'; - } - + } */ $login = $obj->login; } } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 45a895e3287..20e738f14c8 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -63,7 +63,7 @@ class pdf_einstein extends ModelePDFCommandes public $description; /** - * @var int Save the name of generated file as the main doc when generating a doc with this template + * @var string Save the name of generated file as the main doc when generating a doc with this template */ public $update_main_doc_field; @@ -179,8 +179,8 @@ class pdf_einstein extends ModelePDFCommandes $this->posxqty = 135; $this->posxunit = 151; } else { - $this->posxtva = 110; - $this->posxup = 126; + $this->posxtva = 106; + $this->posxup = 122; $this->posxqty = 145; $this->posxunit = 162; } @@ -735,9 +735,11 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 1); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + // If France, show VAT mention if not applicable if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); @@ -746,14 +748,16 @@ class pdf_einstein extends ModelePDFCommandes $posxval = 52; + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + // Show payments conditions if ($object->cond_reglement_code || $object->cond_reglement) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions").':'; $pdf->MultiCell(43, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); @@ -795,11 +799,11 @@ class pdf_einstein extends ModelePDFCommandes // Show planed date of delivery if (!empty($object->delivery_date)) { $outputlangs->load("sendings"); - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); @@ -807,12 +811,12 @@ class pdf_einstein extends ModelePDFCommandes $posy = $pdf->GetY() + 1; } elseif ($object->availability_code || $object->availability) { // Show availability conditions - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetTextColor(0, 0, 0); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : ''); $lib_availability = str_replace('\n', "\n", $lib_availability); @@ -825,12 +829,12 @@ class pdf_einstein extends ModelePDFCommandes if ($object->mode_reglement_code && $object->mode_reglement_code != 'CHQ' && $object->mode_reglement_code != 'VIR') { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode").':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); @@ -842,8 +846,6 @@ class pdf_einstein extends ModelePDFCommandes if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { - $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); - if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_CHQ_NUMBER); @@ -1266,7 +1268,7 @@ class pdf_einstein extends ModelePDFCommandes } if (empty($hidetop)) { $pdf->SetXY($this->postotalht - 1, $tab_top + 1); - $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); + $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C'); } } @@ -1426,12 +1428,18 @@ class pdf_einstein extends ModelePDFCommandes if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index f0a70560499..ccb68a003bb 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -946,9 +946,11 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 1); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + // If France, show VAT mention if not applicable if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); @@ -957,14 +959,16 @@ class pdf_eratosthene extends ModelePDFCommandes $posxval = 52; + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + // Show payments conditions if ($object->cond_reglement_code || $object->cond_reglement) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions").':'; $pdf->MultiCell(43, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); @@ -1006,23 +1010,23 @@ class pdf_eratosthene extends ModelePDFCommandes // Show planed date of delivery if (!empty($object->delivery_date)) { $outputlangs->load("sendings"); - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); $posy = $pdf->GetY() + 1; } elseif ($object->availability_code || $object->availability) { // Show availability conditions - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetTextColor(0, 0, 0); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : ''); $lib_availability = str_replace('\n', "\n", $lib_availability); @@ -1035,12 +1039,12 @@ class pdf_eratosthene extends ModelePDFCommandes if ($object->mode_reglement_code && $object->mode_reglement_code != 'CHQ' && $object->mode_reglement_code != 'VIR') { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode").':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); @@ -1052,8 +1056,6 @@ class pdf_eratosthene extends ModelePDFCommandes if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { - $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); - if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_CHQ_NUMBER); @@ -1601,12 +1603,18 @@ class pdf_eratosthene extends ModelePDFCommandes if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); @@ -1890,7 +1898,7 @@ class pdf_eratosthene extends ModelePDFCommandes 'width' => 26, // in mm 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false, 'title' => array( - 'textkey' => 'TotalHT' + 'textkey' => 'TotalHTShort' ), 'border-left' => true, // add left line separator ); @@ -1901,7 +1909,7 @@ class pdf_eratosthene extends ModelePDFCommandes 'width' => 26, // in mm 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true, 'title' => array( - 'textkey' => 'TotalTTC' + 'textkey' => 'TotalTTCShort' ), 'border-left' => true, // add left line separator ); diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 59a4a549242..2f434af93a6 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -724,11 +724,18 @@ class pdf_strato extends ModelePDFContract if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); diff --git a/htdocs/core/modules/delivery/mod_delivery_saphir.php b/htdocs/core/modules/delivery/mod_delivery_saphir.php index 68da925e62b..89cdafa9fe7 100644 --- a/htdocs/core/modules/delivery/mod_delivery_saphir.php +++ b/htdocs/core/modules/delivery/mod_delivery_saphir.php @@ -83,7 +83,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder // Parametrage du prefix $texte .= '
    '; - $texte .= ''; + $texte .= ''; $texte .= ''; @@ -130,7 +130,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur - $mask = $conf->global->DELIVERY_SAPHIR_MASK; + $mask = getDolGlobalString('DELIVERY_SAPHIR_MASK'); if (!$mask) { $this->error = 'NotConfigured'; diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 16d38e9efeb..9592330da2e 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -1114,7 +1114,14 @@ class pdf_espadon extends ModelePdfExpedition } if (is_array($arrayidcontact) && count($arrayidcontact) > 0) { $object->fetch_user(reset($arrayidcontact)); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index f0d2fb847a1..f7c6599647b 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -1041,7 +1041,14 @@ class pdf_rouget extends ModelePdfExpedition } if (count($arrayidcontact) > 0) { $object->fetch_user(reset($arrayidcontact)); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 14f71fa4f99..cc9bc723635 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -336,8 +336,10 @@ class doc_generic_invoice_odt extends ModelePDFFactures $object->fetchObjectLinked('', '', '', ''); //print_r($object->linkedObjects['propal']); exit; - if (isset($object->linkedObjects['propal'][0])) { - $propal_object = $object->linkedObjects['propal'][0]; + $array_propal_object = $object->linkedObjects['propal']; + if (isset($array_propal_object) && is_array($array_propal_object) && count($array_propal_object) > 0) { + $tmparrayofvalue = array_values($array_propal_object); + $propal_object = $tmparrayofvalue[0]; } else { $propal_object = null; } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 5993b8d0605..a0aa602b9c7 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -191,8 +191,8 @@ class pdf_crabe extends ModelePDFFactures $this->posxqty = 135; $this->posxunit = 151; } else { - $this->posxtva = 110; - $this->posxup = 126; + $this->posxtva = 106; + $this->posxup = 122; $this->posxqty = 145; $this->posxunit = 162; } @@ -1793,7 +1793,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->postotalht - 1, $tab_top + 1); - $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); + $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C'); } } @@ -2036,7 +2036,17 @@ class pdf_crabe extends ModelePDFFactures if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); + $carac_emetteur = ''; + // Add internal contact of object if defined + $arrayidcontact = $object->getIdContact('internal', 'BILLING'); + if (count($arrayidcontact) > 0) { + $object->fetch_user($arrayidcontact[0]); + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= "\n"; + } + + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 3e75ec686ee..254337d9bbb 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1622,7 +1622,7 @@ class pdf_sponge extends ModelePDFFactures // Total remise $total_line_remise = 0; foreach ($object->lines as $i => $line) { - $total_line_remise += (float) pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this method to core/lib/pdf.lib + $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this method to core/lib/pdf.lib // Gestion remise sous forme de ligne négative if ($line->total_ht < 0) { $total_line_remise += -$line->total_ht; @@ -2288,7 +2288,17 @@ class pdf_sponge extends ModelePDFFactures if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); + $carac_emetteur = ''; + // Add internal contact of object if defined + $arrayidcontact = $object->getIdContact('internal', 'BILLING'); + if (count($arrayidcontact) > 0) { + $object->fetch_user($arrayidcontact[0]); + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= "\n"; + } + + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; @@ -2577,7 +2587,7 @@ class pdf_sponge extends ModelePDFFactures 'width' => 19, // in mm 'status' => false, 'title' => array( - 'textkey' => 'Progress' + 'textkey' => 'ProgressShort' ), 'border-left' => true, // add left line separator ); @@ -2620,7 +2630,7 @@ class pdf_sponge extends ModelePDFFactures 'width' => 26, // in mm 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false, 'title' => array( - 'textkey' => 'TotalHT' + 'textkey' => 'TotalHTShort' ), 'border-left' => true, // add left line separator ); @@ -2631,7 +2641,7 @@ class pdf_sponge extends ModelePDFFactures 'width' => 26, // in mm 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true, 'title' => array( - 'textkey' => 'TotalTTC' + 'textkey' => 'TotalTTCShort' ), 'border-left' => true, // add left line separator ); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index f209dc67247..cd1cdf48f5e 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -632,11 +632,18 @@ class pdf_soleil extends ModelePDFFicheinter if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 590e5b6b488..3b6b4e10c82 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -84,7 +84,7 @@ class modExpedition extends DolibarrModules $this->const[$r][0] = "EXPEDITION_ADDON_PDF"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "rouget"; + $this->const[$r][2] = "espadon"; $this->const[$r][3] = 'Nom du gestionnaire de generation des bons expeditions en PDF'; $this->const[$r][4] = 0; $r++; @@ -105,7 +105,7 @@ class modExpedition extends DolibarrModules $this->const[$r][0] = "DELIVERY_ADDON_PDF"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "typhon"; + $this->const[$r][2] = "storm"; $this->const[$r][3] = 'Nom du gestionnaire de generation des bons de reception en PDF'; $this->const[$r][4] = 0; $r++; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 18f6d278d8e..911090c63d3 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -134,8 +134,8 @@ class modFacture extends DolibarrModules 'class'=>'compta/facture/class/facture.class.php', 'objectname'=>'Facture', 'method'=>'sendEmailsRemindersOnInvoiceDueDate', - 'parameters'=>"10,all,EmailTemplateCode", - 'comment'=>'Send an email when we reach the invoice due date (or invoice date) - n days. First param is n, the number of days before due date (or invoice date) to send the remind (or after if value is negative), second parameter is "all" or a payment mode code, third parameter is the code of the email template to use (an email template with the EmailTemplateCode must exists. The version of the email template in the language of the thirdparty will be used in priority. Language of the thirdparty will be also used to update the PDF of the sent invoice). The last parameter is "duedate" or "invoicedate" to define which date of the invoice to use.', + 'parameters'=>"10,all,EmailTemplateCode,duedate", + 'comment'=>'Send an email when we reach the invoice due date (or invoice date) - n days. First param is n, the number of days before due date (or invoice date) to send the remind (or after if value is negative), second parameter is "all" or a payment mode code, third parameter is the code of the email template to use (an email template with the EmailTemplateCode must exists. The version of the email template in the language of the thirdparty will be used in priority. Language of the thirdparty will be also used to update the PDF of the sent invoice). The fourth parameter is the string "duedate" (default) or "invoicedate" to define which date of the invoice to use.', 'frequency'=>1, 'unitfrequency'=>3600 * 24, 'priority'=>50, @@ -318,7 +318,7 @@ class modFacture extends DolibarrModules 'f.date_lim_reglement' => '2021-12-24', 'f.note_public' => '', 'f.note_private' => '', - 'f.model_pdf' => 'crabe', + 'f.model_pdf' => 'sponge', 'f.multicurrency_code' => 'EUR', 'f.multicurrency_tx' => '1', 'f.multicurrency_total_ht' => '100', diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 27c15bda16f..c034f1eb9b5 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -83,7 +83,7 @@ class modFournisseur extends DolibarrModules $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "muscadet"; + $this->const[$r][2] = "cornas"; $this->const[$r][3] = 'Nom du gestionnaire de generation des bons de commande en PDF'; $this->const[$r][4] = 0; $r++; diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 7ddd983c907..a36234b1026 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -1247,11 +1247,18 @@ class pdf_vinci extends ModelePDFMo if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index bd59e513ddf..67b027b0f1d 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -16,7 +16,8 @@ * along with this program. If not, see . */ -// This page should make the process to login and get token as described here: +// This page is used as callback for token generation of an OAUTH request. +// This page can also be used to make the process to login and get token as described here: // https://developers.google.com/identity/protocols/oauth2/openid-connect#server-flow /** @@ -25,6 +26,17 @@ * \brief Page to get oauth callback */ +// Force keyforprovider +$forlogin = 0; +if (preg_match('/^forlogin-/', $_GET['state'])) { + $forlogin = 1; + $_GET['keyforprovider'] = 'Login'; +} + +if (!defined('NOLOGIN') && $forlogin) { + define("NOLOGIN", 1); // This means this output page does not require to be logged. +} + // Load Dolibarr environment require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php'; @@ -33,11 +45,12 @@ use OAuth\Common\Consumer\Credentials; use OAuth\OAuth2\Service\Google; // Define $urlwithroot +global $dolibarr_main_url_root; $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 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - +$langs->load("oauth"); $action = GETPOST('action', 'aZ09'); $backtourl = GETPOST('backtourl', 'alpha'); @@ -85,7 +98,7 @@ $statewithanticsrfonly = ''; $requestedpermissionsarray = array(); if ($state) { // 'state' parameter is standard to store a hash value and can be used to retrieve some parameters back - $statewithscopeonly = preg_replace('/\-.*$/', '', $state); + $statewithscopeonly = preg_replace('/\-.*$/', '', preg_replace('/^forlogin-/', '', $state)); $requestedpermissionsarray = explode(',', $statewithscopeonly); // Example: 'userinfo_email,userinfo_profile,openid,email,profile,cloud_print'. $statewithanticsrfonly = preg_replace('/^.*\-/', '', $state); } @@ -112,13 +125,11 @@ $apiService = $serviceFactory->createService('Google', $credentials, $storage, $ $apiService->setAccessType('offline'); -$langs->load("oauth"); - if (!getDolGlobalString($keyforparamid)) { - accessforbidden('Setup of service is not complete. Customer ID is missing'); + accessforbidden('Setup of service '.$keyforparamid.' is not complete. Customer ID is missing'); } if (!getDolGlobalString($keyforparamsecret)) { - accessforbidden('Setup of service is not complete. Secret key is missing'); + accessforbidden('Setup of service '.$keyforparamid.' is not complete. Secret key is missing'); } @@ -126,7 +137,6 @@ if (!getDolGlobalString($keyforparamsecret)) { * Actions */ - if ($action == 'delete') { $storage->clearToken('Google'); @@ -136,69 +146,14 @@ if ($action == 'delete') { exit(); } -if (GETPOST('code')) { // We are coming from oauth provider page. - dol_syslog("We are coming from the oauth provider page keyforprovider=".$keyforprovider." code=".dol_trunc(GETPOST('code'), 5)); - - // We must validate that the $state is the same than the one into $_SESSION['oauthstateanticsrf'], return error if not. - if (isset($_SESSION['oauthstateanticsrf']) && $state != $_SESSION['oauthstateanticsrf']) { - print 'Value for state = '.dol_escape_htmltag($state).' differs from value in $_SESSION["oauthstateanticsrf"]. Code is refused.'; - unset($_SESSION['oauthstateanticsrf']); - } else { - // This was a callback request from service, get the token - try { - //var_dump($state); - //var_dump($apiService); // OAuth\OAuth2\Service\Google - - // This request the token - // Result is stored into object managed by class DoliStorage into includes/OAuth/Common/Storage/DoliStorage.php, so into table llx_oauth_token - $token = $apiService->requestAccessToken(GETPOST('code'), $state); - - // Note: The extraparams has the 'id_token' than contains a lot of information about the user. - $extraparams = $token->getExtraParams(); - $jwt = explode('.', $extraparams['id_token']); - - // Extract the middle part, base64 decode, then json_decode it - if (!empty($jwt[1])) { - $userinfo = json_decode(base64_decode($jwt[1]), true); - - // TODO - // We should make the 5 steps of validation of id_token - // Verify that the ID token is properly signed by the issuer. Google-issued tokens are signed using one of the certificates found at the URI specified in the jwks_uri metadata value of the Discovery document. - // Verify that the value of the iss claim in the ID token is equal to https://accounts.google.com or accounts.google.com. - // Verify that the value of the aud claim in the ID token is equal to your app's client ID. - // Verify that the expiry time (exp claim) of the ID token has not passed. - // If you specified a hd parameter value in the request, verify that the ID token has a hd claim that matches an accepted G Suite hosted domain. - - /* - $useremailuniq = $userinfo['sub']; - $useremail = $userinfo['email']; - $useremailverified = $userinfo['email_verified']; - $username = $userinfo['name']; - $userfamilyname = $userinfo['family_name']; - $usergivenname = $userinfo['given_name']; - $hd = $userinfo['hd']; - */ - } - - setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); - - $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; - unset($_SESSION["backtourlsavedbeforeoauthjump"]); - - header('Location: '.$backtourl); - exit(); - } catch (Exception $e) { - print $e->getMessage(); - } - } -} else { +if (!GETPOST('code')) { // If we enter this page without 'code' parameter, we arrive here. This is the case when we want to get the redirect // to the OAuth provider login page. $_SESSION["backtourlsavedbeforeoauthjump"] = $backtourl; $_SESSION["oauthkeyforproviderbeforeoauthjump"] = $keyforprovider; $_SESSION['oauthstateanticsrf'] = $state; - if (!preg_match('/^forlogin/', $state)) { + if ($forlogin) { $apiService->setApprouvalPrompt('force'); } @@ -209,19 +164,182 @@ if (GETPOST('code')) { // We are coming from oauth provider page. } else { $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated } + // The redirect_uri is included into this $url // Add more param $url .= '&nonce='.bin2hex(random_bytes(64/8)); - // TODO Add param hd and/or login_hint - if (!preg_match('/^forlogin/', $state)) { - //$url .= 'hd=xxx'; - } - //var_dump($url);exit; + if ($forlogin) { + // TODO Add param hd. What is it for ? + //$url .= 'hd=xxx'; + + if (GETPOST('username')) { + $url .= '&login_hint='.urlencode(GETPOST('username')); + } + + // Check that the redirect_uri that wil be used is same than url of current domain + + // Define $urlwithroot + global $dolibarr_main_url_root; + $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 + //$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + include DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + $currentrooturl = getRootURLFromURL(DOL_MAIN_URL_ROOT); + $externalrooturl = getRootURLFromURL($urlwithroot); + + if ($currentrooturl != $externalrooturl) { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorTheUrlOfYourDolInstanceDoesNotMatchURLIntoOAuthSetup", $currentrooturl, $externalrooturl), null, 'errors'); + $url = DOL_URL_ROOT; + } + } // we go on oauth provider authorization page header('Location: '.$url); exit(); +} else { + // We are coming from the return of an OAuth2 provider page. + dol_syslog("We are coming from the oauth provider page keyforprovider=".$keyforprovider." code=".dol_trunc(GETPOST('code'), 5)); + + // We must validate that the $state is the same than the one into $_SESSION['oauthstateanticsrf'], return error if not. + if (isset($_SESSION['oauthstateanticsrf']) && $state != $_SESSION['oauthstateanticsrf']) { + //var_dump($_SESSION['oauthstateanticsrf']);exit; + print 'Value for state='.dol_escape_htmltag($state).' differs from value in $_SESSION["oauthstateanticsrf"]. Code is refused.'; + unset($_SESSION['oauthstateanticsrf']); + } else { + // This was a callback request from service, get the token + try { + //var_dump($state); + //var_dump($apiService); // OAuth\OAuth2\Service\Google + //dol_syslog("_GET=".var_export($_GET, true)); + + $errorincheck = 0; + + $db->begin(); + + // This requests the token from the received OAuth code (call of the https://oauth2.googleapis.com/token endpoint) + // Result is stored into object managed by class DoliStorage into includes/OAuth/Common/Storage/DoliStorage.php, so into table llx_oauth_token + $token = $apiService->requestAccessToken(GETPOST('code'), $state); + + // Note: The extraparams has the 'id_token' than contains a lot of information about the user. + $extraparams = $token->getExtraParams(); + $jwt = explode('.', $extraparams['id_token']); + + $useremail = ''; + + // Extract the middle part, base64 decode, then json_decode it + if (!empty($jwt[1])) { + $userinfo = json_decode(base64_decode($jwt[1]), true); + + dol_syslog("userinfo=".var_export($userinfo, true)); + + $useremail = $userinfo['email']; + /* + $useremailverified = $userinfo['email_verified']; + $useremailuniq = $userinfo['sub']; + $username = $userinfo['name']; + $userfamilyname = $userinfo['family_name']; + $usergivenname = $userinfo['given_name']; + $hd = $userinfo['hd']; + */ + + // We should make the steps of validation of id_token + + // Verify that the state is the one expected + // TODO + + // Verify that the ID token is properly signed by the issuer. Google-issued tokens are signed using one of the certificates found at the URI specified in the jwks_uri metadata value of the Discovery document. + // TODO + + // Verify that the value of the iss claim in the ID token is equal to https://accounts.google.com or accounts.google.com. + if ($userinfo['iss'] != 'accounts.google.com' && $userinfo['iss'] != 'https://accounts.google.com') { + setEventMessages($langs->trans('Bad value for returned userinfo[iss]'), null, 'errors'); + $errorincheck++; + } + + // Verify that the value of the aud claim in the ID token is equal to your app's client ID. + if ($userinfo['aud'] != getDolGlobalString($keyforparamid)) { + setEventMessages($langs->trans('Bad value for returned userinfo[aud]'), null, 'errors'); + $errorincheck++; + } + + // Verify that the expiry time (exp claim) of the ID token has not passed. + if ($userinfo['exp'] <= dol_now()) { + setEventMessages($langs->trans('Bad value for returned userinfo[exp]. Token expired.'), null, 'errors'); + $errorincheck++; + } + + // If you specified a hd parameter value in the request, verify that the ID token has a hd claim that matches an accepted G Suite hosted domain. + // TODO + } + + if (!$errorincheck) { + // If call back to url for a OAUTH2 login + if ($forlogin) { + dol_syslog("we received the login/email to log to, it is ".$useremail); + + $tmparray = (empty($_SESSION['datafromloginform']) ? array() : $_SESSION['datafromloginform']); + $entitytosearchuser = (isset($tmparray['entity']) ? $tmparray['entity'] : -1); + + // Delete the token + $storage->clearToken('Google'); + + $tmpuser = new User($db); + $res = $tmpuser->fetch(0, '', '', 0, $entitytosearchuser, $useremail); + + if ($res > 0) { + $username = $tmpuser->login; + + $_SESSION['googleoauth_receivedlogin'] = dol_hash($conf->file->instance_unique_id.$username, '0'); + dol_syslog('$_SESSION[\'googleoauth_receivedlogin\']='.$_SESSION['googleoauth_receivedlogin']); + } else { + $errormessage = "Failed to login using Google. User with the Email '".$useremail."' was not found"; + if ($entitytosearchuser > 0) { + $errormessage .= ' ('.$langs->trans("Entity").' '.$entitytosearchuser.')'; + } + $_SESSION["dol_loginmesg"] = $errormessage; + $errorincheck++; + } + } + } else { + // If call back to url for a OAUTH2 login + if ($forlogin) { + $_SESSION["dol_loginmesg"] = "Failed to login using Google. OAuth callback URL retreives a token with non valid data"; + $errorincheck++; + } + } + + if (!$errorincheck) { + $db->commit(); + } else { + $db->rollback(); + } + + $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; + unset($_SESSION["backtourlsavedbeforeoauthjump"]); + + if (empty($backtourl)) { + $backtourl = DOL_URL_ROOT; + } + + // If call back to url for a OAUTH2 login + if ($forlogin) { + $backtourl .= '?actionlogin=login&afteroauthloginreturn=1&username='.urlencode($username).'&token='.newToken(); + if (!empty($tmparray['entity'])) { + $backtourl .= '&entity='.$tmparray['entity']; + } + } + + dol_syslog("Redirect now on backtourl=".$backtourl); + + header('Location: '.$backtourl); + exit(); + } catch (Exception $e) { + print $e->getMessage(); + } + } } @@ -229,6 +347,6 @@ if (GETPOST('code')) { // We are coming from oauth provider page. * View */ -// No view at all, just actions, so we never reach this line. +// No view at all, just actions, so we reach this line only on error. $db->close(); diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 889164fbfe5..93530cc793c 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -88,7 +88,7 @@ class mod_project_universal extends ModeleNumRefProjects // Parametrage du prefix $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; @@ -134,7 +134,7 @@ class mod_project_universal extends ModeleNumRefProjects require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur - $mask = $conf->global->PROJECT_UNIVERSAL_MASK; + $mask = getDolGlobalString('PROJECT_UNIVERSAL_MASK'); if (!$mask) { $this->error = 'NotConfigured'; diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 22ac9e3d681..4084f3d9298 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -83,7 +83,7 @@ class mod_task_universal extends ModeleNumRefTask // Parametrage du prefix $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; @@ -128,7 +128,7 @@ class mod_task_universal extends ModeleNumRefTask require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $mask = !empty($conf->global->PROJECT_TASK_UNIVERSAL_MASK) ? $conf->global->PROJECT_TASK_UNIVERSAL_MASK : ''; + $mask = getDolGlobalString('PROJECT_TASK_UNIVERSAL_MASK'); if (!$mask) { $this->error = 'NotConfigured'; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 7e745d2cc7a..093a8c5b6be 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -48,6 +48,11 @@ class pdf_azur extends ModelePDFPropales */ public $db; + /** + * @var int The environment ID when using a multicompany module + */ + public $entity; + /** * @var string model name */ @@ -925,9 +930,11 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - 1); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + // If France, show VAT mention if not applicable if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); @@ -944,23 +951,23 @@ class pdf_azur extends ModelePDFPropales // Show shipping date if (!empty($object->delivery_date)) { $outputlangs->load("sendings"); - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size -$diffsizetitle); $pdf->SetXY($posxval, $posy); $dlp = dol_print_date($object->delivery_date, $displaydate, false, $outputlangs, true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); $posy = $pdf->GetY() + 1; } elseif ($object->availability_code || $object->availability) { // Show availability conditions - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetTextColor(0, 0, 0); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability); $lib_availability = str_replace('\n', "\n", $lib_availability); @@ -980,12 +987,12 @@ class pdf_azur extends ModelePDFPropales $shipping_method_code = dol_getIdFromCode($this->db, $shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); $shipping_method_label = dol_getIdFromCode($this->db, $shipping_method_id, 'c_shipment_mode', 'rowid', 'libelle'); - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("SendingMethod").':'; $pdf->MultiCell(43, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = ($outputlangs->transnoentities("SendingMethod".strtoupper($shipping_method_code)) != "SendingMethod".strtoupper($shipping_method_code)) ? $outputlangs->trans("SendingMethod".strtoupper($shipping_method_code)) : $shipping_method_label; $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); @@ -996,12 +1003,12 @@ class pdf_azur extends ModelePDFPropales // Show payments conditions if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTTERM) && $object->cond_reglement_code) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions").':'; $pdf->MultiCell(43, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); @@ -1018,11 +1025,11 @@ class pdf_azur extends ModelePDFPropales if ($object->mode_reglement_code && $object->mode_reglement_code != 'CHQ' && $object->mode_reglement_code != 'VIR') { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode").':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); @@ -1034,8 +1041,6 @@ class pdf_azur extends ModelePDFPropales if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) { - $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); - if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER')); @@ -1471,7 +1476,7 @@ class pdf_azur extends ModelePDFPropales } if (empty($hidetop)) { $pdf->SetXY($this->postotalht - 1, $tab_top + 1); - $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); + $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C'); } } @@ -1635,12 +1640,18 @@ class pdf_azur extends ModelePDFPropales if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); @@ -1665,7 +1676,7 @@ class pdf_azur extends ModelePDFPropales $pdf->SetTextColor(0, 0, 60); } - // Show sender name + // Show company name if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) { $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index e7fbdd1fc5f..24ccb210f12 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1035,9 +1035,11 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - 1); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + // If France, show VAT mention if not applicable if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); @@ -1054,23 +1056,23 @@ class pdf_cyan extends ModelePDFPropales // Show shipping date if (!empty($object->delivery_date)) { $outputlangs->load("sendings"); - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $dlp = dol_print_date($object->delivery_date, $displaydate, false, $outputlangs, true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); $posy = $pdf->GetY() + 1; } elseif ($object->availability_code || $object->availability) { // Show availability conditions - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetTextColor(0, 0, 0); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability); $lib_availability = str_replace('\n', "\n", $lib_availability); @@ -1090,12 +1092,12 @@ class pdf_cyan extends ModelePDFPropales $shipping_method_code = dol_getIdFromCode($this->db, $shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); $shipping_method_label = dol_getIdFromCode($this->db, $shipping_method_id, 'c_shipment_mode', 'rowid', 'libelle'); - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("SendingMethod").':'; $pdf->MultiCell(43, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = ($outputlangs->transnoentities("SendingMethod".strtoupper($shipping_method_code)) != "SendingMethod".strtoupper($shipping_method_code)) ? $outputlangs->trans("SendingMethod".strtoupper($shipping_method_code)) : $shipping_method_label; $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); @@ -1106,12 +1108,12 @@ class pdf_cyan extends ModelePDFPropales // Show payments conditions if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTTERM) && $object->cond_reglement_code) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions").':'; $pdf->MultiCell(43, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); @@ -1128,11 +1130,11 @@ class pdf_cyan extends ModelePDFPropales if ($object->mode_reglement_code && $object->mode_reglement_code != 'CHQ' && $object->mode_reglement_code != 'VIR') { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode").':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); @@ -1144,8 +1146,6 @@ class pdf_cyan extends ModelePDFPropales if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) { - $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); - if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER')); @@ -1710,12 +1710,18 @@ class pdf_cyan extends ModelePDFPropales if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); @@ -2033,7 +2039,7 @@ class pdf_cyan extends ModelePDFPropales 'width' => 26, // in mm 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false, 'title' => array( - 'textkey' => 'TotalHT' + 'textkey' => 'TotalHTShort' ), 'border-left' => true, // add left line separator ); @@ -2044,7 +2050,7 @@ class pdf_cyan extends ModelePDFPropales 'width' => 26, // in mm 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true, 'title' => array( - 'textkey' => 'TotalTTC' + 'textkey' => 'TotalTTCShort' ), 'border-left' => true, // add left line separator ); diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index f950bac3e1d..286dcd59cb2 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -971,7 +971,14 @@ class pdf_squille extends ModelePdfReception } if (count($arrayidcontact) > 0) { $object->fetch_user(reset($arrayidcontact)); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 257bdf55e52..3805feee4ce 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -61,8 +61,14 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode if (!isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') { $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER = '401'; } - $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; - $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; + + if (!empty($conf->global->COMPANY_AQUARIUM_NO_PREFIX)) { + $this->prefixcustomeraccountancycode = ''; + $this->prefixsupplieraccountancycode = ''; + } else { + $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; + $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; + } } @@ -102,6 +108,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) { $texte .= $langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."
    \n"; } + + if (!empty($conf->global->COMPANY_AQUARIUM_NO_PREFIX)) { + $texte .= $langs->trans('COMPANY_AQUARIUM_NO_PREFIX').' = '.$conf->global->COMPANY_AQUARIUM_NO_PREFIX."
    \n"; + } $texte .= ''; $texte .= ''; $texte .= '
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).' 
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).' 
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).' 
    '; diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index e1cd6c8e5e6..e0a4e0694dd 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -154,20 +154,24 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Define column position $this->posxdesc = $this->marge_gauche + 1; - $this->posxtva = 112; - $this->posxup = 126; - $this->posxqty = 145; - $this->posxunit = 162; - $this->posxdiscount = 162; - $this->postotalht = 174; if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->posxtva = 99; $this->posxup = 114; $this->posxqty = 130; $this->posxunit = 147; + } else { + $this->posxtva = 106; + $this->posxup = 122; + $this->posxqty = 145; + $this->posxunit = 162; } - //if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; + $this->posxdiscount = 162; + $this->postotalht = 174; + + /* if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { + $this->posxtva = $this->posxup; + } */ $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) { // To work with US executive format $this->posxpicture -= 20; @@ -1189,11 +1193,18 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 00d819a0156..c6e8434c955 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -890,9 +890,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + // If France, show VAT mention if not applicable if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); @@ -903,12 +905,12 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Show payments conditions if (!empty($object->cond_reglement_code) || $object->cond_reglement) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); @@ -919,12 +921,12 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Show payment mode if (!empty($object->mode_reglement_code)) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode").':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); @@ -1379,11 +1381,18 @@ class pdf_cornas extends ModelePDFSuppliersOrders if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 8c6c144f2e4..31cee8d94ed 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -175,8 +175,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->posxqty = 132; $this->posxunit = 147; } else { - $this->posxtva = 110; - $this->posxup = 126; + $this->posxtva = 106; + $this->posxup = 122; $this->posxqty = 145; $this->posxunit = 162; } @@ -772,9 +772,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + // If France, show VAT mention if not applicable if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); @@ -785,12 +787,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Show payments conditions if (!empty($object->cond_reglement_code) || $object->cond_reglement_id) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); @@ -801,12 +803,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Show payment mode if (!empty($object->mode_reglement_code)) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode").':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); @@ -1288,11 +1290,18 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 0974a0df56f..95b661364ad 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -164,18 +164,20 @@ class pdf_aurore extends ModelePDFSupplierProposal // Define position of columns $this->posxdesc = $this->marge_gauche + 1; - $this->posxdiscount = 162; - $this->postotalht = 174; if (getDolGlobalInt('PRODUCT_USE_UNITS')) { + //$this->posxtva = 101; $this->posxup = 112; $this->posxqty = 135; $this->posxunit = 151; } else { - $this->posxup = 120; + //$this->posxtva = 106; + $this->posxup = 122; $this->posxqty = 145; $this->posxunit = 162; } + $this->posxdiscount = 162; + $this->postotalht = 174; $this->posxpicture = $this->posxup - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) { // To work with US executive format @@ -759,6 +761,8 @@ class pdf_aurore extends ModelePDFSupplierProposal global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + $pdf->SetFont('', '', $default_font_size - 1); $posxval = 52; @@ -766,11 +770,11 @@ class pdf_aurore extends ModelePDFSupplierProposal // Show shipping date if (!empty($object->delivery_date)) { $outputlangs->load("sendings"); - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $dlp = dol_print_date($object->delivery_date, "daytext", false, $outputlangs, true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); @@ -778,11 +782,11 @@ class pdf_aurore extends ModelePDFSupplierProposal $posy = $pdf->GetY() + 1; } else { $outputlangs->load("sendings"); - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); //$dlp=dol_print_date($object->delivery_date,"daytext",false,$outputlangs,true); $pdf->MultiCell(80, 4, '', 0, 'L'); @@ -808,12 +812,12 @@ class pdf_aurore extends ModelePDFSupplierProposal // Show payments conditions if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement)) { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy); $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); @@ -827,11 +831,11 @@ class pdf_aurore extends ModelePDFSupplierProposal if ($object->mode_reglement_code && $object->mode_reglement_code != 'CHQ' && $object->mode_reglement_code != 'VIR') { - $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->SetXY($this->marge_gauche, $posy - 2); $titre = $outputlangs->transnoentities("PaymentMode").':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->SetXY($posxval, $posy - 2); $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); @@ -843,8 +847,6 @@ class pdf_aurore extends ModelePDFSupplierProposal if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) { - $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); - if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER')); @@ -1227,7 +1229,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } if (empty($hidetop)) { $pdf->SetXY($this->postotalht - 1, $tab_top + 1); - $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); + $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C'); } } @@ -1343,12 +1345,18 @@ class pdf_aurore extends ModelePDFSupplierProposal if ($showaddress) { // Sender properties $carac_emetteur = ''; - // Add internal contact of proposal if defined + // Add internal contact of object if defined $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); - $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)); + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : ''; + $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : ''; + $carac_emetteur .= "\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 188e60fefb8..7e33d5e8364 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2023 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 @@ -143,7 +143,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
    Contact:con - + diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index 288f3b8f72e..9b4fa75c751 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -13,13 +13,28 @@ if (isset($totalarray['pos'])) { while ($i < $totalarray['nbfield']) { $i++; if (!empty($totalarray['pos'][$i])) { - print ''; - if (isset($totalarray['type']) && $totalarray['type'][$i] == 'duration') { - print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0); - } else { - print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0); + switch ($totalarray['type'][$i]) { + case 'duration'; + print ''; + print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0); + print ''; + break; + case 'string'; + print ''; + print (!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : ''); + print ''; + break; + case 'stock'; + print ''; + print price2num(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0, 'MS'); + print ''; + break; + default; + print ''; + print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0); + print ''; + break; } - print ''; } else { if ($i == 1) { if (is_null($limit) || $num < $limit) { diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 7a0070cbb0d..68e59b0a7b4 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -72,6 +72,8 @@ if (preg_match('/'.preg_quote('core/modules/oauth', '/').'/', $php_self)) { $php_self = DOL_URL_ROOT.'/index.php?mainmenu=home'; } $php_self = preg_replace('/(\?|&|&)action=[^&]+/', '\1', $php_self); +$php_self = preg_replace('/(\?|&|&)username=[^&]*/', '\1', $php_self); +$php_self = preg_replace('/(\?|&|&)entity=\d+/', '\1', $php_self); $php_self = preg_replace('/(\?|&|&)massaction=[^&]+/', '\1', $php_self); $php_self = preg_replace('/(\?|&|&)token=[^&]+/', '\1', $php_self); @@ -207,15 +209,18 @@ if ($disablenofollow) {
    +file->main_authentication) || $conf->file->main_authentication != 'googleoauth') { ?>
    -global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - ?> + global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + ?> " name="password" class="flat input-icon-password minwidth150" value="" tabindex="2" autocomplete="global->MAIN_LOGIN_ENABLE_PASSWORD_AUTOCOMPLETE) ? 'off' : 'on'; ?>" />
    + + + +file->main_authentication) || $conf->file->main_authentication != 'googleoauth') { ?>
    + + file->main_authentication) && $conf->file->main_authentication == 'googleoauth') { + $forgetpasslink = ''; +} + if ($forgetpasslink || $helpcenterlink) { $moreparam = ''; if ($dol_hide_topmenu) { @@ -324,8 +337,8 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->fil $langs->load("users"); //if (!empty($conf->global->MAIN_OPENIDURL_PERUSER)) $url= - echo '
    '; - echo '
    '; + print '
    '; + print '
    '; $url = $conf->global->MAIN_AUTHENTICATION_OPENID_URL; if (!empty($url)) { @@ -335,22 +348,22 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->fil print ''.$langs->trans("ErrorOpenIDSetupNotComplete", 'MAIN_AUTHENTICATION_OPENID_URL').''; } - echo '
    '; + print '
    '; + print '
    '; } if (isset($conf->file->main_authentication) && preg_match('/google/', $conf->file->main_authentication)) { $langs->load("users"); - global $dolibarr_main_url_root; + echo '
    '; + + /*global $dolibarr_main_url_root; // Define $urlwithroot $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 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - echo '
    '; - echo '
    '; - //$shortscope = 'userinfo_email,userinfo_profile'; $shortscope = 'openid,email,profile'; // For openid connect @@ -358,11 +371,17 @@ if (isset($conf->file->main_authentication) && preg_match('/google/', $conf->fil $_SESSION['oauthstateanticsrf'] = $shortscope.'-'.$oauthstateanticsrf; $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state=forlogin-'.$shortscope.'-'.$oauthstateanticsrf; - $url = $urltorenew; + //$url = $urltorenew; + */ - print img_picto('', 'google', 'class="pictofixedwidth"').''.$langs->trans("LoginWith", "Google").''; - - echo '
    '; + print ''; + print ''; + print '
    '; + print img_picto('', 'google', 'class="pictofixedwidth"'); + print $langs->trans("LoginWith", "Google"); + print '
    '; + print '
    '; + print '
    '; } ?> diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php index 0770233c782..b260e1d6fd9 100644 --- a/htdocs/core/tpl/object_discounts.tpl.php +++ b/htdocs/core/tpl/object_discounts.tpl.php @@ -40,9 +40,9 @@ if (!isset($absolute_creditnote)) { } // Relative and absolute discounts -$addrelativediscount = ''.$langs->trans("EditRelativeDiscount").''; -$addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; -$viewabsolutediscount = ''.$langs->trans("ViewAvailableGlobalDiscounts").''; +$addrelativediscount = ''.$langs->trans("EditRelativeDiscount").''; +$addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; +$viewabsolutediscount = ''.$langs->trans("ViewAvailableGlobalDiscounts").''; $fixedDiscount = $thirdparty->remise_percent; if (!empty($discount_type)) { diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index f0e019a82e1..6bdaeb1aca6 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -763,14 +763,22 @@ class InterfaceActionsAuto extends DolibarrTriggers // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); - if (empty($object->actionmsg2)) { - $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs)); + $member = $this->context['member']; + if (!is_object($member)) { // This should not happen but it happen when deleting a subscription from adherents/subscription/card.php + dol_syslog("Execute a trigger MEMBER_SUBSCRIPTION_CREATE with context key 'member' not an object"); + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $member->fetch($object->fk_adherent); } - $object->actionmsg = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs)); - $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + + $object->actionmsg = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$member->getFullName($langs); $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->fk_type; $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->amount; $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->dateh, 'day').' - '.dol_print_date($object->datef, 'day'); + if (empty($object->actionmsg2)) { + $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $member->getFullName($langs)); + } $object->sendtoid = 0; if (isset($object->fk_soc) && $object->fk_soc > 0) { diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index c1cea5abe7d..ff6a536a8c5 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -370,8 +370,8 @@ class Cronjob extends CommonObject $sql .= " ".(!isset($this->unitfrequency) ? 'NULL' : "'".$this->db->escape($this->unitfrequency)."'").","; $sql .= " ".(!isset($this->frequency) ? '0' : ((int) $this->frequency)).","; $sql .= " ".(!isset($this->status) ? '0' : ((int) $this->status)).","; - $sql .= " ".((int) $user->id).","; - $sql .= " ".((int) $user->id).","; + $sql .= " ".($user->id ? (int) $user->id : "NULL").","; + $sql .= " ".($user->id ? (int) $user->id : "NULL").","; $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'").","; $sql .= " ".(!isset($this->nbrun) ? '0' : ((int) $this->nbrun)).","; $sql .= " ".(empty($this->maxrun) ? '0' : ((int) $this->maxrun)).","; @@ -900,6 +900,11 @@ class Cronjob extends CommonObject // Clear fields $object->status = self::STATUS_DISABLED; $object->label = $langs->trans("CopyOf").' '.$langs->trans($object->label); + $object->datelastrun = null; + $object->lastresult = ''; + $object->datelastresult = null; + $object->lastoutput = ''; + $object->nbrun = 0; // Create clone $object->context['createfromclone'] = 'createfromclone'; @@ -908,6 +913,7 @@ class Cronjob extends CommonObject // Other options if ($result < 0) { $this->error = $object->error; + $this->errors = $object->errors; $error++; } @@ -1171,7 +1177,7 @@ class Cronjob extends CommonObject return -1; } else { if (empty($user->id)) { - $this->error = " User user login:".$userlogin." do not exists"; + $this->error = "User login: ".$userlogin." does not exist"; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); $conf->setEntityValues($this->db, $savcurrententity); return -1; diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 5adb955e0d3..7d528f0d051 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -986,7 +986,7 @@ class Delivery extends CommonObject $i = 0; $line = new DeliveryLine($this->db); - $line->fk_product = $prodids[0]; + $line->fk_product = reset($prodids); $line->qty_asked = 10; $line->qty_shipped = 9; $line->ref = 'REFPROD'; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 65dec152abf..78e19dbca1c 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1000,8 +1000,10 @@ class EmailCollector extends CommonObject } else { // Nothing can be done for this param $errorforthisaction++; - $this->error = 'The extract rule to use has on an unknown source (must be HEADER, SUBJECT or BODY)'; + $this->error = 'The extract rule to use to overwrite properties has on an unknown source (must be HEADER, SUBJECT or BODY)'; $this->errors[] = $this->error; + + $operationslog .= '
    '.$this->error; } } elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $regforregex)) { $valuecurrent = ''; @@ -1434,6 +1436,7 @@ class EmailCollector extends CommonObject //$search .= ($search ? ' ' : '').'NOT BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; $searchfilterexcludebody = preg_replace('/^!/', '', $rule['rulevalue']); } else { + // Warning: Google doesn't implement IMAP properly, and only matches whole words, $search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; } } @@ -1753,7 +1756,15 @@ class EmailCollector extends CommonObject //$htmlmsg,$plainmsg,$charset,$attachments $messagetext = $plainmsg ? $plainmsg : dol_string_nohtmltag($htmlmsg, 0); // Removed emojis - $messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext); + + if (utf8_valid($messagetext)) { + //$messagetext = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $messagetext); + $messagetext = $this->removeEmoji($messagetext); + } else { + $operationslog .= '
    Discarded - Email body is not valid utf8'; + dol_syslog(" Discarded - Email body is not valid utf8"); + continue; // Exclude email + } if ($searchfilterexcludebody) { if (preg_match('/'.preg_quote($searchfilterexcludebody, '/').'/ms', $messagetext)) { @@ -2252,7 +2263,7 @@ class EmailCollector extends CommonObject $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> Found namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty); } else { - $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> We discard this, not used to search existing thirdparty'; + $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.' Regex /'.dol_escape_htmltag($regexstring).'/ms into '.strtoupper($sourcefield).' -> We discard this, not a field used to search an existing thirdparty'; } } else { // Regex not found @@ -2267,8 +2278,10 @@ class EmailCollector extends CommonObject } else { // Nothing can be done for this param $errorforactions++; - $this->error = 'The extract rule to use to load thirdparty has an unknown source (must be HEADER, SUBJECT or BODY)'; + $this->error = 'The extract rule to use to load thirdparty for email '.$msgid.' has an unknown source (must be HEADER, SUBJECT or BODY)'; $this->errors[] = $this->error; + + $operationslog .= '
    '.$this->error; } } elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $reg)) { //if (preg_match('/^options_/', $tmpproperty)) $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $reg[1]; @@ -2277,19 +2290,19 @@ class EmailCollector extends CommonObject if ($propertytooverwrite == 'id') { $idtouseforthirdparty = $reg[2]; - $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.'We set property idtouseforthrdparty='.dol_escape_htmltag($idtouseforthirdparty); + $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.' We set property idtouseforthrdparty='.dol_escape_htmltag($idtouseforthirdparty); } elseif ($propertytooverwrite == 'email') { $emailtouseforthirdparty = $reg[2]; - $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.'We set property emailtouseforthrdparty='.dol_escape_htmltag($emailtouseforthirdparty); + $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.' We set property emailtouseforthrdparty='.dol_escape_htmltag($emailtouseforthirdparty); } elseif ($propertytooverwrite == 'name') { $nametouseforthirdparty = $reg[2]; - $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.'We set property nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty); + $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.' We set property nametouseforthirdparty='.dol_escape_htmltag($nametouseforthirdparty); } elseif ($propertytooverwrite == 'name_alias') { $namealiastouseforthirdparty = $reg[2]; - $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.'We set property namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty); + $operationslog .= '
    propertytooverwrite='.$propertytooverwrite.' We set property namealiastouseforthirdparty='.dol_escape_htmltag($namealiastouseforthirdparty); } } else { $errorforactions++; @@ -3498,4 +3511,24 @@ class EmailCollector extends CommonObject return $subject; } + + /** + * Remove EMoji from email content + * + * @param string $text String to sanitize + * @return string Sanitized string + */ + protected function removeEmoji($text) + { + // Supprimer les caractères emoji en utilisant une expression régulière + $text = preg_replace('/[\x{1F600}-\x{1F64F}]/u', '', $text); + $text = preg_replace('/[\x{1F300}-\x{1F5FF}]/u', '', $text); + $text = preg_replace('/[\x{1F680}-\x{1F6FF}]/u', '', $text); + $text = preg_replace('/[\x{2600}-\x{26FF}]/u', '', $text); + $text = preg_replace('/[\x{2700}-\x{27BF}]/u', '', $text); + $text = preg_replace('/[\x{1F900}-\x{1F9FF}]/u', '', $text); + $text = preg_replace('/[\x{1F1E0}-\x{1F1FF}]/u', '', $text); + + return $text; + } } diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 53b16462651..51e3f06be26 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -105,9 +105,9 @@ class ConferenceOrBooth extends ActionComm public $fields = array( 'id' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'csslist'=>'left', 'comment'=>"Id"), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'help'=>"OrganizationEvenLabelName", 'showoncombobox'=>'1', 'autofocusoncreate'=>1), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax150', 'help'=>"OrganizationEvenLabelName", 'showoncombobox'=>'1', 'autofocusoncreate'=>1), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:(t.usage_organize_event:=:1)', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'position'=>52, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'project', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax100'), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'csslist'=>'tdoverflowmax125', 'css'=>'maxwidth500'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'csslist'=>'tdoverflowmax100', 'css'=>'maxwidth500'), 'note' => array('type'=>'html', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3), 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width100', 'csslist'=>'tdoverflowmax100'), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'2',), diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index fff9a14b78a..5544f790585 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -71,6 +71,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects +$project = new Project($db); $object = new ConferenceOrBooth($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; @@ -155,7 +156,6 @@ if (!$permissiontoread) accessforbidden(); */ if (preg_match('/^set/', $action) && ($projectid > 0 || $projectref) && !empty($user->rights->eventorganization->write)) { - $project = new Project($db); //If "set" fields keys is in projects fields $project_attr=preg_replace('/^set/', '', $action); if (array_key_exists($project_attr, $project->fields)) { @@ -163,6 +163,7 @@ if (preg_match('/^set/', $action) && ($projectid > 0 || $projectref) && !empty($ if ($result < 0) { setEventMessages(null, $project->errors, 'errors'); } else { + $projectid = $project->id; $project->{$project_attr}=GETPOST($project_attr); $result=$project->update($user); if ($result < 0) { @@ -239,7 +240,6 @@ $morejs = array(); $morecss = array(); if ($projectid > 0 || $projectref) { - $project = new Project($db); $result = $project->fetch($projectid, $projectref); if ($result < 0) { setEventMessages(null, $project->errors, 'errors'); @@ -641,6 +641,12 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +if ($project->id > 0) { + $param .= '&projectid='.((int) $project->id); +} foreach ($search as $key => $val) { if (is_array($search[$key])) { foreach ($search[$key] as $skey) { @@ -656,9 +662,6 @@ foreach ($search as $key => $val) { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Add $param from hooks diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index df3c966d3b8..d659769d7a3 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -358,7 +358,6 @@ if (empty($reshook)) { //var_dump($batch_line[2]); if (($totalqty > 0 || !empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) && !$error) { // There is at least one thing to ship and no error - //var_dump($_POST);exit; for ($i = 0; $i < $num; $i++) { $qty = "qtyl".$i; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 9f6516838c9..1108bd7446b 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -739,6 +739,7 @@ if (empty($reshook)) { // Actions on extra fields $result = $object->insertExtraFields('INTERVENTION_MODIFY'); if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); $error++; } } diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 196e0be75f2..5883d0e25e6 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '18.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '18.0.0-beta'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 816580d3167..88f0ce47d4e 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Frédéric France * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -186,6 +187,7 @@ class PaiementFourn extends Paiement } $currencyofpayment = ''; + $currencytxofpayment = ''; foreach ($amounts as $key => $value) { if (empty($value)) { @@ -207,6 +209,9 @@ class PaiementFourn extends Paiement $this->error = 'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment'; return -1; } + if (empty($currencytxofpayment)) { + $currencytxofpayment = $this->multicurrency_tx[$key]; + } $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); @@ -264,8 +269,8 @@ class PaiementFourn extends Paiement $facid = $key; if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount, multicurrency_amount)'; - $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).', '.((float) $this->multicurrency_amounts[$key]).')'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)'; + $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).', '.((float) $this->multicurrency_amounts[$key]).', '.($currencyofpayment ? '"'.$this->db->escape($currencyofpayment).'"' : 'NULL').', '.(!empty($currencytxofpayment) ? (double) $currencytxofpayment : 1).')'; $resql = $this->db->query($sql); if ($resql) { $invoice = new FactureFournisseur($this->db); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 5d4f6346af3..731480db581 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2663,10 +2663,7 @@ if ($action == 'create') { //print ''.$langs->trans("ToOrder").''; print ''.$langs->trans("OrderDate").''; $date_com = dol_mktime(GETPOST('rehour', 'int'), GETPOST('remin', 'int'), GETPOST('resec', 'int'), GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($date_com)) { - $date_com = dol_now(); - } - print $form->selectDate($date_com, '', 1, 1, '', "commande", 1, 1); + print $form->selectDate($date_com ?: '', '', 0, 0, '', "commande", 1, 1); print ''; // Force mandatory order method diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index e98bc12cba2..1410b9fe9f9 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -75,6 +75,7 @@ $confirm = GETPOST("confirm"); $ref = GETPOST('ref', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = ''; $lineid = GETPOST('lineid', 'int'); $projectid = GETPOST('projectid', 'int'); @@ -3154,7 +3155,6 @@ if ($action == 'create') { $thirdparty = $societe; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print ''; diff --git a/htdocs/fourn/facture/list-rec.php b/htdocs/fourn/facture/list-rec.php index e3c4ed0fcea..b957726f69e 100644 --- a/htdocs/fourn/facture/list-rec.php +++ b/htdocs/fourn/facture/list-rec.php @@ -709,7 +709,7 @@ if ($resql) { } } if (!empty($arrayfields['s.nom']['checked'])) { - print ''.$companystatic->getNomUrl(1, 'customer').''; + print ''.$companystatic->getNomUrl(1, 'supplier').''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 6429814bd24..4f49d0166e5 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -12,6 +12,7 @@ * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2021 Charlene Benke * Copyright (C) 2022 Udo Tamm + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -270,6 +271,7 @@ if (empty($reshook)) { $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $multicurrency_code = array(); + $multicurrency_tx = array(); // Clean parameters amount if payment is for a credit note foreach ($amounts as $key => $value) { // How payment is dispatched @@ -280,6 +282,7 @@ if (empty($reshook)) { $amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched @@ -290,6 +293,7 @@ if (empty($reshook)) { $multicurrency_amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } //var_dump($amounts); @@ -310,6 +314,7 @@ if (empty($reshook)) { $paiement->amounts = $amounts; // Array of amounts $paiement->multicurrency_amounts = $multicurrency_amounts; $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching + $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching $paiement->paiementid = GETPOST('paiementid', 'int'); $paiement->num_payment = GETPOST('num_paiement', 'alphanohtml'); $paiement->note_private = GETPOST('comment', 'alpha'); diff --git a/htdocs/includes/.gitignore b/htdocs/includes/.gitignore new file mode 100644 index 00000000000..d7775f89292 --- /dev/null +++ b/htdocs/includes/.gitignore @@ -0,0 +1,2 @@ +/phpstan/ +/rector/ diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index 39772c45f77..5d72775f1b2 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -411,4 +411,20 @@ CREATE TABLE llx_c_invoice_subtype ( ALTER TABLE llx_c_invoice_subtype ADD UNIQUE INDEX uk_c_invoice_subtype (entity, code); -ALTER TABLE llx_projet ADD COLUMN fk_project int DEFAULT NULL; +ALTER TABLE llx_projet ADD COLUMN fk_project integer DEFAULT NULL; + +-- Upgrade default PDF models to the 'new' ones (eproved since 4 dolibarr versions from now) +--UPDATE llx_const SET value="eratosthene" WHERE name="COMMANDE_ADDON_PDF" and value="einstein"; +--UPDATE llx_const SET value="sponge" WHERE name="FACTURE_ADDON_PDF" and value="crabe"; +--UPDATE llx_const SET value="espadon" WHERE name="EXPEDITION_ADDON_PDF" and value="merou"; +--UPDATE llx_const SET value="cyan" WHERE name="PROPALE_ADDON_PDF" and value="azur"; +--UPDATE llx_const SET value="storm" WHERE name IN ("DELIVERY_ADDON_PDF","LIVRAISON_ADDON_PDF") and value="typhon"; +--UPDATE llx_const SET value="cornas" WHERE name="COMMANDE_SUPPLIER_ADDON_PDF" and value="muscadet"; + + +ALTER TABLE llx_c_propalst ADD COLUMN sortorder smallint DEFAULT 0; +ALTER TABLE llx_c_stcomm ADD COLUMN sortorder smallint DEFAULT 0; + +ALTER TABLE llx_element_time ADD COLUMN ref_ext varchar(32); + +ALTER TABLE llx_c_ziptown ADD COLUMN town_up varchar(180); diff --git a/htdocs/install/mysql/tables/llx_c_propalst.sql b/htdocs/install/mysql/tables/llx_c_propalst.sql index 7b3351a52b8..dca01ca1843 100644 --- a/htdocs/install/mysql/tables/llx_c_propalst.sql +++ b/htdocs/install/mysql/tables/llx_c_propalst.sql @@ -23,6 +23,7 @@ create table llx_c_propalst id smallint PRIMARY KEY, code varchar(12) NOT NULL, label varchar(128), + sortorder smallint DEFAULT 0, active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_stcomm.sql b/htdocs/install/mysql/tables/llx_c_stcomm.sql index f94ba35be7b..11118cd1767 100644 --- a/htdocs/install/mysql/tables/llx_c_stcomm.sql +++ b/htdocs/install/mysql/tables/llx_c_stcomm.sql @@ -24,6 +24,7 @@ create table llx_c_stcomm code varchar(24) NOT NULL, libelle varchar(128), picto varchar(128), + sortorder smallint DEFAULT 0, active tinyint default 1 NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_ziptown.sql b/htdocs/install/mysql/tables/llx_c_ziptown.sql index 2238d0d5dd4..741ec51c373 100644 --- a/htdocs/install/mysql/tables/llx_c_ziptown.sql +++ b/htdocs/install/mysql/tables/llx_c_ziptown.sql @@ -24,5 +24,6 @@ create table llx_c_ziptown fk_pays integer NOT NULL DEFAULT 0, -- Country id in llx_c_country zip varchar(10) NOT NULL, -- Zip code town varchar(180) NOT NULL, -- Town name + town_up varchar(180), -- Town name in upper case active tinyint NOT NULL DEFAULT 1 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_element_time.sql b/htdocs/install/mysql/tables/llx_element_time.sql index cf346a48ec0..395ca8ff075 100644 --- a/htdocs/install/mysql/tables/llx_element_time.sql +++ b/htdocs/install/mysql/tables/llx_element_time.sql @@ -17,6 +17,7 @@ CREATE TABLE llx_element_time( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref_ext varchar(32), -- reference into an external system (not used by dolibarr) fk_element integer NOT NULL, elementtype varchar(32) NOT NULL, element_date date, diff --git a/htdocs/install/mysql/tables/llx_oauth_state.sql b/htdocs/install/mysql/tables/llx_oauth_state.sql index 77093f6d1b4..02d9d066b7b 100644 --- a/htdocs/install/mysql/tables/llx_oauth_state.sql +++ b/htdocs/install/mysql/tables/llx_oauth_state.sql @@ -1,5 +1,5 @@ -- ============================================================================ --- Copyright (C) 2013 Laurent Destailleur +-- Copyright (C) 2013-23 Laurent Destailleur -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -15,6 +15,9 @@ -- along with this program. If not, see . -- ============================================================================ + +-- This table is deprecated. Still updated but no more read. + CREATE TABLE llx_oauth_state ( rowid integer AUTO_INCREMENT PRIMARY KEY, service varchar(36), diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index fd063b40a26..71929f7417d 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4227,10 +4227,17 @@ function migrate_delete_old_dir($db, $langs, $conf) */ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $force = 0) { + global $user; + if (count($listofmodule) == 0) { return 0; } + if (!is_object($user)) { + include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $user = new User($db); // To avoid error during migration + } + dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule))); foreach ($listofmodule as $moduletoreload => $reloadmode) { // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' @@ -4544,7 +4551,6 @@ function migrate_user_photospath() include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $fuser = new User($db); - if (!is_object($user)) { $user = $fuser; // To avoid error during migration } @@ -4631,7 +4637,6 @@ function migrate_user_photospath2() include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $fuser = new User($db); - if (!is_object($user)) { $user = $fuser; // To avoid error during migration } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d2fdc06de93..462b265f3d8 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2086,6 +2086,7 @@ EnterCalculationRuleIfPreviousFieldIsYes=Enter calculation rule if previous fiel SeveralLangugeVariatFound=Several language variants found RemoveSpecialChars=Remove special characters COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN_REGEX) +COMPANY_AQUARIUM_NO_PREFIX=Do not use prefix, only copy customer or supplier code COMPANY_DIGITARIA_CLEAN_REGEX=Regex filter to clean value (COMPANY_DIGITARIA_CLEAN_REGEX) COMPANY_DIGITARIA_UNIQUE_CODE=Duplicate not allowed RemoveSpecialWords=Clean certain words when generating sub-accounts for customers or suppliers @@ -2221,7 +2222,7 @@ ShowProjectLabel=Project Label PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME=Include alias in thirdparty name THIRDPARTY_ALIAS=Name thirdparty - Alias thirdparty ALIAS_THIRDPARTY=Alias thirdparty - Name thirdparty -PDFIn2Languages=Show labels into PDF in 2 different languages +PDFIn2Languages=Show labels in the PDF in 2 different languages (this feature may not work for some couple of languages) PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF. PDF_USE_A=Gererate PDF documents with format PDF/A instead of defaut format PDF FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book. @@ -2323,8 +2324,8 @@ DefaultOpportunityStatus=Default opportunity status (first status when lead is c IconAndText=Icon and text TextOnly=Text only -IconOnlyAllTextsOnHover=Icon only - All texts appears under icon on mouse hover menu bar -IconOnlyTextOnHover=Icon only - Text of icon appears under icon on mouse hover the icon +IconOnlyAllTextsOnHover=Icon only - All texts appears under icon on mouse over menu bar +IconOnlyTextOnHover=Icon only - Text of icon appears under icon on mouse over the icon IconOnly=Icon only - Text on tooltip only INVOICE_ADD_ZATCA_QR_CODE=Show the ZATCA QR code on invoices INVOICE_ADD_ZATCA_QR_CODEMore=Some Arabic countries need this QR Code on their invoices diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index dc417f47c4f..9c1bc1791ca 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -196,7 +196,8 @@ ConfirmClassifyPaidPartiallyReasonDiscount=Remaining unpaid (%s %s) is a ConfirmClassifyPaidPartiallyReasonDiscountNoVat=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I accept to lose the VAT on this discount. ConfirmClassifyPaidPartiallyReasonDiscountVat=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I recover the VAT on this discount without a credit note. ConfirmClassifyPaidPartiallyReasonBadCustomer=Bad customer -ConfirmClassifyPaidPartiallyReasonBankCharge=Deduction by bank (intermediary bank fees) +ConfirmClassifyPaidPartiallyReasonBankCharge=Deduction by bank (intermediary bank fee) +ConfirmClassifyPaidPartiallyReasonWithholdingTax=Withholding tax ConfirmClassifyPaidPartiallyReasonProductReturned=Products partially returned ConfirmClassifyPaidPartiallyReasonOther=Amount abandoned for other reason ConfirmClassifyPaidPartiallyReasonDiscountNoVatDesc=This choice is possible if your invoice has been provided with suitable comments. (Example «Only the tax corresponding to the price that has been actually paid gives rights to deduction») @@ -205,6 +206,7 @@ ConfirmClassifyPaidPartiallyReasonAvoirDesc=Use this choice if all other does no ConfirmClassifyPaidPartiallyReasonBadCustomerDesc=A bad customer is a customer that refuses to pay his debt. ConfirmClassifyPaidPartiallyReasonProductReturnedDesc=This choice is used when payment is not complete because some of products were returned ConfirmClassifyPaidPartiallyReasonBankChargeDesc=The unpaid amount is intermediary bank fees, deducted directly from the correct amount paid by the Customer. +ConfirmClassifyPaidPartiallyReasonWithholdingTaxDesc=The unpaid amount will never be paid as it is a withholding tax ConfirmClassifyPaidPartiallyReasonOtherDesc=Use this choice if all others are not suitable, for example in following situation:
    - payment not complete because some products were shipped back
    - amount claimed too important because a discount was forgotten
    In all cases, amount over-claimed must be corrected in accountancy system by creating a credit note. ConfirmClassifyAbandonReasonOther=Other ConfirmClassifyAbandonReasonOtherDesc=This choice will be used in all other cases. For example because you plan to create a replacing invoice. @@ -623,6 +625,7 @@ SituationTotalRayToRest=Remainder to pay without taxe PDFSituationTitle=Situation n° %d SituationTotalProgress=Total progress %d %% SearchUnpaidInvoicesWithDueDate=Search unpaid invoices with a due date = %s +SearchValidatedInvoicesWithDate=Search unpaid invoices with a validation date = %s NoPaymentAvailable=No payment available for %s PaymentRegisteredAndInvoiceSetToPaid=Payment registered and invoice %s set to paid SendEmailsRemindersOnInvoiceDueDate=Send reminder by email for validated and unpaid invoices diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 8af9e74759c..1dc31ad6761 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -506,4 +506,5 @@ TwoRecordsOfCompanyName=more than one record exists for this company, please con CompanySection=Company section ShowSocialNetworks=Show social networks HideSocialNetworks=Hide social networks - +ExternalSystemID=External system ID +IDOfPaymentInAnExternalSystem=ID of the payment mode into an external system (like Stripe, Paypal, ...) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index f8b9bfc1be3..9d0ed989a8f 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -313,6 +313,7 @@ ErrorCoherenceMenu=%s is required when %s is 'left' ErrorUploadFileDragDrop=There was an error while the file(s) upload ErrorUploadFileDragDropPermissionDenied=There was an error while the file(s) upload : Permission denied ErrorFixThisHere=Fix this here +ErrorTheUrlOfYourDolInstanceDoesNotMatchURLIntoOAuthSetup=Error: The URL of you current instance (%s) does not match the URL defined into your OAuth2 login setup (%s). Doing OAuth2 login in such a configuration is not allowed. # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 0665c507b3c..894c9de4f13 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -146,7 +146,7 @@ OrganizationEventLinkToThirdParty=Link to third party (customer, supplier or par OrganizationEvenLabelName=Public name of the conference or booth NewSuggestionOfBooth=Application for a booth -NewSuggestionOfConference=Application for a conference +NewSuggestionOfConference=Application to hold a conference # # Vote page diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 032d4008f00..ba800994837 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -41,6 +41,7 @@ EndSubscription=End of membership SubscriptionId=Contribution ID WithoutSubscription=Without membership WaitingSubscription=Membership pending +WaitingSubscriptionShort=Pending MemberId=Member Id MemberRef=Member Ref NewMember=New member diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 62ebfc53ef9..d0696e53c1a 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -319,4 +319,5 @@ StockTransferRightCreateUpdate=Create/Update stocks transfers StockTransferRightDelete=Delete stocks transfers BatchNotFound=Lot / serial not found for this product StockMovementWillBeRecorded=Stock movement will be recorded -StockMovementNotYetRecorded=Stock movement will not be affected by this step \ No newline at end of file +StockMovementNotYetRecorded=Stock movement will not be affected by this step +WarningThisWIllAlsoDeleteStock=Warning, this will also destroy all quantities in stock in the warehouse diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index b75da799cb2..5f9ca0e1f5e 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -200,7 +200,8 @@ TicketAssigned=Ticket is now assigned TicketChangeType=Change type TicketChangeCategory=Change analytic code TicketChangeSeverity=Change severity -TicketAddMessage=Add private message +TicketAddMessage=Add or send a message +TicketAddPrivateMessage=Add a private message MessageSuccessfullyAdded=Ticket added TicketMessageSuccessfullyAdded=Message successfully added TicketMessagesList=Message list @@ -274,6 +275,7 @@ TicketsDelayForFirstResponseTooLong=Too much time elapsed since ticket opening w TicketsDelayFromLastResponseTooLong=Too much time elapsed since last answer on this ticket. TicketNoContractFoundToLink=No contract was found to be automatically linked to this ticket. Please link a contract manually. TicketManyContractsLinked=Many contracts have been automatically linked to this ticket. Make sure to verify which should be chosen. +TicketRefAlreadyUsed=The reference [%s] is already used, your new reference is [%s] # # Logs diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index ba39ce47dc2..2bb8168c4c1 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -242,7 +242,7 @@ OppStatusPENDING=En attente OppStatusWON=Gagné OppStatusLOST=Perdu Budget=Budget -AllowToLinkFromOtherCompany=Permet de lier un élément avec un projet d'une autre société

    Valeurs prises en charge :
    - Garder vide : peut lier des éléments avec n'importe quel projet de la même société (par défaut)
    - "tous" : peut lier des éléments avec n'importe quel projet, même projets d'autres sociétés
    - Une liste d'identifiants tiers séparés par des virgules : permet de lier des éléments à n'importe quel projet de ces tiers (Exemple : 123,4795,53)
    +AllowToLinkFromOtherCompany=Permet de lier un élément avec un projet d'une autre société

    Valeurs prises en charge :
    - Garder vide : peut lier des éléments avec n'importe quel projet de la même société (par défaut)
    - "all" : peut lier des éléments avec n'importe quel projet, même projets d'autres sociétés
    - Une liste d'identifiants tiers séparés par des virgules : permet de lier des éléments à n'importe quel projet de ces tiers (Exemple : 123,4795,53)
    LatestProjects=Les %s derniers projets LatestModifiedProjects=Les %s derniers projets modifiés OtherFilteredTasks=Autres tâches filtrées diff --git a/htdocs/langs/fr_FR/ticket.lang b/htdocs/langs/fr_FR/ticket.lang index f7e92aa7066..1b37c50ddb5 100644 --- a/htdocs/langs/fr_FR/ticket.lang +++ b/htdocs/langs/fr_FR/ticket.lang @@ -198,7 +198,8 @@ TicketAssigned=Le ticket est à présent assigné TicketChangeType=Changer le type TicketChangeCategory=Changer le code analytique TicketChangeSeverity=Changer la sévérité -TicketAddMessage=Ajouter un message privé +TicketAddMessage=Ajouter ou envoyer un message +TicketAddPrivateMessage=Ajouter message privé MessageSuccessfullyAdded=Ticket créé TicketMessageSuccessfullyAdded=Message ajouté avec succès TicketMessagesList=Liste des messages diff --git a/htdocs/langs/tr_TR/main.lang b/htdocs/langs/tr_TR/main.lang index 87d13df4e03..aadab943fed 100644 --- a/htdocs/langs/tr_TR/main.lang +++ b/htdocs/langs/tr_TR/main.lang @@ -10,7 +10,7 @@ DIRECTION=ltr # DejaVuSans is for some Eastern languages, some Asian languages and some Arabic languages # freemono is for ru_RU or uk_UA, uz_UZ # freeserif is for Tamil -FONTFORPDF=helvetica +FONTFORPDF=DejaVuSans FONTSIZEFORPDF=10 SeparatorDecimal=, SeparatorThousand=. diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 594d0b6693e..760412955f1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -772,23 +772,33 @@ if (!defined('NOLOGIN')) { } } - $allowedmethodtopostusername = 2; + $allowedmethodtopostusername = 3; if (defined('MAIN_AUTHENTICATION_POST_METHOD')) { - $allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD'); + $allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD'); // Note a value of 2 is not compatible with some authentication methods that put username as GET parameter } - $usertotest = (!empty($_COOKIE['login_dolibarr']) ? preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['login_dolibarr']) : GETPOST("username", "alpha", $allowedmethodtopostusername)); + // TODO Remove use of $_COOKIE['login_dolibarr'] ? Replace $usertotest = with $usertotest = GETPOST("username", "alpha", $allowedmethodtopostusername); + $usertotest = (!empty($_COOKIE['login_dolibarr']) ? preg_replace('/[^a-zA-Z0-9_@\-\.]/', '', $_COOKIE['login_dolibarr']) : GETPOST("username", "alpha", $allowedmethodtopostusername)); $passwordtotest = GETPOST('password', 'none', $allowedmethodtopostusername); $entitytotest = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : (!empty($conf->entity) ? $conf->entity : 1)); - // Define if we received data to test the login. + // Define if we received the correct data to go into the test of the login with the checkLoginPassEntity(). $goontestloop = false; - if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) { + if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) { // For http basic login test $goontestloop = true; } - if ($dolibarr_main_authentication == 'forceuser' && !empty($dolibarr_auto_user)) { + if ($dolibarr_main_authentication == 'forceuser' && !empty($dolibarr_auto_user)) { // For automatic login with a forced user $goontestloop = true; } - if (GETPOST("username", "alpha", $allowedmethodtopostusername) || !empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode', 'alpha', 1)) { + if (GETPOST("username", "alpha", $allowedmethodtopostusername)) { // For posting the login form + $goontestloop = true; + } + if (GETPOST('openid_mode', 'alpha', 1)) { // For openid_connect ? + $goontestloop = true; + } + if (GETPOST('beforeoauthloginredirect', 'int') || GETPOST('afteroauthloginreturn')) { // For oauth login + $goontestloop = true; + } + if (!empty($_COOKIE['login_dolibarr'])) { // TODO For ? Remove this ? $goontestloop = true; } @@ -805,7 +815,7 @@ if (!defined('NOLOGIN')) { // Validation of login/pass/entity // If ok, the variable login will be returned // If error, we will put error message in session under the name dol_loginmesg - // Note authmode is an array for example: array('0'=>'dolibarr', '1'=>'google'); + // Note authmode is an array for example: array('0'=>'dolibarr', '1'=>'googleoauth'); if ($test && $goontestloop && (GETPOST('actionlogin', 'aZ09') == 'login' || $dolibarr_main_authentication != 'dolibarr')) { $login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode); if ($login === '--bad-login-validity--') { @@ -2292,6 +2302,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= ' '.$langs->trans("ShowCompanyInfos").''; $dropdownBody .= '
    '; + $dropdownBody .= '
    '.$langs->trans("Company").': '.dol_escape_htmltag($mysoc->name).''; if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') { $dropdownBody .= '
    '.$langs->transcountry("ProfId1", $mysoc->country_code).': '.dol_print_profids(getDolGlobalString("MAIN_INFO_SIREN"), 1).''; } @@ -2447,7 +2458,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '')

    - +
    '.$dropdownBody.'
    @@ -2913,7 +2924,7 @@ function top_menu_search() '; $dropDownHtml .= ' - + diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 86eaabcf670..56872c26289 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -370,7 +370,7 @@ $sql = preg_replace('/,\s*$/', '', $sql); // Add HAVING from hooks /* $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; */ diff --git a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php index b31a3ca08d5..47e3d8f475e 100644 --- a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php +++ b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2023 Alexandre Janniaux * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify @@ -56,10 +57,12 @@ class MyObjectTest extends PHPUnit\Framework\TestCase /** * Constructor * We save global variables into local variables + * + * @param string $name Name */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf, $user, $langs, $db; diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 36c5b2ea07d..79b90fc93fc 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Marcos García - * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2018-2023 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 @@ -254,7 +254,7 @@ if ($action == 'edit') { print ''; // Description -print ''.$langs->trans("Description").''; +print ''.$langs->trans("Description").''; if ($action == 'edit') { $doleditor = new DolEditor('nouveauxcommentaires', $object->description, '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); @@ -321,7 +321,7 @@ print ''; print ''; print $langs->trans("Author").''; if ($object->fk_user_creat > 0) { - print $userstatic->getLoginUrl(1); + print $userstatic->getLoginUrl(-1); } else { if ($action == 'edit') { print ''; @@ -428,7 +428,7 @@ if ($object->allow_comments) { print $langs->trans("AddACommentForPoll").'
    '; print '
    '."\n"; print $langs->trans("Name").': '."\n"; - print '
    '."\n"; + print '
    '."\n"; } print ''; diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 7d68f54023b..d9191278edd 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -481,7 +481,7 @@ if ($action == 'edit') { print ''; // Description -print ''.$langs->trans("Description").''; +print ''.$langs->trans("Description").''; if ($action == 'edit') { $doleditor = new DolEditor('nouveauxcommentaires', $object->description, '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); @@ -526,7 +526,7 @@ print ''; print ''; print $langs->trans("Author").''; if ($object->fk_user_creat) { - print $userstatic->getLoginUrl(1); + print $userstatic->getLoginUrl(-1); } else { print dol_htmlentities($object->nom_admin); } diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index 7679b63da09..bf51b1fe5df 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -391,7 +391,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // )); // } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToRefuse'), $text, 'confirm_refuse', $formquestion, '', 1, 250); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToRefuse'), '', 'confirm_refuse', $formquestion, '', 1, 250); } // Call Hook formConfirm diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index 84dcbbf2ab9..671b74a2714 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -191,7 +191,7 @@ if ($id > 0 || $ref) { $out = ''; $morehtmlcenter = ''; if (isModEnabled('agenda')) { - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok) { if (get_class($objproduct) == 'Product') { $out .= '&prodid='.$objproduct->id.'&origin=product&originid='.$id; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 50ac40b545a..99071758252 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -194,9 +194,9 @@ if ($object->id > 0) { $hookmanager->initHooks(array('productcard', 'globalcard')); // Permissions -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); -$usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)); +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'read')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); +$usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'supprimer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'supprimer'))); /* diff --git a/htdocs/product/document.php b/htdocs/product/document.php index af75cbc71ce..9b6876150d2 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -113,7 +113,7 @@ if ($object->id > 0) { restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); } -$permissiontoadd = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); +$permissiontoadd = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); /* diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 00b2a544d6e..f6a852b0c63 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -297,7 +297,7 @@ if (empty($reshook)) { $inventoryline->pmp_expected = price2num(GETPOST('expectedpmp_'.$lineid, 'alpha'), 'MS'); $resultupdate = $inventoryline->update($user); } - } else { + } elseif (GETPOSTISSET('id_' . $lineid)) { // Delete record $result = $inventoryline->fetch($lineid); if ($result > 0) { diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 644a4a80912..1ff093b096c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -11,7 +11,7 @@ * Copyright (C) 2013 Adolfo segura * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2020-2021 Open-DSI + * Copyright (C) 2020-2023 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,6 +44,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; +if (isModEnabled('accounting')) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +} if (isModEnabled('categorie')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; @@ -244,10 +247,10 @@ $arrayfields = array( 'p.numbuyprice'=>array('label'=>"BuyingPriceNumShort", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>43), 'p.pmp'=>array('label'=>"PMPValueShort", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>44), 'p.cost_price'=>array('label'=>"CostPrice", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>45), - 'p.seuil_stock_alerte'=>array('label'=>"StockLimit", 'checked'=>0, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>50), - 'p.desiredstock'=>array('label'=>"DesiredStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>51), - 'p.stock'=>array('label'=>"PhysicalStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>52), - 'stock_virtual'=>array('label'=>"VirtualStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->rights->stock->lire && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $virtualdiffersfromphysical), 'position'=>53), + 'p.seuil_stock_alerte'=>array('label'=>"StockLimit", 'checked'=>0, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>50), + 'p.desiredstock'=>array('label'=>"DesiredStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>51), + 'p.stock'=>array('label'=>"PhysicalStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES))), 'position'=>52), + 'stock_virtual'=>array('label'=>"VirtualStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $virtualdiffersfromphysical), 'position'=>53), 'p.tobatch'=>array('label'=>"ManageLotSerial", 'checked'=>0, 'enabled'=>(isModEnabled('productbatch')), 'position'=>60), 'p.fk_country'=>array('label'=>"Country", 'checked'=>0, 'position'=>100), 'p.fk_state'=>array('label'=>"State", 'checked'=>0, 'position'=>101), @@ -373,9 +376,9 @@ if (empty($reshook)) { $objectlabel = 'Products'; } - $permissiontoread = $user->rights->{$rightskey}->lire; - $permissiontodelete = $user->rights->{$rightskey}->supprimer; - $permissiontoadd = $user->rights->{$rightskey}->creer; + $permissiontoread = $user->hasRight($rightskey, 'lire'); + $permissiontodelete = $user->hasRight($rightskey, 'supprimer'); + $permissiontoadd = $user->hasRight($rightskey, 'creer'); $uploaddir = $conf->product->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -579,22 +582,22 @@ if ($search_finished >= 0 && $search_finished !== '') { $sql .= " AND p.finished = ".((int) $search_finished); } if ($search_accountancy_code_sell) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell', $search_accountancy_code_sell); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell', clean_account($search_accountancy_code_sell)); } if ($search_accountancy_code_sell_intra) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_intra', clean_account($search_accountancy_code_sell_intra)); } if ($search_accountancy_code_sell_export) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_export', $search_accountancy_code_sell_export); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_export', clean_account($search_accountancy_code_sell_export)); } if ($search_accountancy_code_buy) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy', $search_accountancy_code_buy); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy', clean_account($search_accountancy_code_buy)); } if ($search_accountancy_code_buy_intra) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_intra', clean_account($search_accountancy_code_buy_intra)); } if ($search_accountancy_code_buy_export) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', $search_accountancy_code_buy_export); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', clean_account($search_accountancy_code_buy_export)); } if (!empty($conf->global->PRODUCT_USE_UNITS) && $search_units) { $sql .= natural_search('cu.rowid', $search_units); @@ -807,15 +810,15 @@ $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); -if ($user->rights->{$rightskey}->supprimer) { +if ($user->hasRight($rightskey, 'supprimer')) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if ($user->rights->{$rightskey}->creer) { +if ($user->hasRight($rightskey, 'creer')) { $arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus"); $arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus"); $arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice"); } -if (isModEnabled('category') && $user->rights->{$rightskey}->creer) { +if (isModEnabled('category') && $user->hasRight($rightskey, 'creer')) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields', 'preupdateprice'))) { @@ -828,11 +831,11 @@ $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars i $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); if ($type === "") { - $perm = ($user->rights->produit->creer || $user->rights->service->creer); + $perm = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')); } elseif ($type == Product::TYPE_SERVICE) { - $perm = $user->rights->service->creer; + $perm = $user->hasRight('service', 'creer'); } elseif ($type == Product::TYPE_PRODUCT) { - $perm = $user->rights->produit->creer; + $perm = $user->hasRight('produit', 'creer'); } $oldtype = $type; $params = array(); @@ -1510,7 +1513,7 @@ while ($i < $imaxinloop) { } // STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock. - if ((isModEnabled('stock') && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock + if ((isModEnabled('stock') && $user->hasRight('stock', 'lire') && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock if ($product_static->type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Not a service $option = 'nobatch'; if (empty($arrayfields['stock_virtual']['checked'])) { @@ -2050,38 +2053,38 @@ while ($i < $imaxinloop) { } // Accountancy code sell if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { - print ''.$product_static->accountancy_code_sell.''; + print ''.length_accountg($product_static->accountancy_code_sell).''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { - print ''.$product_static->accountancy_code_sell_intra.''; + print ''.length_accountg($product_static->accountancy_code_sell_intra).''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { - print ''.$product_static->accountancy_code_sell_export.''; + print ''.length_accountg($product_static->accountancy_code_sell_export).''; if (!$i) { $totalarray['nbfield']++; } } // Accountancy code buy if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { - print ''.$product_static->accountancy_code_buy.''; + print ''.length_accountg($product_static->accountancy_code_buy).''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { - print ''.$product_static->accountancy_code_buy_intra.''; + print ''.length_accountg($product_static->accountancy_code_buy_intra).''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { - print ''.$product_static->accountancy_code_buy_export.''; + print ''.length_accountg($product_static->accountancy_code_buy_export).''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/product/note.php b/htdocs/product/note.php index 8354fa96029..a3f02813ee0 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -50,7 +50,7 @@ if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); } -$permissionnote = ($user->rights->produit->creer || $user->rights->service->creer); // Used by the include of actions_setnotes.inc.php +$permissionnote = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')); // Used by the include of actions_setnotes.inc.php if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { diff --git a/htdocs/product/price.php b/htdocs/product/price.php index c573a2a26c6..2c583fda1db 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1333,12 +1333,12 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been if (empty($reshook)) { if ($object->isVariant()) { - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print ''; } } else { if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print ''; } else { print '
    ' . $langs->trans("UpdateDefaultPrice") . '
    '; @@ -1346,7 +1346,7 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a } if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print ''; } else { print '
    ' . $langs->trans("AddCustomerPrice") . '
    '; @@ -1354,13 +1354,13 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a } if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print ''; } else { print '
    ' . $langs->trans("UpdateVAT") . '
    '; } - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print ''; } else { print '
    ' . $langs->trans("UpdateLevelPrices") . '
    '; @@ -1378,7 +1378,7 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a * Edit price area */ -if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->service->creer)) { +if ($action == 'edit_vat' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { print load_fiche_titre($langs->trans("UpdateVAT"), ''); print '
    '; @@ -2339,7 +2339,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''.price($object->price_min_ttc).''; print ''; print ''; - if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { + if ($user->hasRight('produit', 'supprimer') || $user->hasRight('service', 'supprimer')) { print ''; print 'id.'">'; print img_info($langs->trans('PriceByCustomerLog')); diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 3d72610736e..63abd714011 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -129,7 +129,7 @@ if (!empty($canvas)) { } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('productreassortlotlist')); +$hookmanager->initHooks(array('reassortlotlist')); // Security check if ($user->socid) { diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 2bdb1ad6d4a..c5209b725b5 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -153,7 +153,7 @@ if ($id > 0 || !empty($ref)) { if ($showmessage && $nboflines > 1) { print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; - } elseif ($user->rights->facture->lire) { + } elseif ($user->hasRight('facture', 'lire')) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; $sql .= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,"; $sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 8478a021b34..b1bee9165c5 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -413,7 +413,10 @@ if ($action == 'create') { // Confirm delete warehouse if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", '', 0, 2); + $formquestion = array( + array('type' => 'other', 'name' => 'info', 'label' => img_warning('').$langs->trans("WarningThisWIllAlsoDeleteStock"), 'morecss'=>'warning') + ); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", $formquestion, 0, 2); } // Call Hook formConfirm @@ -595,35 +598,60 @@ if ($action == 'create') { print '
    '; + $totalarray = array(); + $totalarray['val'] = array (); + $totalarray['pos'] = array (); + $totalarray['type'] = array (); + $totalarray['nbfield'] = 0; + // TODO Create $arrayfields with all fields to show print ''; print ""; - $parameters = array(); + $parameters = array('totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", "", "p.label", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("NumberOfUnit", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield'] += 3; + $totalarray['pos'][$totalarray['nbfield']] = 'totalunit'; + $totalarray['type'][$totalarray['nbfield']] = 'stock'; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print_liste_field_titre("Unit", "", "p.fk_unit", "&id=".$id, "", 'align="left"', $sortfield, $sortorder); + $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'units'; + $totalarray['type'][$totalarray['nbfield']] = 'string'; } + print_liste_field_titre($form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")), "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; + print_liste_field_titre("EstimatedStockValueShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'totalvalue'; + if (empty($conf->global->PRODUIT_MULTIPRICES)) { print_liste_field_titre("SellPriceMin", "", "p.price", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; } if (empty($conf->global->PRODUIT_MULTIPRICES)) { print_liste_field_titre("EstimatedStockValueSellShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'totalvaluesell'; } if ($user->rights->stock->mouvement->creer) { print_liste_field_titre(''); + $totalarray['nbfield']++; } if ($user->rights->stock->creer) { print_liste_field_titre(''); + $totalarray['nbfield']++; } // Hook fields - $parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "\n"; @@ -708,7 +736,7 @@ if ($action == 'create') { //print ''; print ''; - $parameters = array('obj'=>$objp); + $parameters = array('obj'=>$objp, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -807,34 +835,20 @@ if ($action == 'create') { } $db->free($resql); - // Total - print ''; - print ''; - print ''; - print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) { - print ''; - print ''; + $totalarray['val']['totalunit'] = $totalunit; + $totalarray['val']['totalvalue'] = price2num($totalvalue, 'MT'); + $totalarray['val']['totalvaluesell'] = price2num($totalvaluesell, 'MT'); + $totalarray['val']['units'] = $langs->trans($productstatic->getLabelOfUnit()); + + $parameters = array('totalarray' => &$totalarray); + // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListTotal', $parameters, $object); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors); } - if ($user->rights->stock->mouvement->creer) { - print ''; - } - - if ($user->rights->stock->creer) { - print ''; - } - - print ''; + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; } else { dol_print_error($db); } diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 5c9ec6849d3..3164060efd8 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -382,16 +382,28 @@ class Entrepot extends CommonObject // End call triggers } - $elements = array('stock_mouvement', 'product_stock', 'product_warehouse_properties'); - foreach ($elements as $table) { - if (!$error) { - $sql = "DELETE FROM ".$this->db->prefix().$table; - $sql .= " WHERE fk_entrepot = ".((int) $this->id); + if (!$error) { + $sql = "DELETE FROM ".$this->db->prefix()."product_batch"; + $sql .= " WHERE fk_product_stock IN (SELECT rowid FROM ".$this->db->prefix()."product_stock as ps WHERE ps.fk_entrepot = ".((int) $this->id).")"; + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } - $result = $this->db->query($sql); - if (!$result) { - $error++; - $this->errors[] = $this->db->lasterror(); + if (!$error) { + $elements = array('stock_mouvement', 'product_stock'); + foreach ($elements as $table) { + if (!$error) { + $sql = "DELETE FROM ".$this->db->prefix().$table; + $sql .= " WHERE fk_entrepot = ".((int) $this->id); + + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->errors[] = $this->db->lasterror(); + } } } } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index ea7c3e51d35..1d2f0817c20 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -104,9 +104,9 @@ if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $acti accessforbidden(); } -$permissiontoadd = $user->rights->projet->creer; -$permissiontodelete = $user->rights->projet->supprimer; -$permissiondellink = $user->rights->projet->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('projet', 'creer'); +$permissiontodelete = $user->hasRight('projet', 'supprimer'); +$permissiondellink = $user->hasRight('projet', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -1504,7 +1504,7 @@ if ($action == 'create' && $user->rights->projet->creer) { // Back to draft if (!getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') && !getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_PROJECT')) { - if ($object->statut != Project::STATUS_DRAFT && $user->rights->projet->creer) { + if ($object->statut != Project::STATUS_DRAFT && $user->hasRight('projet', 'creer')) { if ($userWrite > 0) { print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?action=confirm_setdraft&confirm=yes&token='.newToken().'&id='.$object->id, ''); } else { @@ -1514,7 +1514,7 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Modify - if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) { + if ($object->statut != Project::STATUS_CLOSED && $user->hasRight('projet', 'creer')) { if ($userWrite > 0) { print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id, ''); } else { @@ -1523,7 +1523,7 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Validate - if ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer) { + if ($object->statut == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer')) { if ($userWrite > 0) { print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER["PHP_SELF"].'?action=validate&token='.newToken().'&id='.$object->id, ''); } else { @@ -1570,7 +1570,7 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Clone - if ($user->rights->projet->creer) { + if ($user->hasRight('projet', 'creer')) { if ($userWrite > 0) { print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER["PHP_SELF"].'?action=clone&token='.newToken().'&id='.$object->id, ''); } else { @@ -1579,8 +1579,8 @@ if ($action == 'create' && $user->rights->projet->creer) { } // Delete - if ($user->rights->projet->supprimer || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) { - if ($userDelete > 0 || ($object->statut == Project::STATUS_DRAFT && $user->rights->projet->creer)) { + if ($user->hasRight('projet', 'supprimer') || ($object->statut == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer'))) { + if ($userDelete > 0 || ($object->statut == Project::STATUS_DRAFT && $user->hasRight('projet', 'creer'))) { print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, ''); } else { print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('Delete'), 'default', $_SERVER['PHP_SELF']. '#', '', false); @@ -1605,8 +1605,8 @@ if ($action == 'create' && $user->rights->projet->creer) { $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->project->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = ($user->rights->projet->lire && $userAccess > 0); - $delallowed = ($user->rights->projet->creer && $userWrite > 0); + $genallowed = ($user->hasRight('projet', 'lire') && $userAccess > 0); + $delallowed = ($user->hasRight('projet', 'creer') && $userWrite > 0); print $formfile->showdocuments('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 0, 0, '', '', '', '', '', $object); diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 8bf6769d8fa..d880ba1ad0d 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -16,10 +16,11 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; + +require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** * API class for projects @@ -29,7 +30,6 @@ */ class Tasks extends DolibarrApi { - /** * @var array $FIELDS Mandatory fields, checked when create and update object */ diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 82bbe79edf9..e2f180ed889 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1251,7 +1251,7 @@ class Task extends CommonObjectLine if (isset($this->timespent_note)) { $this->timespent_note = trim($this->timespent_note); } - if (empty($this->timespent_datehour)) { + if (empty($this->timespent_datehour) || ($this->timespent_date != $this->timespent_datehour)) { $this->timespent_datehour = $this->timespent_date; } @@ -1354,6 +1354,7 @@ class Task extends CommonObjectLine $sql .= " s.nom as thirdparty_name,"; $sql .= " s.email as thirdparty_email,"; $sql .= " ptt.rowid,"; + $sql .= " ptt.ref_ext,"; $sql .= " ptt.fk_element as fk_task,"; $sql .= " ptt.element_date as task_date,"; $sql .= " ptt.element_datehour as task_datehour,"; @@ -1404,6 +1405,7 @@ class Task extends CommonObjectLine $newobj->task_label = $obj->task_label; $newobj->timespent_line_id = $obj->rowid; + $newobj->timespent_line_ref_ext = $obj->ref_ext; $newobj->timespent_line_date = $this->db->jdate($obj->task_date); $newobj->timespent_line_datehour = $this->db->jdate($obj->task_datehour); $newobj->timespent_line_withhour = $obj->task_date_withhour; diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 4e7620476c4..19ecebb2214 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -84,7 +84,7 @@ $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. $result = restrictedArea($user, 'projet', $id, 'projet&project'); -$permissiontoadd = $user->rights->projet->creer; +$permissiontoadd = $user->hasRight('projet', 'creer'); /* diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index c72dcbccda8..9dc6090c3d7 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -425,7 +425,7 @@ $listofreferent = array( 'testnew'=>$user->hasRight('facture', 'creer'), 'test'=>isModEnabled('facture') && $user->hasRight('facture', 'lire')), 'proposal_supplier'=>array( - 'name'=>"SuppliersProposals", + 'name'=>"SupplierProposals", 'title'=>"ListSupplierProposalsAssociatedProject", 'class'=>'SupplierProposal', 'table'=>'supplier_proposal', @@ -492,7 +492,7 @@ $listofreferent = array( 'lang'=>'sendings', 'buttonnew'=>'CreateShipment', 'testnew'=>0, - 'test'=>$conf->expedition->enabled && $user->rights->expedition->lire), + 'test'=>$conf->expedition->enabled && $user->hasRight('expedition', 'lire')), 'mrp'=>array( 'name'=>"MO", 'title'=>"ListMOAssociatedProject", @@ -729,6 +729,9 @@ print ''; // Other options - $parameters = array(); + $parameters = array('arrayfields' => &$arrayfields); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -853,7 +853,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // Link to create task $linktocreatetaskParam = array(); $linktocreatetaskUserRight = false; - if ($user->rights->projet->all->creer || $user->rights->projet->creer) { + if ($user->hasRight('projet', 'all', 'creer') || $user->hasRight('projet', 'creer')) { if ($object->public || $userWrite > 0) { $linktocreatetaskUserRight = true; } else { @@ -1112,7 +1112,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $j = 0; $level = 0; $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields, $arrayofselected); } else { - $colspan = 11; + $colspan = count($arrayfields); if ($object->usage_bill_time) { $colspan += 2; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 8a0d976b379..1723325b6d6 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -707,8 +707,7 @@ if ($id > 0 || !empty($ref)) { // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $defaultthirdpartyid = $socid > 0 ? $socid : $object->project->socid; - $formactions->showactions($object, 'task', $defaultthirdpartyid, 1, '', 10, 'withproject='.$withproject); + $formactions->showactions($object, 'project_task', 0, 1, '', 10, 'withproject='.$withproject); print ''; } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 59423caa901..34ede115538 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -129,7 +129,7 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg'; } - print '
    '; + print '
    '; // Output html code for logo if ($urllogo) { @@ -149,7 +149,7 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ print '
    '; } - print ''; + print ''; print '
    '; } diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index d05ad3558c5..0bf197e7a5e 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -547,7 +547,7 @@ print '
    '."\n"; + $currentusername = $obj->name; + print ''."\n"; } //demande de confirmation pour modification de ligne @@ -659,7 +665,7 @@ while ($compteur < $num) { if ($compteur == $i) { print ''."\n"; } } @@ -676,7 +682,7 @@ if ($ligneamodifier < 0 && (!isset($_SESSION['nom']))) { if (isset($_SESSION['nom'])) { print ''.$_SESSION['nom']."\n"; } else { - print ''."\n"; + print ''."\n"; } print ''."\n"; @@ -701,7 +707,7 @@ if ($ligneamodifier < 0 && (!isset($_SESSION['nom']))) { print ''."\n"; } - // Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base + // Show button to add a new line into database print ''."\n"; print ''."\n"; } @@ -835,13 +841,13 @@ if ($comments) { } // Form to add comment -if ($object->allow_comments) { +if ($object->allow_comments && $currentusername) { print '
    '.$langs->trans("AddACommentForPoll")."
    \n"; print '
    '."\n"; print $langs->trans("Name").': '; - print '   '."\n"; - print '
    '."\n"; + print '   '."\n"; + print '
    '."\n"; print ''."\n"; print '
    '."\n"; // div add comment diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index 6c1f88ecb42..21b12419054 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -243,6 +243,8 @@ if (empty($reshook) && $action == 'add') { $errors = array_merge($errors, $thirdparty->errors); } elseif ($resultfetchthirdparty == 0) { // No thirdparty found + a payment is expected // Creation of a new thirdparty + $genericcompanyname = 'Unknown company'; + if (!empty($societe)) { $thirdparty->name = $societe; } else { @@ -508,7 +510,7 @@ if (empty($reshook) && $action == 'add') { } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); - complete_substitutions_array($substitutionarray, $outputlangs, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $project); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); @@ -516,10 +518,11 @@ if (empty($reshook) && $action == 'add') { $sendto = $thirdparty->email; $from = $conf->global->MAILING_EMAIL_FROM; $urlback = $_SERVER["REQUEST_URI"]; + $trackid = 'proj'.$project->id; $ishtml = dol_textishtml($texttosend); // May contain urls - $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml, '', '', $trackid); $result = $mailfile->sendfile(); if ($result) { diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php index c709cee8b4d..3c7212fa8c5 100644 --- a/htdocs/public/project/suggestconference.php +++ b/htdocs/public/project/suggestconference.php @@ -244,6 +244,8 @@ if (empty($reshook) && $action == 'add') { $errors = array_merge($errors, $thirdparty->errors); } elseif ($resultfetchthirdparty == 0) { // No thirdparty found + a payment is expected // Creation of a new thirdparty + $genericcompanyname = 'Unknown company'; + if (!empty($societe)) { $thirdparty->name = $societe; } else { @@ -439,7 +441,7 @@ if (empty($reshook) && $action == 'add') { } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); - complete_substitutions_array($substitutionarray, $outputlangs, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $project); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); @@ -447,10 +449,11 @@ if (empty($reshook) && $action == 'add') { $sendto = $thirdparty->email; $from = $conf->global->MAILING_EMAIL_FROM; $urlback = $_SERVER["REQUEST_URI"]; + $trackid = 'proj'.$project->id; $ishtml = dol_textishtml($texttosend); // May contain urls - $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml, '', '', $trackid); $result = $mailfile->sendfile(); if ($result) { diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 68cd4eb87d6..464f43cb1a7 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -117,12 +117,10 @@ if (empty($reshook)) { } if (GETPOST('addfile', 'alpha') && !GETPOST('save', 'alpha')) { - ////$res = $object->fetch('','',GETPOST('track_id')); - ////if($res > 0) - ////{ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - // Set tmp directory TODO Use a dedicated directory for temp mails files + // Set tmp directory + // TODO Use a dedicated directory for temporary emails files $vardir = $conf->ticket->dir_output; $upload_dir_tmp = $vardir.'/temp/'.session_id(); if (!dol_is_dir($upload_dir_tmp)) { @@ -131,7 +129,6 @@ if (empty($reshook)) { dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, '', 0); $action = 'create_ticket'; - ////} } // Remove file @@ -139,10 +136,11 @@ if (empty($reshook)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Set tmp directory + // TODO Use a dedicated directory for temporary emails files $vardir = $conf->ticket->dir_output.'/'; $upload_dir_tmp = $vardir.'/temp/'.session_id(); - // TODO Delete only files that was uploaded from email form + // TODO Delete only files that was uploaded from form dol_remove_file_process(GETPOST('removedfile'), 0, 0); $action = 'create_ticket'; } @@ -345,6 +343,7 @@ if (empty($reshook)) { } if (!$error) { + // Creation of the ticket $id = $object->create($user); if ($id <= 0) { $error++; @@ -465,14 +464,7 @@ if (empty($reshook)) { } // Copy files into ticket directory - $destdir = $conf->ticket->dir_output.'/'.$object->ref; - if (!dol_is_dir($destdir)) { - dol_mkdir($destdir); - } - foreach ($filename as $i => $val) { - dol_move($filepath[$i], $destdir.'/'.$filename[$i], 0, 1); - $formmail->remove_attached_files($i); - } + $object->copyFilesForTicket(''); //setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs'); diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index f97bdd15966..70f0b027559 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -86,7 +86,7 @@ print '

    '.(getDolGlobalString("TICKET_PUBLIC_TEXT_H print '
    '; print '

    '; -print '

    '.dol_escape_htmltag($langs->trans("CreateTicket")).'
    '; +print '

    '.dol_escape_htmltag($langs->trans("CreateTicket")).'
    '; print '

    '.dol_escape_htmltag($langs->trans("ViewMyTicketList")).'
    '; print '
    '.img_picto('', 'ticket', 'class="fa-15"').'
    '.dol_escape_htmltag($langs->trans("ShowTicketWithTrackId")).'
    '; print '
    '; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 31837b54d74..005c671fd43 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -234,6 +234,8 @@ if ($action == "view_ticketlist") { $param .= '&entity='.((int) $entity); } + $param .= '&token='.newToken(); + // Definition of fields for list $arrayfields = array( 't.datec' => array('label' => $langs->trans("Date"), 'checked' => 1), @@ -419,6 +421,7 @@ if ($action == "view_ticketlist") { // Search bar print '
    '."\n"; print ''; + print ''; print ''; print ''; print ''; @@ -500,7 +503,7 @@ if ($action == "view_ticketlist") { $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - // Status + // Status ticket if (!empty($arrayfields['t.fk_statut']['checked'])) { print '
    '; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -1917,6 +1911,9 @@ while ($i < $imaxinloop) { $i++; } +// Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script +$formcompany->selectProspectStatus('status_prospect', $prospectstatic, null, null, "js"); + // If no record found if ($num == 0) { $colspan = 1; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 4d00d056a82..cf0d59f6b89 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1076,14 +1076,15 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { $morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard'); } - print load_fiche_titre($langs->trans('CreditCard').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'fa-credit-card'); + print load_fiche_titre($langs->trans('CreditCard'), $morehtmlright, 'fa-credit-card'); + //($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)') print ''."\n"; print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
    '.dol_print_date($objp->datem).'
    '.$langs->trans("Total").''; - $valtoshow = price2num($totalunit, 'MS'); - if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) { - print empty($valtoshow) ? '0' : $valtoshow; - } - print ''; - if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) { - print $langs->trans($productstatic->getLabelOfUnit()); - } - print ''.price(price2num($totalvalue, 'MT')).' '.price(price2num($totalvaluesell, 'MT')).'  
    '; $tooltiponprofit = $langs->trans("ProfitIsCalculatedWith")."
    \n"; $tooltiponprofitplus = $tooltiponprofitminus = ''; foreach ($listofreferent as $key => $value) { + if (!empty($value['lang'])) { + $langs->load($value['lang']); + } $name = $langs->trans($value['name']); $qualified = $value['test']; $margin = empty($value['margin']) ? 0 : $value['margin']; @@ -988,7 +991,6 @@ foreach ($listofreferent as $key => $value) { $tablename = $value['table']; $datefieldname = $value['datefieldname']; $qualified = $value['test']; - $langtoload = empty($value['lang']) ? '' : $value['lang']; $urlnew = empty($value['urlnew']) ? '' : $value['urlnew']; $buttonnew = empty($value['buttonnew']) ? '' : $value['buttonnew']; $testnew = empty($value['testnew']) ? '' : $value['testnew']; @@ -1004,10 +1006,6 @@ foreach ($listofreferent as $key => $value) { // If we want the project task array to have details of users //if ($key == 'project_task') $key = 'project_task_time'; - if ($langtoload) { - $langs->load($langtoload); - } - $element = new $classname($db); $addform = ''; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 4d751918432..5d96adbd7fb 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -317,14 +317,14 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Project'; $objectlabel = 'Project'; - $permissiontoread = $user->rights->projet->lire; - $permissiontodelete = $user->rights->projet->supprimer; - $permissiontoadd = $user->rights->projet->creer; + $permissiontoread = $user->hasRight('projet', 'lire'); + $permissiontodelete = $user->hasRight('projet', 'supprimer'); + $permissiontoadd = $user->hasRight('projet', 'creer'); $uploaddir = $conf->project->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // Close records - if (!$error && $massaction == 'close' && $user->rights->projet->creer) { + if (!$error && $massaction == 'close' && $user->hasRight('projet', 'creer')) { $db->begin(); $objecttmp = new $objectclass($db); @@ -903,14 +903,14 @@ $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->projet->creer) { +if ($user->hasRight('projet', 'creer')) { $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close"); $arrayofmassactions['preaffectuser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AffectUser"); } -if ($user->rights->projet->supprimer) { +if ($user->hasRight('projet', 'supprimer')) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if (isModEnabled('category') && $user->rights->projet->creer) { +if (isModEnabled('category') && $user->hasRight('projet', 'creer')) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } if (in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preaffectuser'))) { @@ -930,7 +930,7 @@ if ($search_usage_event_organization == 1) { $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('projet', 'creer')); print ''; if ($optioncss != '') { @@ -950,7 +950,7 @@ $texthelp = ''; if ($search_project_user == $user->id) { $texthelp .= $langs->trans("MyProjectsDesc"); } else { - if ($user->rights->projet->all->lire && !$socid) { + if ($user->hasRight('projet', 'all', 'lire') && !$socid) { $texthelp .= $langs->trans("ProjectsDesc"); } else { $texthelp .= $langs->trans("ProjectsPublicDesc"); @@ -1001,7 +1001,7 @@ if ($user->rights->user->user->lire) { } // Filter on categories -if (isModEnabled('categorie') && $user->rights->categorie->lire) { +if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { $formcategory = new FormCategory($db); $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth300imp widthcentpercentminusx'); } diff --git a/htdocs/projet/messaging.php b/htdocs/projet/messaging.php index 09e49c41c0f..807008c78c5 100644 --- a/htdocs/projet/messaging.php +++ b/htdocs/projet/messaging.php @@ -161,7 +161,7 @@ print dol_get_fiche_end(); // Actions buttons $out = ''; -$permok = $user->rights->agenda->myactions->create; +$permok = $user->hasRight('agenda', 'myactions', 'create'); if ($permok) { $out .= '&projectid='.$object->id; } diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 3ca7949b35a..dd4672fa98b 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -50,7 +50,7 @@ $socid = 0; $hookmanager->initHooks(array('projetnote')); $result = restrictedArea($user, 'projet', $id, 'projet&project'); -$permissionnote = $user->rights->projet->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('projet', 'creer'); // Used by the include of actions_setnotes.inc.php /* diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index f0f98e3df6c..021537f1d58 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -240,8 +240,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Task'; $objectlabel = 'Tasks'; - $permissiontoread = $user->rights->projet->lire; - $permissiontodelete = $user->rights->projet->supprimer; + $permissiontoread = $user->hasRight('projet', 'lire'); + $permissiontodelete = $user->hasRight('projet', 'supprimer'); $uploaddir = $conf->project->dir_output.'/tasks'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -555,7 +555,7 @@ if ($id > 0 || !empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $arrayofmassactions = array(); - if ($user->rights->projet->creer) { + if ($user->hasRight('projet', 'creer')) { $arrayofmassactions['preclonetasks'] = img_picto('', 'rightarrow', 'class="pictofixedwidth"').$langs->trans("Clone"); } if ($permissiontodelete) { @@ -826,7 +826,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '
    '; if ($action == "dosign" && empty($cancel)) { print '
    '; print ''; - print ''; + print ''; print '
    '; print '
    '; // Do not use class="reposition" here: It breaks the submit and there is a message on top to say it's ok, so going back top is better. diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index b3459f7e36e..ec1f4829051 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -332,7 +332,7 @@ $toutsujet = str_replace("°", "'", $toutsujet); print '
    '.$langs->trans("YouAreInivitedToVote").'
    '; -print $langs->trans("OpenSurveyHowTo").'
    '; +print ''.$langs->trans("OpenSurveyHowTo").'
    '; if (empty($object->allow_spy)) { print ''.$langs->trans("YourVoteIsPrivate").'
    '; } else { @@ -340,17 +340,21 @@ if (empty($object->allow_spy)) { } print '
    '; -print '
    '."\n"; +if (empty($object->description)) { + print '
    '."\n"; +} // show title of survey $titre = str_replace("\\", "", $object->title); -print ''.dol_htmlentities($titre).''; +print ''.dol_htmlentities($titre).'
    '; + +if (!empty($object->description)) { + print '
    '."\n"; +} // show description of survey if ($object->description) { - print '

    '."\n"; print dol_htmlentitiesbr($object->description); - print '
    '."\n"; } print '
    '."\n"; @@ -465,6 +469,7 @@ if ($object->format == "D") { // Loop on each answer +$currentusername = ''; $sumfor = array(); $sumagainst = array(); $compteur = 0; @@ -561,7 +566,7 @@ while ($compteur < $num) { } } } else { - //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs + //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour saisie if ($compteur == $ligneamodifier) { for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); @@ -650,7 +655,8 @@ while ($compteur < $num) { // Button edit at end of line if ($compteur != $ligneamodifier && $mod_ok) { - print '
    '; print ''; - print ''; + print ''; print '
    '; $selected = ($search_fk_status != "non_closed" ? $search_fk_status : ''); diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index 12b319b7589..b6b576747e4 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -171,7 +171,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a if ($object->dao->close($user)) { setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); - $url = 'view.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha').(!empty($entity) && isModEnabled('multicompany')?'&entity='.$entity:''); + $url = 'view.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha').(!empty($entity) && isModEnabled('multicompany')?'&entity='.$entity:'').'&token='.newToken(); header("Location: ".$url); exit; } else { @@ -380,11 +380,11 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a if ($object->dao->fk_statut < Ticket::STATUS_CLOSED) { // New message - print ''; + print ''; // Close ticket if ($object->dao->fk_statut >= Ticket::STATUS_NOT_READ && $object->dao->fk_statut < Ticket::STATUS_CLOSED) { - print ''; + print ''; } } diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 71fbe249031..d3f223acc8e 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -674,6 +674,30 @@ class RecruitmentCandidature extends CommonObject return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'RECRUITMENTCANDIDATURE_REOPEN'); } + /** + * Return full name ('name+' '+lastname) + * + * @param Translate $langs Language object for translation of civility (used only if option is 1) + * @param int $option 0=No option + * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname, 4=Lastname, 5=Lastname if defined else firstname + * @param int $maxlen Maximum length + * @return string String with full name + */ + public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0) + { + $lastname = $this->lastname; + $firstname = $this->firstname; + if (empty($lastname)) { + $lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : ''))))); + } + + $ret = ''; + + $ret .= dolGetFirstLastname($firstname, $lastname, $nameorder); + + return dol_trunc($ret, $maxlen); + } + /** * Return a link to the object card (with optionaly the picto) * diff --git a/htdocs/rector.php b/htdocs/rector.php new file mode 100644 index 00000000000..987cba2ce17 --- /dev/null +++ b/htdocs/rector.php @@ -0,0 +1,99 @@ +paths([ + __DIR__ . '/accountancy', + /* __DIR__ . '/adherents', + __DIR__ . '/admin', + __DIR__ . '/api', + __DIR__ . '/asset', + __DIR__ . '/asterisk', + __DIR__ . '/barcode', + __DIR__ . '/blockedlog', + __DIR__ . '/bom', + __DIR__ . '/bookcal', + __DIR__ . '/bookmarks', + __DIR__ . '/categories', + __DIR__ . '/collab', + __DIR__ . '/comm', + __DIR__ . '/commande', + __DIR__ . '/compta', + __DIR__ . '/conf', + __DIR__ . '/contact', + __DIR__ . '/contrat', + __DIR__ . '/core', + __DIR__ . '/cron', + __DIR__ . '/custom', + __DIR__ . '/datapolicy', + __DIR__ . '/dav', + __DIR__ . '/debugbar', + __DIR__ . '/delivery', + __DIR__ . '/don', + __DIR__ . '/ecm', + __DIR__ . '/emailcollector', + __DIR__ . '/eventorganization', + __DIR__ . '/expedition', + __DIR__ . '/expensereport', + __DIR__ . '/exports', + __DIR__ . '/externalsite', + __DIR__ . '/fichinter', + __DIR__ . '/fourn', + __DIR__ . '/ftp', + __DIR__ . '/holiday', + __DIR__ . '/hrm', + __DIR__ . '/imports', + __DIR__ . '/install', + __DIR__ . '/intracommreport', + __DIR__ . '/knowledgemanagement', + __DIR__ . '/loan', + __DIR__ . '/mailmanspip', + __DIR__ . '/margin', + __DIR__ . '/mrp', + __DIR__ . '/multicurrency', + __DIR__ . '/opensurvey', + __DIR__ . '/partnership', + __DIR__ . '/paybox', + __DIR__ . '/paypal', + __DIR__ . '/printing', + __DIR__ . '/product', + __DIR__ . '/projet', + __DIR__ . '/public', + __DIR__ . '/reception', + __DIR__ . '/recruitment', + __DIR__ . '/resource', + __DIR__ . '/salaries', + __DIR__ . '/societe', + __DIR__ . '/stripe', + __DIR__ . '/supplier_proposal', + __DIR__ . '/support', + __DIR__ . '/takepos', + __DIR__ . '/theme', + __DIR__ . '/ticket', + __DIR__ . '/user', + __DIR__ . '/webhook', + __DIR__ . '/webservices', + __DIR__ . '/website', + __DIR__ . '/workstation', + __DIR__ . '/zapier',*/ + ]); + + // register a single rule + $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); + + // define sets of rules + $rectorConfig->sets([ + //LevelSetList::UP_TO_PHP_81, + SetList::CODE_QUALITY, + SetList::CODING_STYLE, + SetList::DEAD_CODE, + SetList::EARLY_RETURN, + SetList::NAMING + ]); +}; diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php index eeae4e77731..d0a398279c5 100644 --- a/htdocs/societe/class/client.class.php +++ b/htdocs/societe/class/client.class.php @@ -108,10 +108,13 @@ class Client extends Societe { global $langs; - $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm"; + $sql = "SELECT id, code, libelle as label, picto, sortorder"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm"; if ($active >= 0) { $sql .= " WHERE active = ".((int) $active); } + $sql .= $this->db->order('sortorder,id', 'ASC,ASC'); + $resql = $this->db->query($sql); $num = $this->db->num_rows($resql); $i = 0; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 287114d0f1e..70d7fd508a8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4702,49 +4702,50 @@ class Societe extends CommonObject { // phpcs:enable global $langs; + $langs->load('customers'); if ($mode == 2) { if ($status == '-1' || $status == 'ST_NO') { - return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + return img_action($langs->trans("StatusProspect-1"), -1, $picto, 'class="inline-block valignmiddle"').' '.$langs->trans("StatusProspect-1"); } elseif ($status == '0' || $status == 'ST_NEVER') { - return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + return img_action($langs->trans("StatusProspect0"), 0, $picto, 'class="inline-block valignmiddle"').' '.$langs->trans("StatusProspect0"); } elseif ($status == '1' || $status == 'ST_TODO') { - return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + return img_action($langs->trans("StatusProspect1"), 1, $picto, 'class="inline-block valignmiddle"').' '.$langs->trans("StatusProspect1"); } elseif ($status == '2' || $status == 'ST_PEND') { - return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + return img_action($langs->trans("StatusProspect2"), 2, $picto, 'class="inline-block valignmiddle"').' '.$langs->trans("StatusProspect2"); } elseif ($status == '3' || $status == 'ST_DONE') { - return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); + return img_action($langs->trans("StatusProspect3"), 3, $picto, 'class="inline-block valignmiddle"').' '.$langs->trans("StatusProspect3"); } else { - return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); + return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0, $picto, 'class="inline-block valignmiddle"').' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); } } elseif ($mode == 3) { if ($status == '-1' || $status == 'ST_NO') { - return img_action($langs->trans("StatusProspect-1"), -1, $picto); + return img_action($langs->trans("StatusProspect-1"), -1, $picto, 'class="inline-block valignmiddle"'); } elseif ($status == '0' || $status == 'ST_NEVER') { - return img_action($langs->trans("StatusProspect0"), 0, $picto); + return img_action($langs->trans("StatusProspect0"), 0, $picto, 'class="inline-block valignmiddle"'); } elseif ($status == '1' || $status == 'ST_TODO') { - return img_action($langs->trans("StatusProspect1"), 1, $picto); + return img_action($langs->trans("StatusProspect1"), 1, $picto, 'class="inline-block valignmiddle"'); } elseif ($status == '2' || $status == 'ST_PEND') { - return img_action($langs->trans("StatusProspect2"), 2, $picto); + return img_action($langs->trans("StatusProspect2"), 2, $picto, 'class="inline-block valignmiddle"'); } elseif ($status == '3' || $status == 'ST_DONE') { - return img_action($langs->trans("StatusProspect3"), 3, $picto); + return img_action($langs->trans("StatusProspect3"), 3, $picto, 'class="inline-block valignmiddle"'); } else { - return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0, $picto); + return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0, $picto, 'class="inline-block valignmiddle"'); } } elseif ($mode == 4) { if ($status == '-1' || $status == 'ST_NO') { - return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + return img_action($langs->trans("StatusProspect-1"), -1, $picto, 'class="inline-block valignmiddle"').' '.$langs->trans("StatusProspect-1"); } elseif ($status == '0' || $status == 'ST_NEVER') { - return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + return img_action($langs->trans("StatusProspect0"), 0, $picto, 'class="inline-block valignmiddle"').' '.$langs->trans("StatusProspect0"); } elseif ($status == '1' || $status == 'ST_TODO') { - return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + return img_action($langs->trans("StatusProspect1"), 1, $picto, 'class="inline-block valignmiddle"').' '.$langs->trans("StatusProspect1"); } elseif ($status == '2' || $status == 'ST_PEND') { - return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + return img_action($langs->trans("StatusProspect2"), 2, $picto, 'class="inline-block valignmiddle"').' '.$langs->trans("StatusProspect2"); } elseif ($status == '3' || $status == 'ST_DONE') { - return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); + return img_action($langs->trans("StatusProspect3"), 3, $picto, 'class="inline-block valignmiddle"').' '.$langs->trans("StatusProspect3"); } else { - return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); + return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0, $picto, 'class="inline-block valignmiddle"').' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); } } diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 5b993769449..c25713959d2 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -148,6 +148,7 @@ if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field } //if (isModEnabled('agenda') && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); +$elementTypeArray = array(); if ($object->client) { print '
    '; diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index a74d4ff3ae0..e3596f384d7 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -130,7 +130,7 @@ if ($result) { if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; } - if (((isModEnabled('fournisseur') && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled('supplier_order') && $user->rights->supplier_order->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { + if (((isModEnabled('fournisseur') && $user->hasRight('fournisseur', 'facture', 'lire') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled('supplier_order') && $user->hasRight('supplier_order', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire'))) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third['supplier']++; } if (isModEnabled('societe') && $objp->client == 0 && $objp->fournisseur == 0) { @@ -156,7 +156,7 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { $dataseries[] = array($langs->trans("Customers"), round($third['customer'])); } - if (((isModEnabled('fournisseur') && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled('supplier_order') && $user->rights->supplier_order->lire) || (isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) { + if (((isModEnabled('fournisseur') && $user->hasRight('fournisseur', 'facture', 'lire') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled('supplier_order') && $user->hasRight('supplier_order', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire'))) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) { $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier'])); } if (isModEnabled('societe')) { diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index d0f20cd5296..42ecf21c27b 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -996,8 +996,8 @@ if ($contextpage != 'poslist') { $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->rights->societe->creer); -} elseif ($user->rights->societe->creer) { + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->hasRight('societe', 'creer')); +} elseif ($user->hasRight('societe', 'creer')) { $url = DOL_URL_ROOT.'/societe/card.php?action=create&type=t&contextpage=poslist&optioncss=print&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type=t&contextpage=poslist&nomassaction=1&optioncss=print&place='.$place); $label = 'MenuNewCustomer'; $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url); @@ -1826,20 +1826,14 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['s.fk_stcomm']['checked'])) { // Prospect status - print '
    '; - print '
    '; - print $companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); - print '
    -
    '; - foreach ($prospectstatic->cacheprospectstatus as $key => $val) { - $titlealt = 'default'; - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { - $titlealt = $val['label']; - } - if ($obj->stcomm_id != $val['id']) { - print ''.img_action($titlealt, $val['code'], $val['picto']).''; - } - } - print '
    '; + + $prospectid = $obj->rowid; + $statusprospect = $obj->stcomm_id; + + $formcompany->selectProspectStatus('status_prospect', $prospectstatic, $statusprospect, $prospectid); + + print '
    '."\n"; print ''; print ''; - print ''; // external system ID + print ''; // external system ID print ''; print ''; print ''; @@ -1762,6 +1763,10 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' dol_print_error($db); } + //Hook to display your print listing (list of CB card from Stancer Plugin for example) + $parameters = array('arrayfields'=>array(), 'param'=>'', 'sortfield'=>'', 'sortorder'=>'', 'linetype'=>''); + $reshook = $hookmanager->executeHooks('printNewTable', $parameters, $object); + print $hookmanager->resPrint; if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) { print '
    '; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index dae56b10c53..30834382687 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -528,7 +528,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { */ print "\n".'
    '."\n"; - if ($user->rights->produit->creer || $user->rights->service->creer) { + if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { print ''; } print "\n
    \n"; @@ -639,7 +639,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { } } else { $colspan = 10; - if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { + if ($user->hasRight('produit', 'supprimer') || $user->hasRight('service', 'supprimer')) { $colspan += 1; } print ''; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 80c144f43ba..676dd851400 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -633,7 +633,7 @@ if (empty($reshook)) { $error++; } - if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && GETPOST('multicurrency_price_ht') === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPrice")), null, 'errors'); $error++; } @@ -1815,48 +1815,55 @@ if ($action == 'create') { print '
    '.$langs->trans('Label').''.$langs->trans('StripeID').''.$form->textwithpicto($langs->trans('ExternalSystemID'), $langs->trans("IDOfPaymentInAnExternalSystem")).''.$langs->trans('Type').''.$langs->trans('Informations').'
    '.$langs->trans('None').'
    '; - if (isModEnabled("multicurrency") && ($object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount HT - print ''; - print ''; - print ''; - - // Multicurrency Amount VAT - print ''; - print ''; - print ''; - - // Multicurrency Amount TTC - print ''; - print ''; - print ''; - } - + print ''; // Amount HT - print ''; - print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount HT + print ''; + } print ''; + print ''; // Amount VAT - print ''; - print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount VAT + print ''; + } print ''; // Amount Local Taxes - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { // Localtax1 - print ''; - print ''; - print ''; - } - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { // Localtax2 - print ''; - print ''; + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } print ''; + + print ''; + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + } } + print ''; // Amount TTC - print ''; - print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount TTC + print ''; + } print ''; print '
    '.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    '.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    '.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
    '.$langs->trans('AmountHT').''.price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency).'' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
    '.$langs->trans('AmountVAT').''.price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency).'' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
    '.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency).'
    '.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency).'
    ' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
    ' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
    '.$langs->trans('AmountTTC').''.price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency).'' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
    '; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index ffe6423fc22..4fec294aeaa 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -3161,7 +3161,7 @@ class SupplierProposalLine extends CommonObjectLine $sql .= " ".price2num($this->localtax2_tx).","; $sql .= " '".$this->db->escape($this->localtax1_type)."',"; $sql .= " '".$this->db->escape($this->localtax2_type)."',"; - $sql .= " ".(!empty($this->subprice) ? price2num($this->subprice, 'MU') : "null").","; + $sql .= " ".price2num($this->subprice, 'MU') .","; $sql .= " ".((float) $this->remise_percent).","; $sql .= " ".(isset($this->info_bits) ? ((int) $this->info_bits) : "null").","; $sql .= " ".price2num($this->total_ht, 'MT').","; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 91a28a6110a..3105a88450b 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -142,7 +142,6 @@ if (!empty($socid)) { $module = 'societe'; $dbtable = '&societe'; } -$result = restrictedArea($user, $module, $objectid, $dbtable); $diroutputmassaction = $conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id; @@ -199,6 +198,10 @@ 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'); +$result = restrictedArea($user, $module, $objectid, $dbtable); + +$permissiontoread = $user->rights->supplier_proposal->lire; +$permissiontodelete = $user->rights->supplier_proposal->supprimer; /* @@ -206,7 +209,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -218,70 +222,65 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - -// Do we click on purge search criteria ? -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $search_categ = ''; - $search_user = ''; - $search_sale = ''; - $search_ref = ''; - $search_societe = ''; - $search_societe_alias = ''; - $search_montant_ht = ''; - $search_montant_vat = ''; - $search_montant_ttc = ''; - $search_multicurrency_code = ''; - $search_multicurrency_tx = ''; - $search_multicurrency_montant_ht = ''; - $search_multicurrency_montant_vat = ''; - $search_multicurrency_montant_ttc = ''; - $search_login = ''; - $search_product_category = ''; - $search_town = ''; - $search_zip = ""; - $search_state = ""; - $search_type = ''; - $search_country = ''; - $search_type_thirdparty = ''; - $search_date_startday = ''; - $search_date_startmonth = ''; - $search_date_startyear = ''; - $search_date_endday = ''; - $search_date_endmonth = ''; - $search_date_endyear = ''; - $search_date_start = ''; - $search_date_end = ''; - $search_date_valid_startday = ''; - $search_date_valid_startmonth = ''; - $search_date_valid_startyear = ''; - $search_date_valid_endday = ''; - $search_date_valid_endmonth = ''; - $search_date_valid_endyear = ''; - $search_date_valid_start = ''; - $search_date_valid_end = ''; - $search_status = ''; - $object_statut = ''; -} - if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_ref = ''; + $search_societe = ''; + $search_societe_alias = ''; + $search_montant_ht = ''; + $search_montant_vat = ''; + $search_montant_ttc = ''; + $search_multicurrency_code = ''; + $search_multicurrency_tx = ''; + $search_multicurrency_montant_ht = ''; + $search_multicurrency_montant_vat = ''; + $search_multicurrency_montant_ttc = ''; + $search_login = ''; + $search_product_category = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_date_startday = ''; + $search_date_startmonth = ''; + $search_date_startyear = ''; + $search_date_endday = ''; + $search_date_endmonth = ''; + $search_date_endyear = ''; + $search_date_start = ''; + $search_date_end = ''; + $search_date_valid_startday = ''; + $search_date_valid_startmonth = ''; + $search_date_valid_startyear = ''; + $search_date_valid_endday = ''; + $search_date_valid_endmonth = ''; + $search_date_valid_endyear = ''; + $search_date_valid_start = ''; + $search_date_valid_end = ''; + $search_status = ''; + $object_statut = ''; + } + $objectclass = 'SupplierProposal'; $objectlabel = 'SupplierProposals'; - $permissiontoread = $user->rights->supplier_proposal->lire; - $permissiontodelete = $user->rights->supplier_proposal->supprimer; $uploaddir = $conf->supplier_proposal->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } - /* * View */ - -$now = dol_now(); - $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); @@ -289,14 +288,17 @@ $formpropal = new FormPropal($db); $companystatic = new Societe($db); $formcompany = new FormCompany($db); +$now = dol_now(); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $title = $langs->trans('ListOfSupplierProposals'); $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; -llxHeader('', $title, $help_url); +// Build and execute select +// -------------------------------------------------------------------- $sql = 'SELECT'; if ($sall || $search_user > 0) { $sql = 'SELECT DISTINCT'; @@ -464,7 +466,7 @@ if (!empty($searchCategoryProductList)) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); @@ -506,10 +508,14 @@ if ($resql) { $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$id); - exit; } + // Output page + // -------------------------------------------------------------------- + + llxHeader('', $title, $help_url); + $param = ''; if (!empty($mode)) { $param .= '&mode='.urlencode($mode); @@ -709,18 +715,18 @@ if ($resql) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields - if ($massactionbutton) { - $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); - } + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields + $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
    '; - print ''."\n"; + print '
    '."\n"; + // Fields title search + // -------------------------------------------------------------------- print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; @@ -865,7 +871,7 @@ if ($resql) { } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 063b2b06448..af38a5b7ba5 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -71,7 +71,12 @@ if ($action == 'getProducts') { $object = new Categorie($db); if ($category == "supplements") { $category = getDolGlobalInt('TAKEPOS_SUPPLEMENTS_CATEGORY'); + if (empty($category)) { + echo 'Error, the category to use for supplements is not defined. Go into setup of module TakePOS.'; + exit; + } } + $result = $object->fetch($category); if ($result > 0) { $filter = array(); diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 769c343f1fe..fe7a7aa53ac 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -960,7 +960,7 @@ div#moreinfo, div#infowarehouse { } div.wrapper2{ - height:10%; + height: 40px; } } diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 6fabd3a6e2b..a2846f63ddf 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -92,7 +92,6 @@ if ($conf->browser->layout == 'phone') { } $MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG); $MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT); -$MAXCATEG = 5; /* $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; @@ -1090,7 +1089,11 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
    '; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print ''; + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
    '; -if (($action == "valid" || $action == "history") && $invoice->type != Facture::TYPE_CREDIT_NOTE) { +if (($action == "valid" || $action == "history") && $invoice->type != Facture::TYPE_CREDIT_NOTE && empty($conf->global->TAKEPOS_NO_CREDITNOTE)) { print ''; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 7f363e53848..7d504cfd946 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -838,6 +838,9 @@ textarea.centpercent { .wordbreak { word-break: break-all; } +td.wordbreak img { + max-width: 100%; +} .bold { font-weight: bold !important; } @@ -1602,7 +1605,7 @@ maxscreenheightless200 { .minwidth50 { min-width: 50px; } .minwidth75 { min-width: 75px; } /* rule for not too small screen only */ -@media only screen and (min-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3) ? round($nbtopmenuentries * 47, 0) + 130 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) +@media only screen and (min-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3) ? round($nbtopmenuentries * 47, 0) + 130 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) /* reduction 3 */ { .width20 { width: 20px; } .width25 { width: 25px; } @@ -2094,7 +2097,7 @@ div.blockvmenupair, div.blockvmenuimpair { border-top: none !important; border-left: none !important; border-right: none !important; - border-bottom: 1px solid #e0e0e0; + border-bottom: 1px solid #eaeaea; padding-left: 0 !important; } div.blockvmenuend, div.blockvmenubookmarks { @@ -2164,7 +2167,7 @@ div.vmenu, td.vmenu { border-top: none !important; border-left: none !important; border-right: none !important; - border-bottom: 1px solid #e0e0e0; + border-bottom: 1px solid #eaeaea; padding-left: 0 !important; } div.vmenu, td.vmenu { @@ -2921,7 +2924,6 @@ if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) { print ' background-color: #FFFFFF;'; } ?> - -webkit-box-shadow: 0 2px 23px 2px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(60,60,60,0.15); box-shadow: 0 2px 23px 2px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(60,60,60,0.15); @@ -3111,6 +3113,15 @@ img.login, img.printer, img.entity { color: white; font-weight: bold; } +.loginbuttonexternal { + width: 300px; + margin: auto; + border: 1px solid #ccc; + padding: 10px; + border-radius: 5px; +} + + .userimg.atoplogin img.userphoto, .userimgatoplogin img.userphoto { /* size for user photo in login bar */ width: px; height: px; @@ -3449,7 +3460,7 @@ div.tabBar { padding-top: 16px; padding-left: 0px; padding-right: 0px; padding-bottom: 2px; - margin: 0px 0px 16px 0px; + margin: 0px 0px 30px 0px; border-top: 1px solid #BBB; /* border-bottom: 1px solid #AAA; */ width: auto; @@ -4437,7 +4448,7 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nt .noborder > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), .noborder .oddeven.tagtr:nth-child(even):not(:last-of-type) .tagtd:not(.liste_titre) { - border-bottom: 1px solid #e0e0e0; + border-bottom: 1px solid #eaeaea; } .noborder:not(.editmode) > tbody > tr:nth-child(odd):not(.liste_titre):not(.nooddeven), .liste > tbody > tr:nth-child(odd):not(.liste_titre):not(.nooddeven), @@ -4452,7 +4463,7 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nt .noborder > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .noborder .oddeven.tagtr:nth-child(odd):not(:last-child) .tagtd:not(.liste_titre) { - border-bottom: 1px solid #e0e0e0; + border-bottom: 1px solid #eaeaea; } ul.noborder li:nth-child(even):not(.liste_titre) { @@ -4655,13 +4666,16 @@ span.dashboardlineko { display: inline-block; vertical-align: middle; } -.boxtable { +.divboxtable { margin-bottom: 25px !important; +} +.boxtable { border-bottom-width: 1px; background: var(--colorbackbody); border-top: px solid var(--colortopbordertitle1); /* border-top: 2px solid var(--colorbackhmenu1) !important; */ } + table.noborder.boxtable tr td { height: unset; } @@ -5028,7 +5042,7 @@ div#card-errors { /* ============================================================================== */ -/* Formulaire confirmation (When Ajax JQuery is used) */ +/* Formulaire confirmation (When Ajax JQuery is used) and Dialog popups */ /* ============================================================================== */ .ui-dialog-titlebar { @@ -5036,7 +5050,7 @@ div#card-errors { .ui-dialog-content { } .ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-draggable { - z-index: 1002 !important; /* Default 101 with ui-jquery, top menu have a z-index of 1000 */ + z-index: 1005 !important; /* Default 101 with ui-jquery, top menu have a z-index of 1000 */ } @@ -6697,7 +6711,7 @@ div.multi-select-menu[role="menu"] { height: 0; border-style: solid; border-width: 0.5em 0.23em 0em 0.23em; - border-color: #444 transparent transparent transparent; + border-color: #888 transparent transparent transparent; margin-left: 0.4em; } @@ -6705,7 +6719,7 @@ div.multi-select-menu[role="menu"] { .multi-select-container--open .multi-select-button:after { border-width: 0 0.4em 0.4em 0.4em; - border-color: transparent transparent #999 transparent; + border-color: transparent transparent #888 transparent; } .multi-select-menuitem { @@ -6715,6 +6729,7 @@ div.multi-select-menu[role="menu"] { } label.multi-select-menuitem { line-height: 24px; + text-align: start; } diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 8882bf8e220..74208efda17 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -96,7 +96,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { padding-bottom: 5px; } .info-box-sm .info-box-icon, .info-box-sm .info-box-img { - height: 96px !important; /* must match height of info-box-sm .info-box-content */ + height: 98px !important; /* must match height of info-box-sm .info-box-content */ width: 78px; font-size: 25px; line-height: 92px; @@ -239,7 +239,7 @@ a.info-box-text-a i.fa.fa-exclamation-triangle { } .info-box-sm .info-box-content { margin-left: 80px; - height: 86px; /* 96 - margins of .info-box-sm .info-box-content */ + height: 88px; /* 96 - margins of .info-box-sm .info-box-content */ } .info-box-sm .info-box-module-enabled { /* background: linear-gradient(0.35turn, #fff, #fff, #f6faf8, #e4efe8) */ diff --git a/htdocs/theme/eldy/timeline.inc.php b/htdocs/theme/eldy/timeline.inc.php index 84d486817b1..a4fa4ee29b3 100644 --- a/htdocs/theme/eldy/timeline.inc.php +++ b/htdocs/theme/eldy/timeline.inc.php @@ -62,7 +62,8 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { position: relative; } -.timeline > li.timeline-code-ticket_msg_private > .timeline-item { +.timeline > li.timeline-code-ticket_msg_private > .timeline-item, +.timeline > li.timeline-code-ticket_msg_private_sentbymail > .timeline-item { background: #fffbe5; border-color: #d0cfc0; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 1cda692ecc8..379a614adf3 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1080,6 +1080,9 @@ textarea.centpercent { .wordbreak { word-break: break-all; } +td.wordbreak img { + max-width: 100%; +} .bold { font-weight: bold !important; } @@ -2361,7 +2364,6 @@ div.backgroundsemitransparent { } - #id-right { padding-: 0 ! important; } @@ -3122,6 +3124,13 @@ table.login_table_securitycode tr td { max-width: 170px; max-height: 90px; } +.loginbuttonexternal { + width: 300px; + margin: auto; + border: 1px solid #ccc; + padding: 10px; + border-radius: 5px; +} .atoplogin.dropdown .dropdown-menu { @@ -3419,7 +3428,7 @@ div.blockvmenupair, div.blockvmenuimpair background: var(--colorbackvmenu1); padding-bottom: 10px; - border-bottom: 1px solid #e0e0e0; + border-bottom: 1px solid #e8e8e8; } div.blockvmenubookmarks { @@ -3581,7 +3590,7 @@ div.tabBar { padding-left: 24px; padding-right: 24px; padding-bottom: 23px; - margin: 0px 0px 18px 0px; + margin: 0px 0px 20px 0px; -webkit-border-radius: 3px; border-radius: 3px; border-right: 1px solid #CCC; @@ -4554,7 +4563,7 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nt .liste > tbody > tr:nth-child(even):not(:last-of-type) td:not(.liste_titre), .noborder .tagtr:nth-child(even):not(:last-of-type) .oddeven.tagtd:not(.liste_titre) { - border-bottom: 1px solid #ddd; + border-bottom: 1px solid #e8e8e8; } .noborder > tbody > tr:nth-child(odd):not(.liste_titre):not(.nooddeven), @@ -4572,7 +4581,7 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nt .liste > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .noborder .tagtr:nth-child(odd):not(:last-child) .oddeven.tagtd:not(.liste_titre) { - border-bottom: 1px solid #ddd; + border-bottom: 1px solid #e8e8e8; } ul.noborder li:nth-child(even):not(.liste_titre) { @@ -4700,8 +4709,10 @@ span.dashboardlineko { color: #FFFFFF ! important; border-radius: .25em; } -.boxtable { +.divboxtable { margin-bottom: 20px !important; +} +.boxtable { border-bottom-width: 1px; } .boxtablenotop { @@ -4989,7 +5000,7 @@ span.buttonpaymentsmall { min-width: 320px; font-size: 16px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ -#tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } +#tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; margin-bottom: 20px; } #tablepublicpayment .CTableRow1 { background-color: #F0F0F0 !important; } #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } #tablepublicpayment tr.liste_total td { border-top: none; } @@ -5055,7 +5066,7 @@ div#card-errors { /* ============================================================================== */ -/* Formulaire confirmation (When Ajax JQuery is used) */ +/* Formulaire confirmation (When Ajax JQuery is used) and Dialog popups */ /* ============================================================================== */ .ui-dialog-titlebar { @@ -5064,7 +5075,7 @@ div#card-errors { font-size: !important; } .ui-dialog.ui-corner-all.ui-widget.ui-widget-content.ui-front.ui-draggable { - z-index: 1002 !important; /* Default 101 with ui-jquery, top menu have a z-index of 1000 */ + z-index: 1005 !important; /* Default 101 with ui-jquery, top menu have a z-index of 1000 */ } div#dialogforpopup { @@ -6612,7 +6623,7 @@ div.multi-select-menu[role="menu"] { height: 0; border-style: solid; border-width: 0.5em 0.23em 0em 0.23em; - border-color: #444 transparent transparent transparent; + border-color: #888 transparent transparent transparent; margin-left: 0.4em; } @@ -6620,7 +6631,7 @@ div.multi-select-menu[role="menu"] { .multi-select-container--open .multi-select-button:after { border-width: 0 0.4em 0.4em 0.4em; - border-color: transparent transparent #999 transparent; + border-color: transparent transparent #888 transparent; } .multi-select-menuitem { @@ -6630,6 +6641,7 @@ div.multi-select-menu[role="menu"] { } label.multi-select-menuitem { line-height: 24px; + text-align: start; } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 76d266eb760..4c318197b1e 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -59,6 +59,7 @@ $projectid = GETPOST('projectid', 'int'); $cancel = GETPOST('cancel', 'alpha'); $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $contactid = GETPOST('contactid', 'int'); $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); @@ -116,6 +117,10 @@ if ($id || $track_id || $ref) { } } +$now = dol_now(); + +$actionobject = new ActionsTicket($db); + // Store current page url $url_page_current = DOL_URL_ROOT.'/ticket/card.php'; @@ -124,13 +129,12 @@ if ($user->socid > 0) $socid = $user->socid; $result = restrictedArea($user, 'ticket', $object->id); $triggermodname = 'TICKET_MODIFY'; -$permissiontoadd = $user->rights->ticket->write; - -$actionobject = new ActionsTicket($db); +$permissiontoread = $user->hasRight('ticket', 'read'); +$permissiontoadd = $user->hasRight('ticket', 'write'); +$permissiontodelete = $user->hasRight('ticket', 'delete'); $upload_dir = $conf->ticket->dir_output; -$now = dol_now(); /* @@ -175,7 +179,7 @@ if (empty($reshook)) { } // Action to add an action (not a message) - if (GETPOST('save', 'alpha') && !empty($user->rights->ticket->write)) { + if (GETPOST('save', 'alpha') && $permissiontoadd) { $error = 0; if (!GETPOST("type_code", 'alpha')) { @@ -207,7 +211,15 @@ if (empty($reshook)) { if (!$error) { $db->begin(); - $object->ref = GETPOST("ref", 'alphanohtml'); + $getRef = GETPOST("ref", 'alphanohtml'); + if ($object->fetch('', $getRef) > 0) { + $object->ref = $object->getDefaultRef(); + $object->track_id = null; + setEventMessage($langs->trans('TicketRefAlreadyUsed', $getRef, $object->ref)); + } else { + $object->ref = $getRef; + } + $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0; $object->subject = GETPOST("subject", 'alphanohtml'); $object->message = GETPOST("message", 'restricthtml'); @@ -305,7 +317,7 @@ if (empty($reshook)) { } } - if ($action == 'update' && $user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) { + if ($action == 'update' && $permissiontoadd && $object->status < Ticket::STATUS_CLOSED) { $error = 0; $ret = $object->fetch(GETPOST('id', 'int'), GETPOST('ref', 'alpha'), GETPOST('track_id', 'alpha')); @@ -370,7 +382,7 @@ if (empty($reshook)) { } // Mark as Read - if ($action == "mark_ticket_read" && $user->rights->ticket->write) { + if ($action == "mark_ticket_read" && $permissiontoadd) { $object->fetch('', '', GETPOST("track_id", 'alpha')); if ($object->markAsRead($user) > 0) { @@ -385,7 +397,7 @@ if (empty($reshook)) { } // Assign to someone - if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $user->rights->ticket->write) { + if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $permissiontoadd) { $object->fetch('', '', GETPOST("track_id", 'alpha')); $useroriginassign = $object->fk_user_assign; $usertoassign = GETPOST('fk_user_assign', 'int'); @@ -444,7 +456,7 @@ if (empty($reshook)) { // Action to add a message (private or not, with email or not). // This may also send an email (concatenated with email_intro and email footer if checkbox was selected) - if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $user->rights->ticket->read) { + if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $permissiontoread) { $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0), 0); if ($ret > 0) { @@ -462,7 +474,7 @@ if (empty($reshook)) { } } - if (($action == "confirm_close" || $action == "confirm_abandon") && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) { + if (($action == "confirm_close" || $action == "confirm_abandon") && GETPOST('confirm', 'alpha') == 'yes' && $permissiontoadd) { $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); if ($object->close($user, ($action == "confirm_abandon" ? 1 : 0))) { @@ -476,7 +488,7 @@ if (empty($reshook)) { } } - if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') { + if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes' && $permissiontoadd) { $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) { $object->close($user); @@ -494,7 +506,7 @@ if (empty($reshook)) { } } - if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) { + if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $permissiontodelete) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->delete($user) > 0) { setEventMessages('
    '.$langs->trans('TicketDeletedSuccess').'
    ', null, 'mesgs'); @@ -579,7 +591,7 @@ if (empty($reshook)) { } } } - } elseif ($action == 'classin' && $user->rights->ticket->write) { + } elseif ($action == 'classin' && $permissiontoadd) { // Categorisation dans projet if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $object->setProject($projectid); @@ -587,7 +599,7 @@ if (empty($reshook)) { header("Location: ".$url); exit(); } - } elseif ($action == 'setcontract' && $user->rights->ticket->write) { + } elseif ($action == 'setcontract' && $permissiontoadd) { // Categorisation dans contrat if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $object->setContract(GETPOST('contractid', 'int')); @@ -618,7 +630,7 @@ if (empty($reshook)) { } $action = 'view'; - } elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) { + } elseif ($action == 'confirm_set_status' && $permissiontoadd && !GETPOST('cancel')) { // Reopen ticket if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { $new_status = GETPOST('new_status', 'int'); @@ -639,7 +651,7 @@ if (empty($reshook)) { } // Action to update one extrafield - if ($action == "update_extras" && !empty($permissiontoadd)) { + if ($action == "update_extras" && $permissiontoadd) { $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); @@ -663,7 +675,7 @@ if (empty($reshook)) { } } - if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $user->rights->ticket->write) { + if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $permissiontoadd) { $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); $object->type_code = GETPOST('update_value_type', 'aZ09'); @@ -687,7 +699,6 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once // Actions to build doc - $permissiontoadd = $user->rights->ticket->write; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; //var_dump($action);exit; @@ -1415,7 +1426,7 @@ if ($action == 'create' || $action == 'presend') { // Show link to add a message (if read and not closed) if (isset($object->status) && $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") { - print dolGetButtonAction('', $langs->trans('TicketAddMessage'), 'default', $_SERVER["PHP_SELF"].'?action=presend_addmessage&mode=init&token='.newToken().'&track_id='.$object->track_id.'#formmailbeforetitle', ''); + print dolGetButtonAction('', $langs->trans('TicketAddPrivateMessage'), 'default', $_SERVER["PHP_SELF"].'?action=presend_addmessage&mode=init&token='.newToken().'&track_id='.$object->track_id.'#formmailbeforetitle', ''); } // Link to create an intervention diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 29a013f1eb9..c566bf54329 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -306,6 +306,14 @@ class ActionsTicket if ($res) { print $userstat->getNomUrl(0); } + } elseif (isset($arraymsgs['fk_contact_author'])) { + $contactstat = new Contact($this->db); + $res = $contactstat->fetch(0, null, '', $arraymsgs['fk_contact_author']); + if ($res) { + print $contactstat->getNomUrl(0, 'nolink'); + } else { + print $arraymsgs['fk_contact_author']; + } } else { print $langs->trans('Customer'); } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 158f3e30e2f..01d911d0c8b 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -505,7 +505,7 @@ class Ticket extends CommonObject $sql .= " ".($this->fk_soc > 0 ? $this->db->escape($this->fk_soc) : "null").","; $sql .= " ".($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "null").","; $sql .= " ".(!isset($this->origin_email) ? 'NULL' : "'".$this->db->escape($this->origin_email)."'").","; - $sql .= " ".($this->fk_user_create > 0 ? $this->fk_user_create : ($user->id > 0 ? $user->id : 'NULL')).","; + $sql .= " ".(!isset($this->fk_user_create) ? ($user->id > 0 ? $user->id : 'NULL') : ($this->fk_user_create > 0 ? $this->fk_user_create : 'NULL')).","; $sql .= " ".($this->fk_user_assign > 0 ? $this->fk_user_assign : 'NULL').","; $sql .= " ".(empty($this->email_msgid) ? 'NULL' : "'".$this->db->escape($this->email_msgid)."'").","; $sql .= " ".(empty($this->email_date) ? 'NULL' : "'".$this->db->idate($this->email_date)."'").","; @@ -1265,13 +1265,14 @@ class Ticket extends CommonObject /** * Load into a cache array, the list of ticket categories (setup done into dictionary) * - * @return int Number of lines loaded, 0 if already loaded, <0 if KO + * @param int $publicgroup 0=No public group, 1=Public group only, -1=All + * @return int Number of lines loaded, 0 if already loaded, <0 if KO */ - public function loadCacheCategoriesTickets() + public function loadCacheCategoriesTickets($publicgroup = -1) { global $conf, $langs; - if (!empty($this->cache_category_tickets) && count($this->cache_category_tickets)) { + if ($publicgroup == -1 && !empty($this->cache_category_ticket) && count($this->cache_category_tickets)) { // Cache already loaded return 0; } @@ -1279,8 +1280,13 @@ class Ticket extends CommonObject $sql = "SELECT rowid, code, label, use_default, pos, description, public, active, force_severity, fk_parent"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category"; $sql .= " WHERE active > 0 AND entity = ".((int) $conf->entity); + if ($publicgroup > -1) { + $sql .= " AND public = ".((int) $publicgroup); + } $sql .= " ORDER BY pos"; + dol_syslog(get_class($this)."::load_cache_categories_tickets", LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -1700,6 +1706,9 @@ class Ticket extends CommonObject if ($send_email) { $actioncomm->code .= '_SENTBYMAIL'; } + if ((empty($user->id) || $user->id == 0) && isset($_SESSION['email_customer'])) { + $actioncomm->email_from = $_SESSION['email_customer']; + } $actioncomm->socid = $this->socid; $actioncomm->label = $this->subject; $actioncomm->note_private = $this->message; @@ -1753,7 +1762,7 @@ class Ticket extends CommonObject // Cache already loaded - $sql = "SELECT id as rowid, fk_user_author, datec, label, note as message, code"; + $sql = "SELECT id as rowid, fk_user_author, email_from, datec, label, note as message, code"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm"; $sql .= " WHERE fk_element = ".(int) $this->id; $sql .= " AND elementtype = 'ticket'"; @@ -1768,6 +1777,9 @@ class Ticket extends CommonObject $obj = $this->db->fetch_object($resql); $this->cache_msgs_ticket[$i]['id'] = $obj->rowid; $this->cache_msgs_ticket[$i]['fk_user_author'] = $obj->fk_user_author; + if ($obj->code == 'TICKET_MSG' && empty($obj->fk_user_author)) { + $this->cache_msgs_ticket[$i]['fk_contact_author'] = $obj->email_from; + } $this->cache_msgs_ticket[$i]['datec'] = $this->db->jdate($obj->datec); $this->cache_msgs_ticket[$i]['subject'] = $obj->label; $this->cache_msgs_ticket[$i]['message'] = $obj->message; @@ -2335,8 +2347,8 @@ class Ticket extends CommonObject * Used for files linked into messages. * Files may be renamed during copy to avoid overwriting existing files. * - * @param string $forcetrackid Force trackid - * @return array Array with final path/name/mime of files. + * @param string $forcetrackid Force trackid used for $keytoavoidconflict into get_attached_files() + * @return array|int Array with final path/name/mime of files. */ public function copyFilesForTicket($forcetrackid = null) { @@ -2356,7 +2368,7 @@ class Ticket extends CommonObject $formmail->trackid = (is_null($forcetrackid) ? 'tic'.$this->id : ''); $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; + $filepath = $attachedfiles['paths']; // path is for example user->dir_temp.'/'.$user->id.'/'... $filename = $attachedfiles['names']; $mimetype = $attachedfiles['mimes']; @@ -2379,16 +2391,23 @@ class Ticket extends CommonObject } $res = dol_move($filepath[$i], $destfile, 0, 1, 0, 1); - - if (image_format_supported($destfile) == 1) { - // Create small thumbs for image (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($destfile, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); - // Create mini thumbs for image (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($destfile, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + if (!$res) { + // Move has failed + $this->error = "Failed to move file ".dirbasename($filepath[$i])." into ".dirbasename($destfile); + return -1; + } else { + // If file is an image, we create thumbs + if (image_format_supported($destfile) == 1) { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($destfile, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($destfile, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + } } + // Clear variables into session $formmail->remove_attached_files($i); // Fill array with new names @@ -2449,11 +2468,11 @@ class Ticket extends CommonObject * Add new message on a ticket (private/public area). * Can also send it by email if GETPOST('send_email', 'int') is set. For such email, header and footer is added. * - * @param User $user User for action - * @param string $action Action string - * @param int $private 1=Message is private. TODO Implement this. What does this means ? - * @param int $public_area 1=Is the public area - * @return int + * @param User $user User for action + * @param string $action Action string + * @param int $private 1=Message is private. TODO Implement this. What does this means ? + * @param int $public_area 1=Is the public area + * @return int <0 if KO, >= 0 if OK */ public function newMessage($user, &$action, $private = 1, $public_area = 0) { @@ -2490,6 +2509,10 @@ class Ticket extends CommonObject // Copy attached files (saved into $_SESSION) as linked files to ticket. Return array with final name used. $resarray = $object->copyFilesForTicket(); + if (is_numeric($resarray) && $resarray == -1) { + setEventMessages($object->error, $object->errors, 'errors'); + return -1; + } $listofpaths = $resarray['listofpaths']; $listofnames = $resarray['listofnames']; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 570b78f7604..f6126f59ced 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2086,11 +2086,12 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; } + print ''."\n"; print ''."\n"; print ''."\n"; print ''; - print '
    '.$langs->trans("Groups").''; if ($caneditgroup) { - print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); + print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity, false, 'maxwidth150'); print '   '; print ''; print ''; @@ -2101,7 +2102,7 @@ if ($action == 'create' || $action == 'adduserldap') { if (!empty($groupslist)) { foreach ($groupslist as $group) { print '
    '; + print ''; if ($caneditgroup) { print $group->getNomUrl(1); } else { diff --git a/htdocs/user/logout.php b/htdocs/user/logout.php index 661995bb729..8afa07ee0d0 100644 --- a/htdocs/user/logout.php +++ b/htdocs/user/logout.php @@ -45,13 +45,15 @@ if (!defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) { require_once '../main.inc.php'; -// This can happen only with a bookmark or forged url call. +// This can happen only with a bookmark or a forged url call. if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuser' || $_SESSION["dol_authmode"] == 'http')) { unset($_SESSION["dol_login"]); + unset($_SESSION['dol_entity']); + unset($_SESSION['urlfrom']); die("Applicative disconnection should be useless when connection was made in mode ".$_SESSION["dol_authmode"]); } -global $conf, $langs, $user; +//global $conf, $langs, $user; // Call trigger $result = $user->call_trigger('USER_LOGOUT', $user); diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php index 47a2087e3bf..6b27a567ec9 100644 --- a/htdocs/variants/list.php +++ b/htdocs/variants/list.php @@ -140,9 +140,9 @@ $arrayfields['nb_products'] = array( $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->variants->read; -$permissiontoadd = $user->rights->variants->write; -$permissiontodelete = $user->rights->variants->delete; +$permissiontoread = $user->hasRight('variants', 'read'); +$permissiontoadd = $user->hasRight('variants', 'write'); +$permissiontodelete = $user->hasRight('variants', 'delete'); // Security check if (!isModEnabled('variants')) { diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 8cd37f2e96f..c531dbc09e0 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -157,7 +157,9 @@ if (GETPOST("cache", 'alpha')) { // Add param cache=abcdef if (empty($dolibarr_nocache)) { header('Cache-Control: max-age=3600, public, must-revalidate'); - header('Pragma: cache'); // This is to avoid having Pragma: no-cache + header('Pragma: cache'); // This is to avoid to have Pragma: no-cache set by proxy or web server + header('Expires: '.gmdate('D, d M Y H:i:s', time() + 3600).' GMT'); // This is to avoid to have Expires set by proxy or web server + //header('Expires: '.strtotime('+1 hour'); } else { header('Cache-Control: no-cache'); } diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 818f2676af6..901b12d662b 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -135,7 +135,7 @@ if ($result < 0) { exit(-1); } else { if (empty($user->id)) { - echo "User login: ".$userlogin." does not exists"; + echo "User login: ".$userlogin." does not exists\n"; dol_syslog("User login:".$userlogin." does not exists", LOG_ERR); exit(-1); } @@ -169,7 +169,7 @@ $object = new Cronjob($db); $filter = array(); if (!empty($id)) { if (!is_numeric($id)) { - echo "Error: Bad value for parameter job id"; + echo "Error: Bad value for parameter job id\n"; dol_syslog("cron_run_jobs.php Bad value for parameter job id", LOG_WARNING); exit(); } @@ -199,7 +199,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) { // Force reload of setup for the current entity if ((empty($line->entity) ? 1 : $line->entity) != $conf->entity) { - dol_syslog("cron_run_jobs.php we work on another entity conf than ".$conf->entity." so we reload mysoc, langs, user and conf", LOG_DEBUG); + dol_syslog("cron_run_jobs.php: we work on another entity conf than ".$conf->entity." so we reload mysoc, langs, user and conf", LOG_DEBUG); echo " -> we change entity so we reload mysoc, langs, user and conf"; $conf->entity = (empty($line->entity) ? 1 : $line->entity); @@ -211,12 +211,12 @@ if (is_array($object->lines) && (count($object->lines) > 0)) { $result = $user->fetch('', $userlogin, '', 1); if ($result < 0) { echo "\nUser Error: ".$user->error."\n"; - dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); + dol_syslog("cron_run_jobs.php: User Error:".$user->error, LOG_ERR); exit(-1); } else { if ($result == 0) { - echo "\nUser login: ".$userlogin." does not exists for entity ".$conf->entity."\n"; - dol_syslog("User login:".$userlogin." does not exists", LOG_ERR); + echo "\nUser login: ".$userlogin." does not exist for entity ".$conf->entity."\n"; + dol_syslog("cron_run_jobs.php: User login: ".$userlogin." does not exist", LOG_ERR); exit(-1); } } @@ -248,7 +248,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) { $cronjob = new Cronjob($db); $result = $cronjob->fetch($line->id); if ($result < 0) { - echo "Error cronjobid: ".$line->id." cronjob->fetch: ".$cronjob->error."\n"; + echo " - Error cronjobid: ".$line->id." cronjob->fetch: ".$cronjob->error."\n"; echo "Failed to fetch job ".$line->id."\n"; dol_syslog("cron_run_jobs.php::fetch Error ".$cronjob->error, LOG_ERR); exit(-1); @@ -256,7 +256,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) { // Execute job $result = $cronjob->run_jobs($userlogin); if ($result < 0) { - echo "Error cronjobid: ".$line->id." cronjob->run_job: ".$cronjob->error."\n"; + echo " - Error cronjobid: ".$line->id." cronjob->run_job: ".$cronjob->error."\n"; echo "At least one job failed. Go on menu Home-Setup-Admin tools to see result for each job.\n"; echo "You can also enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n"; dol_syslog("cron_run_jobs.php::run_jobs Error ".$cronjob->error, LOG_ERR); @@ -272,7 +272,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) { // We re-program the next execution and stores the last execution time for this job $result = $cronjob->reprogram_jobs($userlogin, $now); if ($result < 0) { - echo "Error cronjobid: ".$line->id." cronjob->reprogram_job: ".$cronjob->error."\n"; + echo " - Error cronjobid: ".$line->id." cronjob->reprogram_job: ".$cronjob->error."\n"; echo "Enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n"; dol_syslog("cron_run_jobs.php::reprogram_jobs Error ".$cronjob->error, LOG_ERR); exit(-1); diff --git a/test/phpunit/AccountingAccountTest.php b/test/phpunit/AccountingAccountTest.php index bf34616563a..80a793f4d19 100644 --- a/test/phpunit/AccountingAccountTest.php +++ b/test/phpunit/AccountingAccountTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class AccountingAccountTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return AccountingAccountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ActionCommTest.php b/test/phpunit/ActionCommTest.php index d3c0a02a656..8f86c13d067 100644 --- a/test/phpunit/ActionCommTest.php +++ b/test/phpunit/ActionCommTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class ActionCommTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ActionCommTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index ce7c44e01c6..96ebe4728ec 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2013 Marcos García + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,12 @@ class AdherentTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return AdherentTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/AdminLibTest.php b/test/phpunit/AdminLibTest.php index 4df1a6933e1..b4002d06c91 100644 --- a/test/phpunit/AdminLibTest.php +++ b/test/phpunit/AdminLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class AdminLibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return AdminLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 9a6934da2f4..2d321752fe9 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -69,7 +69,6 @@ class AllTests */ public static function suite() { - $suite = new PHPUnit\Framework\TestSuite('PHPUnit Framework'); //require_once dirname(__FILE__).'/CoreTest.php'; diff --git a/test/phpunit/BOMTest.php b/test/phpunit/BOMTest.php index c331c3cd4e2..f23c7344ca9 100644 --- a/test/phpunit/BOMTest.php +++ b/test/phpunit/BOMTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify @@ -56,11 +57,12 @@ class BOMTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return BOMTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/BankAccountTest.php b/test/phpunit/BankAccountTest.php index 4e879be7c0a..8a900f5768f 100644 --- a/test/phpunit/BankAccountTest.php +++ b/test/phpunit/BankAccountTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,11 +59,12 @@ class BankAccountTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return BankAccountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/BarcodeTest.php b/test/phpunit/BarcodeTest.php index 67cc013c50b..0751969baf8 100644 --- a/test/phpunit/BarcodeTest.php +++ b/test/phpunit/BarcodeTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,11 +59,12 @@ class BarcodeTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return BarcodeTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/BonPrelevementTest.php b/test/phpunit/BonPrelevementTest.php index 1adf938a906..d5f34aca7ca 100644 --- a/test/phpunit/BonPrelevementTest.php +++ b/test/phpunit/BonPrelevementTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,12 @@ class BonPrelevementTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return BankAccountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index 82fe9c43ee6..71a5daa35f9 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -85,11 +86,12 @@ class BuildDocTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return BuildDocTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index 729aa4b4c7f..fe09584c6ce 100644 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class CMailFileTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CMailFile */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index 763be9cca65..fcab2c07116 100644 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class CategorieTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CategorieTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ChargeSocialesTest.php b/test/phpunit/ChargeSocialesTest.php index 2feaccd497b..af108e7bcaf 100644 --- a/test/phpunit/ChargeSocialesTest.php +++ b/test/phpunit/ChargeSocialesTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class ChargeSocialesTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ChargeSocialesTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index f33aa1c1588..ace8d4ff32a 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -87,11 +88,12 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 94b6d57b558..6f9df3ea7ea 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -87,11 +88,12 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index 7282fb1a88e..4aba4486244 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,12 @@ class CommandeFournisseurTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CommandeFournisseurTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index fa3fe3ac843..7e7804610ed 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class CommandeTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CommandeTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CommonInvoiceTest.php b/test/phpunit/CommonInvoiceTest.php index a5b93720ede..f0ab9bdd770 100644 --- a/test/phpunit/CommonInvoiceTest.php +++ b/test/phpunit/CommonInvoiceTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class CommonInvoiceTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CommonObjectTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CommonObjectTest.php b/test/phpunit/CommonObjectTest.php index bf68954227c..7db85b7a9ce 100644 --- a/test/phpunit/CommonObjectTest.php +++ b/test/phpunit/CommonObjectTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class CommonObjectTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CommonObjectTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CompanyBankAccountTest.php b/test/phpunit/CompanyBankAccountTest.php index 05f0abd136d..dde7d15afb0 100644 --- a/test/phpunit/CompanyBankAccountTest.php +++ b/test/phpunit/CompanyBankAccountTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class CompanyBankAccountTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CompanyBankAccountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CompanyLibTest.php b/test/phpunit/CompanyLibTest.php index 39b8109b3a3..2f6024afcb8 100644 --- a/test/phpunit/CompanyLibTest.php +++ b/test/phpunit/CompanyLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class CompanyLibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return AdminLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index c28db01d579..82447cd4bc9 100644 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -62,11 +63,12 @@ class ContactTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ContactTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; @@ -296,7 +298,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $result=$localobject->getFullAddress(1); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nBelgium", $result); + $this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result); $localobject->info($localobject->id); print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; @@ -357,7 +359,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nFrance", $result); + $this->assertStringContainsString("New address\nNew zip New town\nFrance", $result); // Belgium unset($localobjectadd->country_code); @@ -368,7 +370,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nBelgium", $result); + $this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result); // Switzerland unset($localobjectadd->country_code); @@ -379,7 +381,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nSwitzerland", $result); + $this->assertStringContainsString("New address\nNew zip New town\nSwitzerland", $result); // USA unset($localobjectadd->country_code); @@ -390,7 +392,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew town, New zip\nUnited States", $result); + $this->assertStringContainsString("New address\nNew town, New zip\nUnited States", $result); return $localobjectadd->id; } diff --git a/test/phpunit/ContratTest.php b/test/phpunit/ContratTest.php index 17d302fcf82..ac919f8d69c 100644 --- a/test/phpunit/ContratTest.php +++ b/test/phpunit/ContratTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class ContratTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ContratTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php index 8ac448fa15e..d5bee69da6f 100644 --- a/test/phpunit/CoreTest.php +++ b/test/phpunit/CoreTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -78,11 +79,12 @@ class CoreTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CoreTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index eef029d26d1..428b55de164 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,11 +60,12 @@ class DateLibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/DateLibTzFranceTest.php b/test/phpunit/DateLibTzFranceTest.php index b855b240648..b2ca92a1b65 100644 --- a/test/phpunit/DateLibTzFranceTest.php +++ b/test/phpunit/DateLibTzFranceTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class DateLibTzFranceTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/DiscountTest.php b/test/phpunit/DiscountTest.php index b7e4297f490..e7c41336d3e 100644 --- a/test/phpunit/DiscountTest.php +++ b/test/phpunit/DiscountTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class DiscountTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return DiscountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/DoliDBTest.php b/test/phpunit/DoliDBTest.php index f810deee98e..999c3b3e54a 100644 --- a/test/phpunit/DoliDBTest.php +++ b/test/phpunit/DoliDBTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class DoliDBTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return DiscountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/EmailCollectorTest.php b/test/phpunit/EmailCollectorTest.php index 8ad06dc1f23..541023a44b8 100644 --- a/test/phpunit/EmailCollectorTest.php +++ b/test/phpunit/EmailCollectorTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,12 @@ class EmailCollectorTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ExpenseReportTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index 9bf237374ef..5ef30cc07e9 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class EntrepotTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return EntrepotTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/EvalMathTest.php b/test/phpunit/EvalMathTest.php index bc50c65f6b8..0a5e2f48407 100644 --- a/test/phpunit/EvalMathTest.php +++ b/test/phpunit/EvalMathTest.php @@ -55,11 +55,12 @@ class EvalMathTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return InventoryTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ExpenseReportTest.php b/test/phpunit/ExpenseReportTest.php index 689c88d1313..df85b4822cf 100644 --- a/test/phpunit/ExpenseReportTest.php +++ b/test/phpunit/ExpenseReportTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class ExpenseReportTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ExpenseReportTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index 0a0a1c867ba..0af1df57995 100644 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -80,11 +81,12 @@ class ExportTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ExportTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FactureFournisseurTest.php b/test/phpunit/FactureFournisseurTest.php index 4b0c41d5f82..ecb57af995c 100644 --- a/test/phpunit/FactureFournisseurTest.php +++ b/test/phpunit/FactureFournisseurTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2017 Juanjo Menent + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class FactureFournisseurTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return FactureFournisseurTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FactureRecTest.php b/test/phpunit/FactureRecTest.php index d5d9a164daa..813e4cba0a3 100644 --- a/test/phpunit/FactureRecTest.php +++ b/test/phpunit/FactureRecTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class FactureRecTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return FactureTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index 004fc18725e..08cc68333a2 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Frédéric France + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class FactureTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return FactureTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FactureTestRounding.php b/test/phpunit/FactureTestRounding.php index d5d502d0697..37b5bbac375 100644 --- a/test/phpunit/FactureTestRounding.php +++ b/test/phpunit/FactureTestRounding.php @@ -55,11 +55,12 @@ class FactureTestRounding extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return FactureTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FichinterTest.php b/test/phpunit/FichinterTest.php index 8fb2ee736cc..755642cc39a 100644 --- a/test/phpunit/FichinterTest.php +++ b/test/phpunit/FichinterTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class FichinterTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ContratTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 520e1888899..8f235f3e868 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class FilesLibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return FilesLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; @@ -487,18 +489,16 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - - if (empty($user->rights->facture)) { - $user->rights->facture = new stdClass(); - } - //$dummyuser=new User($db); //$result=restrictedArea($dummyuser,'societe'); // We save user properties - $savpermlire = $user->rights->facture->lire; - $savpermcreer = $user->rights->facture->creer; + $savpermlire = $user->hasRight('facture', 'lire'); + $savpermcreer = $user->hasRight('facture', 'creer'); + if (empty($user->rights->facture)) { + $user->rights->facture = new stdClass(); + } // Check access to SPECIMEN $user->rights->facture->lire = 0; diff --git a/test/phpunit/FormAdminTest.php b/test/phpunit/FormAdminTest.php index e9beea8a5c6..7434189c1ff 100644 --- a/test/phpunit/FormAdminTest.php +++ b/test/phpunit/FormAdminTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class FormAdminTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return FactureTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FormTest.php b/test/phpunit/FormTest.php index 429ae296152..b17ac2a8b23 100644 --- a/test/phpunit/FormTest.php +++ b/test/phpunit/FormTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class FormTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return FactureTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php index 69ccdc45866..59ae8e4f7ac 100644 --- a/test/phpunit/Functions2LibTest.php +++ b/test/phpunit/Functions2LibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -79,11 +80,12 @@ class Functions2LibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CoreTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 90a92c450cb..85a5f525e47 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,11 +87,12 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CoreTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db,$mysoc; diff --git a/test/phpunit/GetUrlLibTest.php b/test/phpunit/GetUrlLibTest.php index b8e3c50363f..c3411ea8273 100644 --- a/test/phpunit/GetUrlLibTest.php +++ b/test/phpunit/GetUrlLibTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class GetUrlLibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return FilesLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index d6ebd6425e4..f25eb06617c 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,12 @@ class HolidayTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return HolidayTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index b8288aa25e6..ade9fe1f476 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,12 @@ class ImagesLibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ImagesLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ImportTest.php b/test/phpunit/ImportTest.php index d64c82cc4e8..80c35a2f64d 100644 --- a/test/phpunit/ImportTest.php +++ b/test/phpunit/ImportTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -78,11 +79,12 @@ class ImportTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ImportTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/InventoryTest.php b/test/phpunit/InventoryTest.php index c4b415885d3..ced18910790 100644 --- a/test/phpunit/InventoryTest.php +++ b/test/phpunit/InventoryTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Frédéric France + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class InventoryTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return InventoryTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/JsonLibTest.php b/test/phpunit/JsonLibTest.php index 341cf51583f..3d16630543f 100644 --- a/test/phpunit/JsonLibTest.php +++ b/test/phpunit/JsonLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -78,11 +79,12 @@ class JsonLibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return CoreTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/KnowledgeRecordTest.php b/test/phpunit/KnowledgeRecordTest.php index 8dab9846435..7103345a096 100644 --- a/test/phpunit/KnowledgeRecordTest.php +++ b/test/phpunit/KnowledgeRecordTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2021 SuperAdmin + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,11 +59,12 @@ class KnowledgeRecordTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return KnowledgeRecordTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf, $user, $langs, $db; diff --git a/test/phpunit/LangTest.php b/test/phpunit/LangTest.php index 18fa1c2d4db..c4021d2deff 100644 --- a/test/phpunit/LangTest.php +++ b/test/phpunit/LangTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -87,11 +88,12 @@ class LangTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/LesscTest.php b/test/phpunit/LesscTest.php index e9a72d0ef4f..911a671cc9e 100644 --- a/test/phpunit/LesscTest.php +++ b/test/phpunit/LesscTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -87,11 +88,12 @@ class LesscTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/LoanTest.php b/test/phpunit/LoanTest.php index 2eaaa221183..946479c1e53 100644 --- a/test/phpunit/LoanTest.php +++ b/test/phpunit/LoanTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class LoanTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return LoanTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/MarginsLibTest.php b/test/phpunit/MarginsLibTest.php index 0b5aa0cfb5e..8ba581fb44d 100644 --- a/test/phpunit/MarginsLibTest.php +++ b/test/phpunit/MarginsLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class MarginsLibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ModulesTest.php b/test/phpunit/ModulesTest.php index 5ef22cddd88..9e71bc15102 100644 --- a/test/phpunit/ModulesTest.php +++ b/test/phpunit/ModulesTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -54,11 +55,12 @@ class ModulesTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return BuildDocTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index 68eacd466bf..c2bf052751e 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,12 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ContratTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index 9134ad3e0d5..67852e81ccf 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -54,11 +55,12 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return NumberingModulesTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ODFTest.php b/test/phpunit/ODFTest.php index 4211a637303..a7d972bf345 100644 --- a/test/phpunit/ODFTest.php +++ b/test/phpunit/ODFTest.php @@ -57,11 +57,12 @@ class ODFTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return BOMTest + * @param string $name Name + * @return ODFTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index fdcc17fd48d..086e62dc9af 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class PaypalTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return ProductTest + * @param string $name Name + * @return PaypalTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/PdfDocTest.php b/test/phpunit/PdfDocTest.php index 238830ac1a0..d468af76ebd 100644 --- a/test/phpunit/PdfDocTest.php +++ b/test/phpunit/PdfDocTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,11 +59,12 @@ class PdfDocTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return PdfDocTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/PgsqlTest.php b/test/phpunit/PgsqlTest.php index 17c4c82714e..2767ee5a807 100644 --- a/test/phpunit/PgsqlTest.php +++ b/test/phpunit/PgsqlTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,12 @@ class PgsqlTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return ContactTest + * @param string $name Name + * @return PgsqlTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index cab19d715f5..3e9889fe966 100644 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -61,11 +62,12 @@ class PricesTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return CoreTest + * @param string $name Name + * @return PriceTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index 4f237a90314..2c4dfd6a829 100644 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class ProductTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ProductTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ProjectTest.php b/test/phpunit/ProjectTest.php index ee2f4ed92c2..4ceb469ec7d 100644 --- a/test/phpunit/ProjectTest.php +++ b/test/phpunit/ProjectTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class ProjectTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ProjectTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/PropalTest.php b/test/phpunit/PropalTest.php index 833812bfb4b..f9a8f7d95c1 100644 --- a/test/phpunit/PropalTest.php +++ b/test/phpunit/PropalTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class PropalTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return PropalTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/RepositoryTest.php b/test/phpunit/RepositoryTest.php index 1df9cbe7aa8..74ed813a1cd 100644 --- a/test/phpunit/RepositoryTest.php +++ b/test/phpunit/RepositoryTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,11 +87,12 @@ class RepositoryTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return SecurityTest + * @param string $name Name + * @return RepositoryTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index 1992e56d815..f487593a9b8 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,11 +59,12 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables. * - * @return DateLibTest + * @param string $name Name + * @return RestAPIDocumentTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index 4de0557c561..ba18c5aa6bb 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -60,11 +61,12 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return DateLibTest + * @param string $name Name + * @return RestAPIUserTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ScriptsTest.php b/test/phpunit/ScriptsTest.php index 6132cd7837a..d1973bb2b37 100644 --- a/test/phpunit/ScriptsTest.php +++ b/test/phpunit/ScriptsTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -87,11 +88,12 @@ class ScriptsTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return ScriptsTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 1138e06d3b2..8a54893d890 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -83,11 +84,12 @@ class SecurityTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index 415212c64cb..9191a7e1d5c 100644 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class SocieteTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return SocieteTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/StripeTest.php b/test/phpunit/StripeTest.php index e26b023a38e..f44b598270a 100644 --- a/test/phpunit/StripeTest.php +++ b/test/phpunit/StripeTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class StripeTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return ProductTest + * @param string $name Name + * @return StripeTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index 81917e34d9e..ca1c11172ce 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,11 +59,12 @@ class SupplierProposalTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return PropalTest + * @param string $name Name + * @return SupplierProposalTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/TargetTest.php b/test/phpunit/TargetTest.php index 3a96ceba3b2..3cf8fce21ab 100644 --- a/test/phpunit/TargetTest.php +++ b/test/phpunit/TargetTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2022 Alice Adminson + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,11 +58,12 @@ class TargetTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return TargetTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf, $user, $langs, $db; diff --git a/test/phpunit/TicketTest.php b/test/phpunit/TicketTest.php index 5d05f7839f4..b840d2204d8 100644 --- a/test/phpunit/TicketTest.php +++ b/test/phpunit/TicketTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,11 +57,12 @@ class TicketTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return ContratTest + * @param string $name Name + * @return TicketTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/UserGroupTest.php b/test/phpunit/UserGroupTest.php index 8ca21384002..ec3c6469cca 100644 --- a/test/phpunit/UserGroupTest.php +++ b/test/phpunit/UserGroupTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class UserGroupTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return UserGroupTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index 625c4df7ef7..a26dfd0a707 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class UserTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return UserTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/UtilsTest.php b/test/phpunit/UtilsTest.php index 5c34df81ea4..af25fdb8e90 100644 --- a/test/phpunit/UtilsTest.php +++ b/test/phpunit/UtilsTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class UtilsTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * + * @param string $name Name * @return UserTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index dccf1516993..7ca227a0f84 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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,11 +68,12 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return DateLibTest + * @param string $name Name + * @return WebservicesInvoicesTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesOrdersTest.php b/test/phpunit/WebservicesOrdersTest.php index f790ac15902..7cc66266fcf 100644 --- a/test/phpunit/WebservicesOrdersTest.php +++ b/test/phpunit/WebservicesOrdersTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,11 +60,12 @@ class WebservicesOrdersTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return DateLibTest + * @param string $name Name + * @return WebservicesOrdersTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesOtherTest.php b/test/phpunit/WebservicesOtherTest.php index 5f5a6e833b1..96ab2f0c642 100644 --- a/test/phpunit/WebservicesOtherTest.php +++ b/test/phpunit/WebservicesOtherTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,11 +60,12 @@ class WebservicesOtherTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return DateLibTest + * @param string $name Name + * @return WebservicesOtherTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesProductsTest.php b/test/phpunit/WebservicesProductsTest.php index 021c305f7e2..54c8e10fa8f 100644 --- a/test/phpunit/WebservicesProductsTest.php +++ b/test/phpunit/WebservicesProductsTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -65,11 +66,12 @@ class WebservicesProductsTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return DateLibTest + * @param string $name Name + * @return WebservicesProductsTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index 7d8fb7aab8e..632728b998e 100644 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -65,11 +66,12 @@ class WebservicesThirdpartyTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return DateLibTest + * @param string $name Name + * @return WebservicesThirdpartyTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesUserTest.php b/test/phpunit/WebservicesUserTest.php index 6eba28dfde8..2ed16c238bb 100644 --- a/test/phpunit/WebservicesUserTest.php +++ b/test/phpunit/WebservicesUserTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,11 +60,12 @@ class WebservicesUserTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return DateLibTest + * @param string $name Name + * @return WebservicesUserTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebsiteTest.php b/test/phpunit/WebsiteTest.php index 4383d844ed8..a0cbc5084c7 100644 --- a/test/phpunit/WebsiteTest.php +++ b/test/phpunit/WebsiteTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -88,11 +89,12 @@ class WebsiteTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return SecurityTest + * @param string $name Name + * @return WebsiteTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/XCalLibTest.php b/test/phpunit/XCalLibTest.php index dc4550fc84f..ac9b592414c 100644 --- a/test/phpunit/XCalLibTest.php +++ b/test/phpunit/XCalLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,11 +56,12 @@ class XCalLibTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables * - * @return FilesLibTest + * @param string $name Name + * @return XCalLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db;