diff --git a/.travis.yml b/.travis.yml index 22d4b2b0827..df6e24a7e02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,9 @@ dist: xenial language: php +git: + depth: 1 + # Start on every boot services: - memcached @@ -264,24 +267,27 @@ script: echo - | - echo "Checking PHP syntax errors" + echo "Checking PHP syntax errors (only 1 version to not overload travis and avoid duplicate tests)" # Ensure we catch errors set -e #parallel-lint --exclude htdocs/includes --blame . - parallel-lint --exclude dev/tools/test/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ - --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ - --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ - --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \ - --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --blame . + # Exclusions are defined in the ruleset.xml file + if [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then + parallel-lint -e php --exclude dev/tools/test/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ + --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ + --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ + --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \ + --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --blame . + fi set +e echo - | - echo "Checking coding style (excluding Pull Requests builds to not overload travis, excluding also some jobs to avoid duplicate tests)" + echo "Checking coding style (only for Pull Requests builds and 1 version to not overload travis and avoid duplicate tests)" # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4" ] && [ "$DB" = "mysql" ]; then + if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi set +e @@ -401,8 +407,12 @@ script: php upgrade.php 13.0.0 14.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade13001400.log php upgrade2.php 13.0.0 14.0.0 > $TRAVIS_BUILD_DIR/upgrade13001400-2.log php step5.php 13.0.0 14.0.0 > $TRAVIS_BUILD_DIR/upgrade13001400-3.log + ls -alrt $TRAVIS_BUILD_DIR/ +- | + echo "Enabling new modules" # Enable modules not enabled into original dump + cd htdocs/install php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_STRIPE > $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP >> $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $TRAVIS_BUILD_DIR/enablemodule.log diff --git a/ChangeLog b/ChangeLog index 95a4a7a3ae6..98c22d90bf7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,29 +10,16 @@ For users: NEW: Module Recruitement to follow application to job positions is now stable. NEW: Feature to make Stock Inventories NEW: Several security issues after a second private bug hunting campaign. -NEW: Add a security center page with all information and advices related to the security of your instance -NEW: Add a performance center page with all information and advices related to the performance of your instance NEW: A lot of fix into english text after a small proofreading campaign (still not perfect, but really better) NEW: All main menu entries are using the picto of the module NEW: Add a copy to clipboard button on some fields NEW: Add an example of scheduled job to send email reminder for unpaid invoices -NEW: Accountancy - Add FEC import -NEW: Accountancy - Add a confirmation form with options on export -NEW: Accountancy - Add select date from/to in already bind customer and supplier list -NEW: Accountancy - Format FEC - Add new field DateLimitReglmt -NEW: Accountancy - In ledger & journals, show link on bank transaction -NEW: Accountancy - Possibility to filter on journals in balance -NEW: Accountancy - Add a page to list subledger accounts -NEW: add the Channel column into the list of orders -NEW: Add a check to avoid an invoice date in the future NEW: Add some color and picto for the direction of movement +NEW: add the column "Channel" into the list of orders NEW: Add the column "alias" of company in the list of proposal, order, invoice NEW: Add the column "Office phone" and "User mobile" in user list -NEW: Add the column "Price level"in thirdparty list +NEW: Add the column "Price level" in thirdparty list NEW: Add some company information in the dropdown login menu -NEW: Add constant MAIN_BUGTRACK_URL to set a custom url to redirect to when clicking on link "declare a bug" -NEW: Add contact tag and bulk email status on the thirdparty + contact create form -NEW: Support down payment on supplier invoice (& somes ajustments) NEW: Add edit/delete action icons on categories list pages NEW: Add hidden option to auto load input line extrafield into new lines NEW: Add import profile to import BOM @@ -40,29 +27,21 @@ NEW: Add link picto to the stock movement on the detail of production NEW: Add mass action "Set tag" for product/service, user, thirdparty, warehouse, project, bank account, members NEW: Add bulk action Validate and Set to billed on order list. NEW: Add possibility to exports userGroups fields on user exports -NEW: Add price min and price min including tax into product export NEW: Can search on lots or serials into the quick search bar NEW: Add support for Friday as a non working day -NEW: Add a total in page of margin by user -NEW: Add the total of margin in invoice list NEW: auto notification with module Notification can use templated emails -NEW: Bank Entries : display user linked to a salary or a taxes NEW: Can clone a cron job NEW: Can create a lot from the list view (Look and feel standardization). NEW: Can filter on extrafields date on lists NEW: Can filter on rowid in list of blocked logs NEW: Can hide columns "time consumed" on timesheet per week NEW: Can set an employee on each social contribution -NEW: Can set a percentage when creating an invoice from another object NEW: Can set order of execution of hooks -NEW: Can show the leave dates/holidays on the agenda view NEW: Can toggle FCKeditor on public/private notes NEW: Check update availability for externals modules using a button on module page NEW: Choose lines to use while creating intervention card from origin NEW: Columns shipment method, payment mode, payment term in proposal and order list NEW: Conf for default actioncomm status -NEW: customer ref for product customer prices -NEW: date and user signature on proposal (Issue 16062) #16980 NEW: Dictionary for availability - Add a column position NEW: Can set a user related to a social contribution NEW: ICS Direct debit can be set with a different value for each bank account @@ -70,18 +49,13 @@ NEW: LDAP: usergroup search can be filtered NEW: Make public bookmarks editable by admin users only NEW: If main logo not defined, can use the squarred logo on login page NEW: The manifest file can use the squared image if available -NEW: Add bulk actions for Bank Transfer NEW: Enhance the multicurrency rate editor -NEW: Multiselect ledger account code filter on book keeping list NEW: Normalyse Type company field with ajax combobox NEW: preload product description on selection for customer propal/order/invoice -NEW: Add a ref in product customer price NEW: Search usergroups & resources -NEW: Set status of all variants when changing status of parent NEW: Setup Page for module creation with module builder enhancement #FoundationFunding NEW: Show picto of module into the list of dictionaries NEW: Show the total of payment on the payment confirmation page -NEW: Support color for types of event NEW: The global setup for Mandatory fields can now be done on combo list too. NEW: translate in "en_US" to complete PR 16980 NEW: Update the list of taxes available by default for France @@ -89,26 +63,63 @@ NEW: Salary payment request and Salary payment are 2 different steps in workflow NEW: VAT payment request and VAT payment are now 2 different steps in workflow on VAT payment recording NEW: VAT report - Optimisation & collapse by rate NEW: When a doc file is shared, link is visible from the main page of doc. -NEW: #16378 More E-Mail Contact substitution Values for better salutation -NEW: option to keep the "Automatically create a total payment" checkbox empty on the tax creation page +NEW: #16378 more E-Mail Contact substitution Values for better salutation +NEW: option to keep the "Automatically create the payment" checkbox empty on the tax creation page + + Accountancy +NEW: Accountancy - Add FEC import +NEW: Accountancy - Add a confirmation form with options on export +NEW: Accountancy - Add select date from/to in already bind customer and supplier list +NEW: Accountancy - Format FEC - Add new field DateLimitReglmt +NEW: Accountancy - In ledger & journals, show link on bank transaction +NEW: Accountancy - Possibility to filter on journals in balance +NEW: Accountancy - Add a page to list subledger accounts +NEW: Multiselect ledger account code filter on book keeping list + + Agenda +NEW: add support for Friday as a non working day +NEW: can show the leave dates/holidays on the agenda view +NEW: Support color for types of event + + Bank +NEW: Bank Entries : display user linked to a salary or a taxes +NEW: Add bulk actions for Bank Transfer ECM/GED -NEW: Add db fields note_public and note_private for ECM module -NEW: Can filter files in GED on status Shared/Not shared +NEW: add DB fields note_public and note_private for ECM module +NEW: can filter files in ECM/GED on status Shared / Not shared + + Invoices +NEW: add a check to avoid an invoice date in the future +NEW: add the total of margin in invoice list +NEW: can set a percentage when creating an invoice from another object +NEW: Support down payment on supplier invoice (& somes ajustments) + + Margin +NEW: add the total of margin in invoice list +NEW: add the total of margin in page by user Members NEW: #17292 default subscription amount by adherent type -NEW: Option to automatically create a login/user when a new subscription of a member is done online +NEW: option to automatically create a login/user when a new subscription of a member is done online NEW: option to select membership type on the online payment page for membership subscription or renewal + Products +NEW: Add price min and price min including tax into product export +NEW: Add a ref in product customer price +NEW: customer ref for product customer prices +NEW: Set status of all variants when changing status of parent + Projects/Tasks NEW: option to automatically close an open project when all its tasks are done (=progress 100%) NEW: can show the project ref into PDF documents NEW: when we add contacts/users to a project, ask to also affect them on tasks +NEW: Can hide columns "time consumed" on timesheet per week Proposals NEW: add bulk action to set a commercial proposal to status "Refused" NEW: can set a warehouse in a proposal +NEW: date and user signature on proposal (Issue 16062) #16980 Shipment NEW: add option in Workflow module to set a shipment as closed @@ -121,18 +132,20 @@ NEW: edit sales lines rights in TakePOS NEW: option for TakePOS to show the total price without tax NEW: more permissions in TakePOS (can edit added line, can modify once order sent to kitchen) - Third-Parties -NEW: Can set a Warehouse on a Thirdparty + Third Party / Contacts +NEW: add contact tag and bulk email status on the thirdparty + contact create form +NEW: can set a warehouse on a thirdparty Tickets NEW: can use captcha on public page to create a ticket #16347 NEW: can set if a ticket group is visible on public interface or not - Warehouse -NEW: Can make massive stock transfers from a CSV file -NEW: Stock movement list - Add more complete date field -NEW: Can set a Warehouse on a Thirdparty + Warehouse/Stock +NEW: Feature to make Stock Inventories +NEW: can make massive stock transfers from a CSV file +NEW: Stock movement list - add more complete date field NEW: can set a warehouse in a proposal +NEW: can set a warehouse on a thirdparty Website Module NEW: #17113 Can upload a favicon in website module @@ -140,49 +153,63 @@ NEW: add a new permission "Export website" NEW: add last date of modification for website pages in the list of pages NEW: Save old page with .old extension on disk when editing a website page - new Modules + Workflows +NEW: add option in Workflow module to set a shipment as closed + + + for Admins +NEW: Add a security center page with all information and advices related to the security of your instance +NEW: Add a performance center page with all information and advices related to the performance of your instance + + Modules +NEW: Module Recruitement is now stable NEW: start new experimental module Event Organization Management NEW: start new experimental module Partnership Management NEW: start new experimental module Knowledge Management NEW: start new experimental module Workstations Management +NEW: Check update availability for externals modules using a button on module page +Module SimplePOS is deprecated - TakePOS is recommended for the future new Options -NEW: Add option CONTRACT_ALLOW_EXTERNAL_DOWNLOAD to make generated doc automatically shared -NEW: Add option SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD to make generated doc automatically shared -NEW: Add option MAIN_SECURITY_ANTI_SSRF_SERVER_IP to define list of IPs that are local IPs -NEW: Add option SOCIETE_DISABLE_WORKFORCE to hide staff field +NEW: add option CONTRACT_ALLOW_EXTERNAL_DOWNLOAD to make generated doc automatically shared +NEW: add option SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD to make generated doc automatically shared +NEW: add option MAIN_SECURITY_ANTI_SSRF_SERVER_IP to define list of IPs that are local IPs +NEW: add option SOCIETE_DISABLE_WORKFORCE to hide staff field +NEW: add constant MAIN_BUGTRACK_URL to set a custom url to redirect to when clicking on link "declare a bug" For developers: --------------- NEW: Can edit an object property in module builder -NEW: hook printFieldListTitle for cabyprodserv.php -NEW: Hook to allow external modules to add their own shortlist of recent objects -NEW: SQL-altering hooks in the turnover by product report NEW: Add data-eec=1 for EEC countries on select for js interaction NEW: Add experimental repair script to switch to dynamic row format and utf8mb4 encoding -NEW: add form confirm hook on company card NEW: Add function showValueWithClipboardCPButton() to add a copy/paste -NEW: Add hook addSectionECMAuto method to add custom diretory into ECM auto files -NEW: Add native compression in rest apis -NEW: Product Variants API, add variant stock to response by parameter NEW: Upgrade Stripe PHP lib to 7.67.0 -NEW: Add link to OpenAPI specifications xml file in REST API module setup: swagger.json file can be included into external tools like redoc NEW: Support sepa_debit in stripe paymentmethods list NEW: Update doleditor.class.php for easily activate SCAYT NEW: Add triggers in the function add_object_linked(), updateObjectLinked() and deleteObjectLinked() NEW: Add triggers OBJECT_LINK_INSERT, OBJECT_LINK_UPDATE et OBJECT_LINK_DELETE in the function add_object_linked(), updateObjectLinked() and deleteObjectLinked() -NEW: Can set a target image in dolcropresize function. -NEW: Can set a label as placeholder for combo lists. +NEW: can set a target image in dolcropresize function +NEW: can set a label as placeholder for combo lists NEW: Add pagination on Get Products response API NEW: Add the DefaultValues CRUD class NEW: Extrafields of documents lines are inside the lines, not any more on separate TR NEW: unit selection on object edit line -NEW: #13739 #17390 Product API route added to get product stock and product with or without variants APIs -NEW: API Add option $includeifobjectisused to get a product -NEW: API Get the list of product ids only +NEW: API add option $includeifobjectisused to get a product +NEW: API get the list of product ids only +NEW: add link to OpenAPI specifications XML file in REST API module setup: swagger.json file can be included into external tools like redoc +NEW: add native compression in REST APIs +NEW: Product Variants API, add variant stock to response by parameter +NEW: Product API route added to get product stock and product with or without variants #13739 #17390 + + Hooks +NEW: hook printFieldListTitle for cabyprodserv.php +NEW: hook to allow external modules to add their own shortlist of recent objects +NEW: SQL-altering hooks in the turnover by product report +NEW: add form confirm hook on company card +NEW: add hook addSectionECMAuto method to add custom diretory into ECM auto files WARNING: @@ -198,6 +225,7 @@ Following changes may create regressions for some external modules, but were nec * If your database is MySQL or MariaDB, you need at least version 5.1 * Function set_price_level() has been renamed into setPriceLevel() to follow camelcase rules * removed deprecated subtituion key __REFCLIENT__ (replaced with __REF_CLIENT__) +* Removed constant MAIN_COUNTRIES_IN_EEC. You can now set if country is in Europe or not from the dictionary of countries. ***** ChangeLog for 13.0.3 compared to 13.0.2 ***** @@ -209,6 +237,8 @@ FIX: #17060 FIX: #17192 - With tz < 0, event is show in bad day on calendar views FIX: #17363 FIX: #17476 releve.php: Fix SQL statement +FIX: #17967 +Fix: #17906 : fix access denied FIX: Accountancy - Import in general ledger FIX: Accountancy - Quadra export - wrong data on credit FIX: Accountancy - Warning on the pages of the preparatory statements of accounting entries @@ -255,7 +285,6 @@ FIX: test must be === and not == FIX: test on link type FIX: type link extrafield case for advanced target emailing FIX: Write right on document ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git ***** ChangeLog for 13.0.2 compared to 13.0.1 ***** diff --git a/README.md b/README.md index ad349f713c1..7878f6270a7 100644 --- a/README.md +++ b/README.md @@ -202,9 +202,12 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### System Environment / Requirements -- Works with PHP 5.6+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite)) +- PHP +- MariaDB, MySQL or PostgreSQL - Compatible with all Cloud solutions that match PHP & MySQL or PostgreSQL prerequisites. +See exact requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite) + ### Extending diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 7d6d71d49a8..b84fe255760 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -388,7 +388,7 @@ if ($action != 'export_csv') { } elseif (empty($tmparrayforrootaccount['label'])) { // $tmparrayforrootaccount['label'] not defined = the account has not parent with a parent. // This is useless, we should not create a new account when an account has no parent, we must edit it to fix its parent. - // BUG 1: Accounts on level root or level 1 must not have a parent 2 level higher, so shoule not show a link to create another account. + // BUG 1: Accounts on level root or level 1 must not have a parent 2 level higher, so should not show a link to create another account. // BUG 2: Adding a link to create a new accounting account here is useless because it is not add as parent of the orphelin. //$link = '' . img_edit_add() . ''; } @@ -429,7 +429,7 @@ if ($action != 'export_csv') { print ''; print ''.$accounting_account.''; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { - print ''.price($opening_balance).''; + print ''.price($opening_balance).''; } $urlzoom = ''; @@ -466,7 +466,7 @@ if ($action != 'export_csv') { if (!empty($show_subgroup)) { print ''.$langs->trans("SubTotal").':'; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { - print ''.price($sous_total_opening_balance).''; + print ''.price($sous_total_opening_balance).''; } print ''.price($sous_total_debit).''; print ''.price($sous_total_credit).''; @@ -486,9 +486,9 @@ if ($action != 'export_csv') { print ''.price($total_debit).''; print ''.price($total_credit).''; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { - print '' . price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')) . ''; + print '' . price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')) . ''; } else { - print '' . price(price2num($total_debit - $total_credit, 'MT')) . ''; + print '' . price(price2num($total_debit - $total_credit, 'MT')) . ''; } print "\n"; print ''; diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index bcb3d7901f5..b612762d358 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -12,7 +12,7 @@ * 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 . + * along with this program. If not, see . * */ @@ -124,7 +124,11 @@ if ($action == 'validate_movements_confirm' && !empty($user->rights->accounting- $form = new Form($db); $formaccounting = new FormAccounting($db); -llxHeader('', $langs->trans("Closure")); +$title = $langs->trans('Closure'); + +$help_url ='EN:Module_Double_Entry_Accounting'; + +llxHeader('', $title, $help_url); if ($action == 'validate_movements') { $form_question = array(); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 16dea74108e..dde599a1462 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -141,6 +141,9 @@ if ($action == 'validatehistory') { $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; + if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); + } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 347f5b8c4c2..97d94a42f00 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -495,7 +495,7 @@ if ($result) { //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ProductDescription", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, '', $sortfield, $sortorder, 'right maxwidth50 '); - print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ', '', 1); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); @@ -703,13 +703,13 @@ if ($result) { print ''.$thirdpartystatic->getNomUrl(1, 'customer').''; // Country - print ''; $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; - print $labelcountry; + print ''; + print dol_escape_htmltag($labelcountry); print ''; // VAT Num - print ''.$objp->tva_intra.''; + print ''.dol_escape_htmltag($objp->tva_intra).''; // Found accounts print ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 343eb506408..b5c6804c7d6 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -149,6 +149,9 @@ if ($action == 'validatehistory') { $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; + if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); + } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 793ba453105..4fd16df2afe 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -482,7 +482,7 @@ if ($result) { print ''; print ''; print ''; - print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1); + print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1, null, 1); //print ''; print ''; print ''; @@ -503,7 +503,7 @@ if ($result) { //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ProductDescription", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, '', $sortfield, $sortorder, 'right maxwidth50 '); - print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ', '', 1); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); @@ -687,13 +687,13 @@ if ($result) { print ''.$thirdpartystatic->getNomUrl(1, 'supplier').''; // Country - print ''; $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; - print $labelcountry; + print ''; + print dol_escape_htmltag($labelcountry); print ''; // VAT Num - print ''.$objp->tva_intra.''; + print ''.dol_escape_htmltag($objp->tva_intra).''; // Found accounts print ''; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index d20318090e0..da84fd5bf6b 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1727,15 +1727,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Password").''.preg_replace('/./i', '*', $object->pass); + print ''.$langs->trans("Password").''; if ($object->pass) { print preg_replace('/./i', '*', $object->pass); } else { if ($user->admin) { - print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; - } else { - print $langs->trans("Hidden"); + print ''; } + print 'trans("Hidden").''; } if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) { $langs->load("errors"); diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 1f3dbd32cb6..489ed20d6c2 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -92,7 +92,7 @@ class AdherentStats extends Stats $sql = "SELECT date_format(p.dateadh,'%m') as dm, count(*)"; $sql .= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); + $sql .= " WHERE ".dolSqlDateFilter('p.dateadh', 0, 0, (int) $year, 1); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -133,7 +133,7 @@ class AdherentStats extends Stats $sql = "SELECT date_format(p.dateadh,'%m') as dm, sum(p.".$this->field.")"; $sql .= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); + $sql .= " WHERE ".dolSqlDateFilter('p.dateadh', 0, 0, (int) $year, 1); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -154,7 +154,7 @@ class AdherentStats extends Stats $sql = "SELECT date_format(p.dateadh,'%m') as dm, avg(p.".$this->field.")"; $sql .= " FROM ".$this->from; //if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); + $sql .= " WHERE ".dolSqlDateFilter('p.dateadh', 0, 0, (int) $year, 1); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index 56c9605c460..1e924699cd5 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -144,23 +144,23 @@ print ''."\n"; print ''; print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright'); -print ''; +print ''; print ''."\n"; print ''; print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright'); -print ''; +print ''; print ''."\n"; print ''; print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright'); -print ''; +print ''; print ''."\n"; // Web print ''; print img_picto('', 'globe', '', false, 0, 0, '', 'paddingright'); -print ''; +print ''; print ''."\n"; // Code diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 9ce55583d99..272da835741 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -3,6 +3,7 @@ * Copyright (C) 2011-2015 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Raphaël Doursenaud + * Copyright (C) 2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -158,14 +159,6 @@ print dol_get_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action print ''.$langs->trans("AgendaExtSitesDesc")."
\n"; print "
\n"; - -$selectedvalue = $conf->global->AGENDA_DISABLE_EXT; -if ($selectedvalue == 1) { - $selectedvalue = 0; -} else { - $selectedvalue = 1; -} - print ""; print ""; @@ -226,15 +219,15 @@ while ($i <= $MAXAGENDA) { // Nb print '"; // Name - print ''; + print ''; // URL - print ''; + print ''; // Offset TZ - print ''; + print ''; // Color (Possible colors are limited by Google) print ''; print ""; $i++; diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index ae33ef3b6fa..56971457f76 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -422,7 +422,7 @@ foreach ($boxactivated as $key => $box) { $hasnext = ($key < (count($boxactivated) - 1)); $hasprevious = ($key != 0); print ''; - print ''; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 0c6da346285..804ed9934bf 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -418,7 +418,7 @@ print ''."\n"; // Phone print ''; +print ''; print ''."\n"; // Fax print ''; +print ''; print ''."\n"; // Email print ''; +print ''; print ''."\n"; // Web print ''; +print ''; print ''."\n"; // Barcode @@ -467,19 +467,19 @@ if (!empty($conf->barcode->enabled)) { print ''; + print ''; print ''; } // Logo print ''; // Logo (squarred) print '
'.$langs->trans("AgendaExtNb", $key)."'; //print $formadmin->selectColor($conf->global->$color, "google_agenda_color".$key, $colorlist); - print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR".$key) ?GETPOST("AGENDA_EXT_COLOR".$key) : $conf->global->$color), "AGENDA_EXT_COLOR".$key, 'extsitesconfig', 1, '', 'hideifnotset'); + print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR".$key) ?GETPOST("AGENDA_EXT_COLOR".$key) : getDolGlobalString($color)), "AGENDA_EXT_COLOR".$key, 'extsitesconfig', 1, '', 'hideifnotset'); print '
'.($key + 1).''; + print ''; print ($hasnext ? ''.img_down().' ' : ''); print ($hasprevious ? ''.img_up().'' : ''); print ''; print img_picto('', 'globe-americas', 'class="paddingrightonly"'); -print $form->select_country($mysoc->country_id, 'country_id'); +print $form->select_country($mysoc->country_id, 'country_id', '', 0); if ($user->admin) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } @@ -441,25 +441,25 @@ print '
'; print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright'); -print '
'; print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright'); -print '
'; print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright'); -print '
'; print img_picto('', 'globe', '', false, 0, 0, '', 'paddingright'); -print '
'; print ''; print ''; - print '
'; -print '
'; -print ''; +print '
'; +print ''; print '
'; if (!empty($mysoc->logo_small)) { if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { print '
'; - print ''; + print ''; print '
'; } elseif (!empty($mysoc->logo)) { if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) { @@ -487,10 +487,12 @@ if (!empty($mysoc->logo_small)) { } $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_small', $quality); print '
'; - print ''; + print ''; print '
'; } - print ''; + print ''; } elseif (!empty($mysoc->logo)) { if (file_exists($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { print '
'; @@ -508,8 +510,8 @@ print '
'; -print '
'; -print ''; +print '
'; +print ''; print '
'; if (!empty($mysoc->logo_squarred_small)) { if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_small)) { @@ -551,20 +553,21 @@ print '
'; print '
'; // IDs of the company (country-specific) +print '
'; print ''; -print ''; +print ''; $langs->load("companies"); // Managing Director(s) print ''; +print ''; // GDPR contact print ''; +print 'global->MAIN_INFO_GDPR) ? $conf->global->MAIN_INFO_GDPR : ''))).'">'; // Capital print ''; - - // VAT - print ''; - - // Unit price - print ''; - - // Unit price with tax - print ''; - - // Quantity - print ''; - - //print ''; - //print ''; - - // Picture - print ''; - - print ''; - - print ''; } - $i++; - } - } + $tredited = 'tredited'; + include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; + include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_linktofile.tpl.php'; - // Add a new line - if (($object->status == ExpenseReport::STATUS_DRAFT || $object->status == ExpenseReport::STATUS_REFUSED) - && $action != 'editline' - && $user->rights->expensereport->creer) { + print ''; + + print ''; + + // Select date + print ''; + + // Select project + if (!empty($conf->projet->enabled)) { + print ''; + } + + // Select type + print ''; + + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + print ''; + } + + // Add comments + print ''; + + // VAT + print ''; + + // Unit price + print ''; + + // Unit price with tax + print ''; + + // Quantity + print ''; + + //print ''; + //print ''; + + // Picture + print ''; + + print ''; + + print ''; + } + + $i++; + } + } + + // Add a new line + if (($object->status == ExpenseReport::STATUS_DRAFT || $object->status == ExpenseReport::STATUS_REFUSED) + && $action != 'editline' + && $user->rights->expensereport->creer) { $colspan = 11; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { - $colspan++; - } - if (!empty($conf->projet->enabled)) { - $colspan++; - } - if ($action != 'editline') { - $colspan++; - } + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + $colspan++; + } + if (!empty($conf->projet->enabled)) { + $colspan++; + } + if ($action != 'editline') { + $colspan++; + } $nbFiles = $nbLinks = 0; $arrayoffiles = array(); - if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); - $arrayoffiles = dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png|'.preg_quote(dol_sanitizeFileName($object->ref.'.pdf'), '/').')$'); - $nbFiles = count($arrayoffiles); - $nbLinks = Link::count($db, $object->element, $object->id); - } + if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); + $arrayoffiles = dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png|'.preg_quote(dol_sanitizeFileName($object->ref.'.pdf'), '/').')$'); + $nbFiles = count($arrayoffiles); + $nbLinks = Link::count($db, $object->element, $object->id); + } // Add line with link to add new file or attach to an existing file print ''; @@ -2326,46 +2333,65 @@ if ($action == 'create') { print ''.$langs->trans("UploadANewFileNow"); print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print ''; - if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { - print '   -   '.$langs->trans("AttachTheNewLineToTheDocument"); - print img_picto($langs->trans("AttachTheNewLineToTheDocument"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); - print ''; - } + if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { + print '   -   '.$langs->trans("AttachTheNewLineToTheDocument"); + print img_picto($langs->trans("AttachTheNewLineToTheDocument"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); + print ''; + } + print ''."\n"; print ''."\n"; print ''; - include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_linktofile.tpl.php'; + include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; print ''; print ''; print ''; - if (!empty($conf->projet->enabled)) { - print ''; - } + if (!empty($conf->projet->enabled)) { + print ''; + } print ''; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { - print ''; - } + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + print ''; + } print ''; print ''; print ''; @@ -2388,23 +2414,23 @@ if ($action == 'create') { print ''; // Select project - if (!empty($conf->projet->enabled)) { - print ''; - } + if (!empty($conf->projet->enabled)) { + print ''; + } // Select type print ''; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { - print ''; - } + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + print ''; + } // Add comments print ''; @@ -2438,15 +2464,15 @@ if ($action == 'create') { // Picture print ''; - if ($action != 'editline') { - print ''; - print ''; - } + if ($action != 'editline') { + print ''; + print ''; + } print ''; print ''; - } // Fin si c'est payé/validé + } // Fin si c'est payé/validé print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'; -print '
'; print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc")); print ''; -print 'global->MAIN_INFO_GDPR) ? $conf->global->MAIN_INFO_GDPR : ''))).'">
'; @@ -656,6 +659,7 @@ print ''; - print ''; - print $form->load_tva('vatrate', (GETPOSTISSET("vatrate") ? GETPOST("vatrate") : $line->vatrate), $mysoc, '', 0, 0, '', false, 1); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').''; - //print $line->fk_ecm_files; - print ''; - print ''; - print ''; - print '
'; - print '
'; + print $form->selectDate($line->date, 'date'); + print ''; + $formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + print ''; + print $formexpensereport->selectTypeExpenseReport($line->fk_c_type_fees, 'fk_c_type_fees'); + print ''; + $params = array('fk_expense' => $object->id, 'fk_expense_det' => $line->rowid, 'date' => $line->dates); + print $form->selectExpenseCategories($line->fk_c_exp_tax_cat, 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params); + print ''; + print ''; + print ''; + print $form->load_tva('vatrate', (GETPOSTISSET("vatrate") ? GETPOST("vatrate") : $line->vatrate), $mysoc, '', 0, 0, '', false, 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').''; + //print $line->fk_ecm_files; + print ''; + print ''; + print ''; + print '
'; + print '
'.$langs->trans('Date').''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$langs->trans('Type').''.$langs->trans('CarCategory').''.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''; - $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); - print ''; + $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + print ''; print $formexpensereport->selectTypeExpenseReport($fk_c_type_fees, 'fk_c_type_fees', 1); print ''; - $params = array('fk_expense' => $object->id); - print $form->selectExpenseCategories('', 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0); - print ''; + $params = array('fk_expense' => $object->id); + print $form->selectExpenseCategories('', 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0); + print ''; @@ -2414,9 +2440,9 @@ if ($action == 'create') { // Select VAT print ''; $defaultvat = -1; - if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) { - $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; - } + if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) { + $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; + } print $form->load_tva('vatrate', ($vatrate != '' ? $vatrate : $defaultvat), $mysoc, '', 0, 0, '', false, 1); print '
'; print '
'; @@ -2474,11 +2500,15 @@ if ($action == 'create') { print ''; print dol_get_fiche_end(); - } - } else { - dol_print_error($db); } + } else { + dol_print_error($db); } +} else { + print 'Record not found'; + + llxFooter(); + exit(1); } /* diff --git a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php index 640f4c17b5d..42be03263a8 100644 --- a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php +++ b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php @@ -18,6 +18,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { $modulepart = 'expensereport'; $maxheightmini = 48; $relativepath = (!empty($object->ref) ?dol_sanitizeFileName($object->ref) : '').'/'; $filei = 0; + // Loop on each attached file foreach ($arrayoffiles as $file) { $urlforhref = array(); $filei++; @@ -77,7 +78,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { } if (empty($urlforhref) || empty($thumbshown)) { - print ''; + print ''; } else { print ''; } @@ -85,7 +86,12 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { print $thumbshown ? $thumbshown : img_mime($minifile); - print ''; + print ''; + if (empty($urlforhref) || empty($thumbshown)) { + print ''; + } else { + print ''; + } } print '
'; $checked = ''; @@ -106,7 +112,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { if (!empty($filenamelinked) && $filenamelinked == $file['relativename']) { $checked = ' checked'; } - print '
'; + print '
'; print ''; print '
'; diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 8c1bf9642b1..b8960572255 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -54,11 +54,12 @@ class Export public $array_export_examplevalues = array(); // array with examples for fields public $array_export_help = array(); // array with tooltip help for fields - // To store export modules + // To store export templates public $hexa; // List of fields in the export profile public $hexafiltervalue; // List of search criteria in the export profile public $datatoexport; public $model_name; // Name of export profile + public $fk_user; public $sqlusedforexport; @@ -720,8 +721,6 @@ class Export $this->db->begin(); - $filter = ''; - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'export_model ('; $sql .= 'label,'; $sql .= 'type,'; @@ -732,11 +731,10 @@ class Export $sql .= "'".$this->db->escape($this->model_name)."',"; $sql .= " '".$this->db->escape($this->datatoexport)."',"; $sql .= " '".$this->db->escape($this->hexa)."',"; - $sql .= ' '.($user->id > 0 ? $user->id : 'null').","; + $sql .= ' '.(isset($this->fk_user) ? (int) $this->fk_user : 'null').","; $sql .= " '".$this->db->escape($this->hexafiltervalue)."'"; $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index b3d0cf49a32..1dd3400ff80 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -335,6 +335,7 @@ if ($action == 'add_export_model') { $objexport->datatoexport = $datatoexport; $objexport->hexa = $hexa; $objexport->hexafiltervalue = $hexafiltervalue; + $objexport->fk_user = (GETPOST('visibility', 'aZ09') == 'all' ? 0 : $user->id); $result = $objexport->create($user); if ($result >= 0) { @@ -516,11 +517,7 @@ if ($step == 2 && $datatoexport) { print ''; print '
'; print ''.$langs->trans("SelectExportFields").' '; - if (empty($conf->global->EXPORTS_SHARE_MODELS)) { - $htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1, $user->id); - } else { - $htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1); - } + $htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1, $user->id); print ' '; print ''; print '
'; @@ -1007,20 +1004,28 @@ if ($step == 4 && $datatoexport) { print ''; print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; + print ''; + $tmpuser = new User($db); + // List of existing export profils - $sql = "SELECT rowid, label"; + $sql = "SELECT rowid, label, fk_user, entity"; $sql .= " FROM ".MAIN_DB_PREFIX."export_model"; $sql .= " WHERE type = '".$db->escape($datatoexport)."'"; - if (empty($conf->global->EXPORTS_SHARE_MODELS)) { - $sql .= " AND fk_user=".$user->id; + if (empty($conf->global->EXPORTS_SHARE_MODELS)) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner. + $sql .= " AND fk_user IN (0, ".((int) $user->id).")"; } $sql .= " ORDER BY rowid"; $resql = $db->query($sql); @@ -1029,9 +1034,19 @@ if ($step == 4 && $datatoexport) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); + print ''; + print ''; + print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 567aaf754a8..44ec5935d49 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -55,6 +55,12 @@ class Import */ public $errors = array(); + // To store import templates + public $hexa; // List of fields in the export profile + public $datatoimport; + public $model_name; // Name of export profile + public $fk_user; + /** * Constructor @@ -266,11 +272,18 @@ class Import $this->db->begin(); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'import_model ('; - $sql .= 'fk_user, label, type, field'; + $sql .= 'fk_user,'; + $sql .= ' label,'; + $sql .= ' type,'; + $sql .= ' field'; $sql .= ')'; - $sql .= " VALUES (".($user->id > 0 ? $user->id : 0).", '".$this->db->escape($this->model_name)."', '".$this->db->escape($this->datatoimport)."', '".$this->db->escape($this->hexa)."')"; + $sql .= " VALUES ("; + $sql .= (isset($this->fk_user) ? (int) $this->fk_user : 'null').","; + $sql .= " '".$this->db->escape($this->model_name)."',"; + $sql .= " '".$this->db->escape($this->datatoimport)."',"; + $sql .= " '".$this->db->escape($this->hexa)."'"; + $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 20a846123f1..4c5975ecb43 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -226,6 +226,7 @@ if ($action == 'add_import_model') { $objimport->model_name = $import_name; $objimport->datatoimport = $datatoimport; $objimport->hexa = $hexa; + $objimport->fk_user = (GETPOST('visibility', 'aZ09') == 'all' ? 0 : $user->id); $result = $objimport->create($user); if ($result >= 0) { @@ -968,7 +969,7 @@ if ($step == 4 && $datatoimport) { $s = str_replace('{s1}', img_picto('', 'grip_title', '', false, 0, 0, '', '', 0), $s); print $s; print ' '; - $htmlother->select_import_model($importmodelid, 'importmodelid', $datatoimport, 1); + $htmlother->select_import_model($importmodelid, 'importmodelid', $datatoimport, 1, $user->id); print ''; print ''; print ''; @@ -1249,28 +1250,51 @@ if ($step == 4 && $datatoimport) { print '
'.$langs->trans("ExportModelName").' '.$langs->trans("Visibility").'
'; + print ''; + $arrayvisibility = array('private'=>$langs->trans("Private"), 'all'=>$langs->trans("Everybody")); + print $form->selectarray('visibility', $arrayvisibility, 'private'); + print ''; print ''; print '
'; print $obj->label; - print ''; + print ''; + if (empty($obj->fk_user)) { + print $langs->trans("Everybody"); + } else { + $tmpuser->fetch($obj->fk_user); + print $tmpuser->getNomUrl(1); + } + print ''; print 'rowid.'">'; print img_delete(); print ''; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 0c825672f65..3c6151ef349 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -3594,7 +3594,7 @@ class SupplierInvoiceLine extends CommonObjectLine $sql .= ' '.(!empty($this->fk_code_ventilation) ? $this->fk_code_ventilation : 0).','; $sql .= ' '.((int) $this->rang).','; $sql .= ' '.((int) $this->special_code).','; - $sql .= " ".((int) $this->info_bits)."',"; + $sql .= " ".((int) $this->info_bits).","; $sql .= " ".price2num($this->total_ht).","; $sql .= " ".price2num($this->total_tva).","; $sql .= " ".price2num($this->total_ttc).","; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 44a712969c1..6e89abbf953 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -66,6 +66,11 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'purchaseordercard'; // To manage different context of search + +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); + $socid = GETPOST('socid', 'int'); $projectid = GETPOST('projectid', 'int'); $cancel = GETPOST('cancel', 'alpha'); @@ -151,12 +156,16 @@ if ($reshook < 0) { } if (empty($reshook)) { - if ($cancel) { - if (!empty($backtopage)) { - header("Location: ".$backtopage); - exit; + $backurlforlist = DOL_URL_ROOT.'/fourn/commande/list.php'.($socid > 0 ? '&socid='.((int) $socid) : ''); + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = DOL_URL_ROOT.'/fourn/commande/card.php?id='.($id > 0 ? $id : '__ID__'); + } } - $action = ''; } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once @@ -1573,10 +1582,16 @@ if ($action == 'create') { print '
'; print ''; print ''; - print ''."\n"; print ''; print ''; print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + if (!empty($currency_tx)) { print ''; } @@ -1592,9 +1607,9 @@ if ($action == 'create') { print '
'.$langs->trans('Supplier').''; - if ($socid > 0) { + if ($societe->id > 0) { print $societe->getNomUrl(1); - print ''; + print ''; } else { print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 25f71f85eb4..c644f9e35a5 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -892,8 +892,9 @@ if ($resql) { $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $url = DOL_URL_ROOT.'/fourn/commande/card.php?action=create'; - if (!empty($socid)) { - $url .= '&socid='.$socid; + if ($socid > 0) { + $url .= '&socid='.((int) $socid); + $url .= '&backtopage='.urlencode(DOL_URL_ROOT.'/fourn/commande/list.php?socid='.((int) $socid)); } $newcardbutton = dolGetButtonTitle($langs->trans('NewSupplierOrderShort'), '', 'fa fa-plus-circle', $url, '', ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer)); diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 97a70782e36..e7fc4014563 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -858,9 +858,10 @@ $object = new Holiday($db); $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); +$title = $langs->trans('CPTitreMenu'); $help_url = 'EN:Module_Holiday'; -llxHeader('', $langs->trans('CPTitreMenu'), $help_url); +llxHeader('', $title, $help_url); if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { // If user has no permission to create a leave diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 76ea8555d85..e1a9d9d905b 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1393,7 +1393,7 @@ class Holiday extends CommonObject * Met à jour le timestamp de la dernière mise à jour du solde des CP * * @param int $userID Id of user - * @param int $nbHoliday Nb of days + * @param float $nbHoliday Nb of days * @param int $fk_type Type of vacation * @return int 0=Nothing done, 1=OK, -1=KO */ @@ -1477,7 +1477,7 @@ class Holiday extends CommonObject if ($num > 0) { // Update for user $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; - $sql .= " nb_holiday = ".((int) $nbHoliday); + $sql .= " nb_holiday = ".((float) $nbHoliday); $sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; $result = $this->db->query($sql); if (!$result) { @@ -1487,7 +1487,7 @@ class Holiday extends CommonObject } else { // Insert for user $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users(nb_holiday, fk_user, fk_type) VALUES ("; - $sql .= ((int) $nbHoliday); + $sql .= ((float) $nbHoliday); $sql .= ", ".(int) $userID.", ".(int) $fk_type.")"; $result = $this->db->query($sql); if (!$result) { @@ -1955,8 +1955,8 @@ class Holiday extends CommonObject $sql .= " ".((int) $fk_user_action).","; $sql .= " ".((int) $fk_user_update).","; $sql .= " '".$this->db->escape($label)."',"; - $sql .= " '".$this->db->escape($prev_solde)."',"; - $sql .= " '".$this->db->escape($new_solde)."',"; + $sql .= " ".((float) $prev_solde).","; + $sql .= " ".((float) $new_solde).","; $sql .= " ".((int) $fk_type); $sql .= ")"; diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index b3d2c25adda..fdcdb5f88e6 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -126,16 +126,16 @@ if (empty($reshook)) { */ // Si il y a une action de mise à jour - if ($action == 'update' && isset($_POST['update_cp'])) { + if ($action == 'update' && GETPOSTISSET('update_cp')) { $error = 0; $typeleaves = $holiday->getTypes(1, 1); - $userID = array_keys($_POST['update_cp']); + $userID = array_keys(GETPOST('update_cp')); $userID = $userID[0]; foreach ($typeleaves as $key => $val) { - $userValue = $_POST['nb_holiday_'.$val['rowid']]; + $userValue = GETPOST('nb_holiday_'.$val['rowid']); $userValue = $userValue[$userID]; if (!empty($userValue) || (string) $userValue == '0') { @@ -189,7 +189,10 @@ if (empty($reshook)) { $form = new Form($db); $userstatic = new User($db); -llxHeader('', $langs->trans('CPTitreMenu')); + +$title = $langs->trans('CPTitreMenu'); + +llxHeader('', $title); $typeleaves = $holiday->getTypes(1, 1); diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index 063a3330ffd..c4e779efe52 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -137,7 +137,9 @@ $form = new Form($db); $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); -llxHeader("", "", $langs->trans("InterventionCard")); +$title = $langs->trans('InterventionCard'); + +llxHeader('', $title); if ($object->id) { diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 698d71e5dc7..1bb58ca98b0 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -133,7 +133,9 @@ $holidaystatic = new Holiday($db); $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); -llxHeader('', $langs->trans('CPTitreMenu')); +$title = $langs->trans('CPTitreMenu'); + +llxHeader('', $title); $search_month = GETPOST("remonth", 'int') ?GETPOST("remonth", 'int') : date("m", time()); $search_year = GETPOST("reyear", 'int') ?GETPOST("reyear", 'int') : date("Y", time()); diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index cd43e03f957..1a621d55a98 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -180,7 +180,8 @@ $formother = new FormOther($db); $holidaylogstatic = new stdClass(); $alltypeleaves = $object->getTypes(1, -1); // To have labels -llxHeader('', $langs->trans('CPTitreMenu')); +$title = $langs->trans('CPTitreMenu'); +llxHeader('', $title); $sqlwhere = ''; diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 2315edc100c..cdce14780f9 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -233,8 +233,8 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { print '
'.$holidaystatic->getNomUrl(1).''.$userstatic->getNomUrl(-1, 'leave').''.$typeleaves[$obj->fk_type]['label'].''.$userstatic->getNomUrl(-1, 'leave').''.dol_escape_htmltag($typeleaves[$obj->fk_type]['label']).'
'; print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; + print ''; // List of existing import profils - $sql = "SELECT rowid, label"; + $sql = "SELECT rowid, label, fk_user, entity"; $sql .= " FROM ".MAIN_DB_PREFIX."import_model"; $sql .= " WHERE type = '".$db->escape($datatoimport)."'"; + if (empty($conf->global->EXPORTS_SHARE_MODELS)) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner. + $sql .= " AND fk_user IN (0, ".((int) $user->id).")"; + } $sql .= " ORDER BY rowid"; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + + $tmpuser = new user($db); + $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); + print ''; + print ''; + print '"; - // Public URL - print ''; + if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) { + // Public URL + print ''; + } if ($type != 1 && !empty($conf->stock->enabled)) { // Default warehouse @@ -1205,20 +1207,24 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; - // Stock min level - print ''; + if (empty($conf->global->PRODUCT_DISABLE_STOCK_LEVELS)) { + // Stock min level + print ''; - print ''; + print ''; - // Stock desired level - print ''; + // Stock desired level + print ''; + } } else { - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_STOCK_LEVELS)) { + print ''; + print ''; + } } // Duration @@ -1230,17 +1236,21 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } if ($type != 1) { // Nature, Weight and volume only applies to products and not to services - // Nature - print ''; + if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { + // Nature + print ''; + } - // Brut Weight - print ''; + if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) { + // Brut Weight + print ''; + } // Brut Length if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { @@ -1349,170 +1359,174 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'; - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - // We do no show price array on create when multiprices enabled. - // We must set them on prices tab. - print '
'.$langs->trans("ImportModelName").' '.$langs->trans("Visibility").'
'; + print ''; + $arrayvisibility = array('private'=>$langs->trans("Private"), 'all'=>$langs->trans("Everybody")); + print $form->selectarray('visibility', $arrayvisibility, 'private'); + print ''; print ''; print '
'; print $obj->label; - print ''; + print ''; + if (empty($obj->fk_user)) { + print $langs->trans("Everybody"); + } else { + $tmpuser->fetch($obj->fk_user); + print $tmpuser->getNomUrl(1); + } + print ''; print 'rowid.'&filetoimport='.urlencode($filetoimport).'">'; print img_delete(); print ''; diff --git a/htdocs/install/mysql/data/llx_00_c_country.sql b/htdocs/install/mysql/data/llx_00_c_country.sql index 1e2e8b69c39..ac8eba73a28 100644 --- a/htdocs/install/mysql/data/llx_00_c_country.sql +++ b/htdocs/install/mysql/data/llx_00_c_country.sql @@ -231,48 +231,48 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (19 INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (200,'SL','SLE','Sierra Leone',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (201,'SK','SVK','Slovakia',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (202,'SI','SVN','Slovenia',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (203,'SB','SLB','Iles Salomon',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (204,'SO','SOM','Somalie',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (203,'SB','SLB','Solomon Islands',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (204,'SO','SOM','Somalia',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (205,'ZA','ZAF','South Africa',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (206,'GS','SGS','Iles Géorgie du Sud et Sandwich du Sud',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (206,'GS','SGS','South Georgia and the South Sandwich Islands ',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (207,'LK','LKA','Sri Lanka',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (208,'SD','SDN','Soudan',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (208,'SD','SDN','Sudan',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (209,'SR','SUR','Suriname',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (210,'SJ','SJM','Iles Svalbard et Jan Mayen',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (211,'SZ','SWZ','Swaziland',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (212,'SY','SYR','Syrie',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (213,'TW','TWN','Taïwan',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (214,'TJ','TJK','Tadjikistan',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (215,'TZ','TZA','Tanzanie',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (216,'TH','THA','Thaïlande',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (217,'TL','TLS','Timor Oriental',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (218,'TK','TKL','Tokélaou',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (210,'SJ','SJM','Svalbard and Jan Mayen',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (211,'SZ','SWZ','Swaziland / Eswatini',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (212,'SY','SYR','Syria',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (213,'TW','TWN','Taiwan',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (214,'TJ','TJK','Tajikistan',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (215,'TZ','TZA','Tanzania',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (216,'TH','THA','Thailand',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (217,'TL','TLS','Timor-Leste',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (218,'TK','TKL','Tokelau',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (219,'TO','TON','Tonga',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (220,'TT','TTO','Trinité-et-Tobago',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (221,'TR','TUR','Turquie',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (222,'TM','TKM','Turkménistan',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (223,'TC','TCA','Iles Turks-et-Caicos',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (220,'TT','TTO','Trinidad and Tobago',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (221,'TR','TUR','Turkey',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (222,'TM','TKM','Turkmenistan',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (223,'TC','TCA','Turks and Caicos Islands',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (224,'TV','TUV','Tuvalu',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (225,'UG','UGA','Ouganda',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (225,'UG','UGA','Uganda',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (226,'UA','UKR','Ukraine',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (227,'AE','ARE','United Arab Emirates',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (228,'UM','UMI','Iles mineures éloignées des États-Unis',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (228,'UM','UMI','United States Minor Outlying Islands',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (229,'UY','URY','Uruguay',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (230,'UZ','UZB','Ouzbékistan',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (230,'UZ','UZB','Uzbekistan',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (231,'VU','VUT','Vanuatu',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (232,'VE','VEN','Vénézuela',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (233,'VN','VNM','Viêt Nam',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (234,'VG','VGB','Iles Vierges britanniques',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (235,'VI','VIR','Iles Vierges américaines',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (236,'WF','WLF','Wallis-et-Futuna',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (237,'EH','ESH','Sahara occidental',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (238,'YE','YEM','Yémen',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (239,'ZM','ZMB','Zambie',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (232,'VE','VEN','Venezuela',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (233,'VN','VNM','Vietnam',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (234,'VG','VGB','British Virgin Islands',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (235,'VI','VIR','Virgin Islands of the United States',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (236,'WF','WLF','Wallis and Futuna',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (237,'EH','ESH','Western Sahara',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (238,'YE','YEM','Yemen',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (239,'ZM','ZMB','Zambia',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (240,'ZW','ZWE','Zimbabwe',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (241,'GG','GGY','Guernesey',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (242,'IM','IMN','Ile de Man',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (241,'GG','GGY','Guernsey',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (242,'IM','IMN','Isle of Man',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (243,'JE','JEY','Jersey',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (244,'ME','MNE','Monténégro',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (244,'ME','MNE','Montenegro',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (245,'BL','BLM','Saint-Barthélemy',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (246,'MF','MAF','Saint-Martin',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (247,'XK','XKX','Kosovo',1,0); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index c58b9ee3efe..8caf6e9a401 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -32,6 +32,11 @@ -- Missing in v13 or lower +-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; +-- VMYSQL4.1 update llx_propal set tms = datec where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; +-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; +-- VMYSQL4.1 update llx_propal set tms = null where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; + ALTER TABLE llx_ecm_files ADD COLUMN note_private text AFTER fk_user_m; ALTER TABLE llx_ecm_files ADD COLUMN note_public text AFTER note_private; @@ -62,9 +67,6 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) UPDATE llx_c_country SET eec = 1 WHERE code IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','NL','HU','IE','IM','IT','LT','LU','LV','MC','MT','PL','PT','RO','SE','SK','SI'); -ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64); - - INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 11, 'US-BASE', 'USA basic chart of accounts', 1); INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 14, 'CA-ENG-BASE', 'Canadian basic chart of accounts - English', 1); INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 154, 'SAT/24-2019', 'Catalogo y codigo agrupador fiscal del 2019', 1); @@ -79,6 +81,12 @@ DELETE FROM llx_user_param where param = 'MAIN_THEME' and value in ('auguria', ' -- For v14 +ALTER TABLE llx_import_model MODIFY COLUMN type varchar(64); +ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64); + +ALTER TABLE llx_import_model ADD COLUMN entity integer DEFAULT 0 NOT NULL; +ALTER TABLE llx_export_model ADD COLUMN entity integer DEFAULT 0 NOT NULL; + ALTER TABLE llx_product_lot ADD COLUMN eol_date datetime NULL; ALTER TABLE llx_product_lot ADD COLUMN manufacturing_date datetime NULL; ALTER TABLE llx_product_lot ADD COLUMN scrapping_date datetime NULL; @@ -492,7 +500,7 @@ ALTER TABLE llx_payment_donation ADD COLUMN ext_payment_id varchar(128) AFTER n -- Rebuild sequence for postgres only after query INSERT INTO llx_salary(rowid, ... -- VPGSQL8.2 SELECT dol_util_rebuild_sequences(); -UPDATE llx_const SET type = 'chaine', value = __ENCRYPT('github')__ WHERE __DECRYPT('name')__ = 'MAIN_BUGTRACK_ENABLELINK' AND __DECRYPT('value')__ = 1; +UPDATE llx_const SET type = 'chaine', value = __ENCRYPT('github')__ WHERE __DECRYPT('name')__ = 'MAIN_BUGTRACK_ENABLELINK' AND __DECRYPT('value')__ = '1'; ALTER TABLE llx_facture_fourn_det ADD COLUMN fk_remise_except integer DEFAULT NULL after remise_percent; ALTER TABLE llx_facture_fourn_det ADD UNIQUE INDEX uk_fk_remise_except (fk_remise_except, fk_facture_fourn); @@ -513,11 +521,13 @@ CREATE TABLE llx_knowledgemanagement_knowledgerecord( answer text, url varchar(255), fk_ticket integer, + fk_c_ticket_category integer, status integer NOT NULL -- END MODULEBUILDER FIELDS ) ENGINE=innodb; ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN fk_ticket integer; +ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN fk_c_ticket_category integer; ALTER TABLE llx_knowledgemanagement_knowledgerecord ADD COLUMN url varchar(255); @@ -546,4 +556,4 @@ create table llx_c_partnership_type active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; - +DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee'; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 6e9ea4601f8..59f04fdb2ca 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -533,3 +533,5 @@ UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NUL --ALTER TABLE llx_tablename ROW_FORMAT=DYNAMIC; +DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee'; + diff --git a/htdocs/install/mysql/tables/llx_export_model.sql b/htdocs/install/mysql/tables/llx_export_model.sql index 7e68eab4ad5..cfdb2fdc530 100644 --- a/htdocs/install/mysql/tables/llx_export_model.sql +++ b/htdocs/install/mysql/tables/llx_export_model.sql @@ -22,10 +22,10 @@ create table llx_export_model ( rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 0, -- by default on all entities for compatibility fk_user integer DEFAULT 0 NOT NULL, label varchar(50) NOT NULL, type varchar(64) NOT NULL, field text NOT NULL, filter text - )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_import_model.sql b/htdocs/install/mysql/tables/llx_import_model.sql index 2a110a2d80a..ceb3ae9f323 100644 --- a/htdocs/install/mysql/tables/llx_import_model.sql +++ b/htdocs/install/mysql/tables/llx_import_model.sql @@ -21,8 +21,9 @@ create table llx_import_model ( rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 0 NOT NULL, -- by default on all entities for compatibility fk_user integer DEFAULT 0 NOT NULL, label varchar(50) NOT NULL, - type varchar(50) NOT NULL, + type varchar(64) NOT NULL, field text NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql index c5332372019..65c8add25c4 100644 --- a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql +++ b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord.sql @@ -30,6 +30,7 @@ CREATE TABLE llx_knowledgemanagement_knowledgerecord( answer text, url varchar(255), fk_ticket integer, + fk_c_ticket_category integer, status integer NOT NULL -- END MODULEBUILDER FIELDS ) ENGINE=innodb; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index bc615c1da94..70257bba79e 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -58,12 +58,12 @@ error_reporting(0); error_reporting($err); -$setuplang = GETPOST("selectlang", 'aZ09', 3) ?GETPOST("selectlang", 'aZ09', 3) : 'auto'; +$setuplang = GETPOST("selectlang", 'aZ09', 3) ? GETPOST("selectlang", 'aZ09', 3) : 'auto'; $langs->setDefaultLang($setuplang); -$versionfrom = GETPOST("versionfrom", 'alpha', 3) ?GETPOST("versionfrom", 'alpha', 3) : (empty($argv[1]) ? '' : $argv[1]); -$versionto = GETPOST("versionto", 'alpha', 3) ?GETPOST("versionto", '', 3) : (empty($argv[2]) ? '' : $argv[2]); -$dirmodule = ((GETPOST("dirmodule", 'alpha', 3) && GETPOST("dirmodule", 'alpha', 3) != 'ignoredbversion')) ?GETPOST("dirmodule", 'alpha', 3) : ((empty($argv[3]) || $argv[3] == 'ignoredbversion') ? '' : $argv[3]); -$ignoredbversion = (GETPOST('ignoredbversion', 'alpha', 3) == 'ignoredbversion') ?GETPOST('ignoredbversion', 'alpha', 3) : ((empty($argv[3]) || $argv[3] != 'ignoredbversion') ? '' : $argv[3]); +$versionfrom = GETPOST("versionfrom", 'alpha', 3) ? GETPOST("versionfrom", 'alpha', 3) : (empty($argv[1]) ? '' : $argv[1]); +$versionto = GETPOST("versionto", 'alpha', 3) ? GETPOST("versionto", 'alpha', 3) : (empty($argv[2]) ? '' : $argv[2]); +$dirmodule = ((GETPOST("dirmodule", 'alpha', 3) && GETPOST("dirmodule", 'alpha', 3) != 'ignoredbversion')) ? GETPOST("dirmodule", 'alpha', 3) : ((empty($argv[3]) || $argv[3] == 'ignoredbversion') ? '' : $argv[3]); +$ignoredbversion = (GETPOST('ignoredbversion', 'alpha', 3) == 'ignoredbversion') ? GETPOST('ignoredbversion', 'alpha', 3) : ((empty($argv[3]) || $argv[3] != 'ignoredbversion') ? '' : $argv[3]); $langs->loadLangs(array("admin", "install", "other", "errors")); diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index 85d8a1bcb9e..872c5289c61 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -112,6 +112,8 @@ class KnowledgeRecord extends CommonObject 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), 'question' => array('type'=>'text', 'label'=>'Question', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'csslist'=>'tdoverflow300'), 'answer' => array('type'=>'html', 'label'=>'Solution', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>3, 'csslist'=>'tdoverflow300'), + //'url' => array('type'=>'varchar(255)', 'label'=>'URL', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflow200', 'help'=>'UrlForInfoPage'), + 'fk_c_ticket_category' => array('type'=>'integer:CTicketCategory:ticket/class/cticketcategory.class.php', 'label'=>'TicketGroup', 'enabled'=>'$conf->ticket->enabled', 'position'=>512, 'notnull'=>0, 'visible'=>-1, 'help'=>'YouCanLinkArticleToATicketCategory'), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Valid'),), ); public $rowid; @@ -126,6 +128,7 @@ class KnowledgeRecord extends CommonObject public $model_pdf; public $question; public $answer; + public $url; public $status; // END MODULEBUILDER PROPERTIES diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php index b33ecb652f7..c96319eb022 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_card.php +++ b/htdocs/knowledgemanagement/knowledgerecord_card.php @@ -327,7 +327,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; // Common attributes - //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field + $keyforbreak='fk_c_ticket_category'; // We change column just before this field //unset($object->fields['fk_project']); // Hide field already shown in banner //unset($object->fields['fk_soc']); // Hide field already shown in banner include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; @@ -344,54 +344,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); - /* - * Lines - */ - - if (!empty($object->table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - - print ' - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
'; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); - } - - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add products/services form - $object->formAddObjectLine(1, $mysoc, $soc); - - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - } - } - - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
'; - } - print ''; - - print "\n"; - } - - // Buttons for actions if ($action != 'presend' && $action != 'editline') { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 329b7ff2775..efe674e7ca8 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -849,10 +849,10 @@ Permission402=Create/modify discounts Permission403=Validate discounts Permission404=Delete discounts Permission430=Use Debug Bar -Permission511=Read payments of salaries (yours and subordinates) -Permission512=Create/modify payments of salaries -Permission514=Delete payments of salaries -Permission517=Read payments of salaries of everybody +Permission511=Read salaries and payments (yours and subordinates) +Permission512=Create/modify salaries and payments +Permission514=Delete salaries and payments +Permission517=Read salaries and payments everybody Permission519=Export salaries Permission520=Read Loans Permission522=Create/modify loans @@ -2144,3 +2144,4 @@ YouEnableDeprecatedWSAPIsUseRESTAPIsInstead=You enabled deprecated WS API. You s RandomlySelectedIfSeveral=Randomly selected if several pictures are available DatabasePasswordObfuscated=Database password is obfuscated in conf file DatabasePasswordNotObfuscated=Database password is NOT obfuscated in conf file +APIsAreNotEnabled=APIs modules are not enabled \ No newline at end of file diff --git a/htdocs/langs/en_US/deliveries.lang b/htdocs/langs/en_US/deliveries.lang index fdfd6404a8a..cd8a36e6c70 100644 --- a/htdocs/langs/en_US/deliveries.lang +++ b/htdocs/langs/en_US/deliveries.lang @@ -30,3 +30,4 @@ NonShippable=Not Shippable ShowShippableStatus=Show shippable status ShowReceiving=Show delivery receipt NonExistentOrder=Nonexistent order +StockQuantitiesAlreadyAllocatedOnPreviousLines = Stock quantities already allocated on previous lines diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 72d78178cf1..863b94af564 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -730,6 +730,7 @@ MenuMembers=Members MenuAgendaGoogle=Google agenda MenuTaxesAndSpecialExpenses=Taxes | Special expenses ThisLimitIsDefinedInSetup=Dolibarr limit (Menu home-setup-security): %s Kb, PHP limit: %s Kb +ThisLimitIsDefinedInSetupAt=Dolibarr limit (Menu %s): %s Kb, PHP limit (Param %s): %s Kb NoFileFound=No documents uploaded CurrentUserLanguage=Current language CurrentTheme=Current theme @@ -1134,4 +1135,5 @@ ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected CategTypeNotFound=No tag type found for type of records CopiedToClipboard=Copied to clipboard InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration. -ConfirmCancel=Are you sure you want to cancel \ No newline at end of file +ConfirmCancel=Are you sure you want to cancel +EmailMsgID=Email MsgID diff --git a/htdocs/langs/fr_FR/deliveries.lang b/htdocs/langs/fr_FR/deliveries.lang index bd13cce814c..6af98a54d4f 100644 --- a/htdocs/langs/fr_FR/deliveries.lang +++ b/htdocs/langs/fr_FR/deliveries.lang @@ -30,3 +30,4 @@ NonShippable=Non expédiable ShowShippableStatus=Afficher le statut Expédiable ShowReceiving=Afficher le bon de réception NonExistentOrder=Commande inexistante +StockQuantitiesAlreadyAllocatedOnPreviousLines = Qtés de stock déja attribuées sur une ou des lignes précédentes diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index 2969d6958b5..67be217f0d2 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -196,9 +196,10 @@ $(document).ready(function() { var capital=price2numjs($(idcap).val()); console.log("Change montly amount echeance="+echeance+" idcap="+idcap+" capital="+capital); $.ajax({ + method: "GET", dataType: 'json', url: 'calcmens.php', - data: { echeance: echeance, mens: mens, capital:capital, rate:rate / 100; ?> , nbterm : nbterm; ?>}, + data: { echeance: echeance, mens: mens, capital:capital, rate:rate / 100; ?>, nbterm: nbterm; ?>, token: '' }, success: function(data) { $.each(data, function(index, element) { var idcap_res='#hi_capital'+index; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 72698a2f8aa..affa435d389 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -469,13 +469,15 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl $sensitiveget = true; } - // Check all cases that need a mandatory token (all POST actions + all login, actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set + all sensitive GET actions) + // Check a token is provided for all cases that need a mandatory token + // (all POST actions + all login, actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set + all sensitive GET actions) if ( $_SERVER['REQUEST_METHOD'] == 'POST' || $sensitiveget || ((GETPOSTISSET('actionlogin') || GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) ) { - if (!GETPOST('token', 'alpha')) { // If token is not provided or empty + // If token is not provided or empty, error (we are in case it is mandatory) + if (!GETPOST('token', 'alpha') || GETPOST('token', 'alpha') == 'notrequired') { if (GETPOST('uploadform', 'int')) { dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused. File size too large."); $langs->loadLangs(array("errors", "install")); @@ -497,7 +499,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl $sessiontokenforthisurl = (empty($_SESSION['token']) ? '' : $_SESSION['token']); // TODO Get the sessiontokenforthisurl into the array of session token - if (GETPOSTISSET('token') && GETPOST('token', 'alpha') != $sessiontokenforthisurl) { + if (GETPOSTISSET('token') && GETPOST('token') != 'notrequired' && GETPOST('token', 'alpha') != $sessiontokenforthisurl) { dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused due to invalid token, so we disable POST and some GET parameters - referer=".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING); //print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers. setEventMessages('SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry', null, 'warnings'); @@ -2563,7 +2565,7 @@ function top_menu_search() - '; @@ -2585,6 +2587,26 @@ function top_menu_search() } }); + // arrow key nav + $(document).keydown(function(e) { + // Get the focused element: + var $focused = $(":focus"); + if($focused.length && $focused.hasClass("global-search-item")){ + + // UP - move to the previous line + if (e.keyCode == 38) { + e.preventDefault(); + $focused.prev().focus(); + } + + // DOWN - move to the next line + if (e.keyCode == 40) { + e.preventDefault(); + $focused.next().focus(); + } + } + }); + // submit form action $(".dropdown-global-search-button-list .global-search-item").on("click", function(event) { @@ -2617,7 +2639,6 @@ function top_menu_search() var openGlobalSearchDropDown = function() { - event.preventDefault(); $("#topmenu-global-search-dropdown").toggleClass("open"); $("#top-global-search-input").focus(); } @@ -3205,16 +3226,17 @@ if (!function_exists("llxFooter")) { country_code: 'country_code ? dol_escape_js($mysoc->country_code) : 'unknown'; ?>', php_version: '', os_version: '', - distrib: '' + distrib: '', + token: 'notrequired' }, success: function (data, status, xhr) { // success callback function (data contains body of response) - console.log("Ping ok"); + console.log("Ping ok"); $.ajax({ method: 'GET', url: '', timeout: 500, // timeout milliseconds cache: false, - data: { hash_algo: 'md5', hash_unique_id: '', action: 'firstpingok' }, // for update + data: { hash_algo: 'md5', hash_unique_id: '', action: 'firstpingok', token: 'notrequired' }, // for update }); }, error: function (data,status,xhr) { // error callback function @@ -3224,7 +3246,7 @@ if (!function_exists("llxFooter")) { url: '', timeout: 500, // timeout milliseconds cache: false, - data: { hash_algo: 'md5', hash_unique_id: '', action: 'firstpingko' }, + data: { hash_algo: 'md5', hash_unique_id: '', action: 'firstpingko', token: 'notrequired' }, }); } }); diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index d64c80c9355..f3228915592 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -3,7 +3,7 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2018-2019 Philippe Grand + * Copyright (C) 2018-2021 Philippe Grand * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -85,18 +85,18 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $this->marge_haute = 0; $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_logo = 1; // Display logo + $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 0; // Display payment mode + $this->option_condreg = 0; // Display payment terms + $this->option_codeproduitservice = 0; // Display product-service code + $this->option_multilang = 1; // Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts - // Recupere emetteur + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined @@ -135,7 +135,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); @@ -173,7 +174,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject if ($nbofiles) { $texte .= ''; } @@ -195,7 +196,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject /** * Function to build a document on disk using the generic odt module. * - * @param Commande $object Object source to build document + * @param MyObject $object Object source to build document * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details @@ -229,11 +230,11 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); - if ($conf->commande->dir_output) { + if ($conf->mymodule->dir_output) { // If $object is id instead of object if (!is_object($object)) { $id = $object; - $object = new Commande($this->db); + $object = new MyObject($this->db); $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -241,7 +242,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject } } - $dir = $conf->commande->multidir_output[isset($object->entity) ? $object->entity : 1]; + $object->fetch_thirdparty(); + + $dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1]; $objectref = dol_sanitizeFileName($object->ref); if (!preg_match('/specimen/i', $objectref)) { $dir .= "/".$objectref; @@ -281,7 +284,11 @@ class doc_generic_myobject_odt extends ModelePDFMyObject //print "conf->societe->dir_temp=".$conf->societe->dir_temp; dol_mkdir($conf->mymodule->dir_temp); - + if (!is_writable($conf->mymodule->dir_temp)) { + $this->error = "Failed to write in temp directory ".$conf->mymodule->dir_temp; + dol_syslog('Error in write_file: '.$this->error, LOG_ERR); + return -1; + } // If CUSTOMER contact defined on order, we use it $usecontact = false; @@ -331,7 +338,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $odfHandler = new odf( $srctemplatepath, array( - 'PATH_TO_TMP' => $conf->commande->dir_temp, + 'PATH_TO_TMP' => $conf->mymodule->dir_temp, 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 33d4a108f17..ed17db03db6 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -299,6 +299,10 @@ class Mos extends DolibarrApi */ public function produceAndConsume($id, $request_data = null) { + global $langs; + + $error = 0; + if (!DolibarrApiAccess::$user->rights->mrp->write) { throw new RestException(401, 'Not enough permission'); } @@ -327,6 +331,12 @@ class Mos extends DolibarrApi if ($field == 'autoclose') { $autoclose = $value; } + if ($field == 'arraytoconsume') { + $arraytoconsume = $value; + } + if ($field == 'arraytoproduce') { + $arraytoproduce = $value; + } } if (empty($labelmovement)) { @@ -336,8 +346,291 @@ class Mos extends DolibarrApi throw new RestException(500, "Field inventorycode not prodivded"); } - // TODO Add code for consume and produce... - throw new RestException(500, "Feature not yet available"); + // Code for consume and produce... + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; + dol_include_once('/mrp/lib/mrp_mo.lib.php'); + + $stockmove = new MouvementStock($this->db); + + if (!empty($arraytoconsume) && !empty($arraytoproduce)) { + $pos = 0; + $arrayofarrayname = array("arraytoconsume","arraytoproduce"); + foreach ($arrayofarrayname as $arrayname) { + foreach ($$arrayname as $value) { + $tmpproduct = new Product($this->db); + if (empty($value["objectid"])) { + throw new RestException(500, "Field objectid required in ".$arrayname); + } + $tmpproduct->fetch($value["qty"]); + if (empty($value["qty"])) { + throw new RestException(500, "Field qty required in ".$arrayname); + } + if ($value["qty"]!=0) { + $qtytoprocess = $value["qty"]; + if (isset($value["fk_warehouse"])) { // If there is a warehouse to set + if (!($value["fk_warehouse"] > 0)) { // If there is no warehouse set. + throw new RestException(500, "Field fk_warehouse must be > 0 in ".$arrayname); + $error++; + } + if ($tmpproduct->status_batch) { + throw new RestException(500, "Product ".$tmpproduct->ref."must be in batch"); + $error++; + } + } + $idstockmove = 0; + if (!$error && $value["fk_warehouse"] > 0) { + // Record stock movement + $id_product_batch = 0; + $stockmove->origin = $this->mo; + if ($qtytoprocess >= 0) { + $moline = new MoLine($this->db); + $moline->fk_mo = $this->mo->id; + $moline->position = $pos; + $moline->fk_product = $value["objectid"]; + $moline->fk_warehouse = $value["fk_warehouse"]; + $moline->qty = $qtytoprocess; + $moline->batch = $tmpproduct->status_batch; + $moline->role = 'toproduce'; + $moline->fk_mrp_production = ""; + $moline->fk_stock_movement = $idstockmove; + $moline->fk_user_creat = DolibarrApiAccess::$user->id; + + $resultmoline = $moline->create(DolibarrApiAccess::$user); + if ($resultmoline <= 0) { + $error++; + throw new RestException(500, $moline->error); + } + $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $value["objectid"], $value["fk_warehouse"], $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + } else { + $moline = new MoLine($this->db); + $moline->fk_mo = $this->mo->id; + $moline->position = $pos; + $moline->fk_product = $value["objectid"]; + $moline->fk_warehouse = $value["fk_warehouse"]; + $moline->qty = $qtytoprocess; + $moline->batch = $tmpproduct->status_batch; + $moline->role = 'toconsume'; + $moline->fk_mrp_production = ""; + $moline->fk_stock_movement = $idstockmove; + $moline->fk_user_creat = DolibarrApiAccess::$user->id; + + $resultmoline = $moline->create(DolibarrApiAccess::$user); + if ($resultmoline <= 0) { + $error++; + throw new RestException(500, $moline->error); + } + $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $value["objectid"], $value["fk_warehouse"], $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + } + if ($idstockmove < 0) { + $error++; + throw new RestException(500, $stockmove->error); + } + } + if (!$error) { + // Record consumption + $moline = new MoLine($this->db); + $moline->fk_mo = $this->mo->id; + $moline->position = $pos; + $moline->fk_product = $value["objectid"]; + $moline->fk_warehouse = $value["fk_warehouse"]; + $moline->qty = $qtytoprocess; + $moline->batch = $tmpproduct->status_batch; + if ($arrayname == "arraytoconsume") { + $moline->role = 'consumed'; + } else { + $moline->role = 'produced'; + } + $moline->fk_mrp_production = ""; + $moline->fk_stock_movement = $idstockmove; + $moline->fk_user_creat = DolibarrApiAccess::$user->id; + + $resultmoline = $moline->create(DolibarrApiAccess::$user); + if ($resultmoline <= 0) { + $error++; + throw new RestException(500, $moline->error); + } + + $pos++; + } + } + } + } + if (!$error) { + $consumptioncomplete = true; + $productioncomplete = true; + + if ($autoclose <= 0) { + $consumptioncomplete = false; + $productioncomplete = false; + } + } + } else { + $pos = 0; + foreach ($this->mo->lines as $line) { + if ($line->role == 'toconsume') { + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($line->fk_product); + if ($line->qty != 0) { + $qtytoprocess = $line->qty; + if (isset($line->fk_warehouse)) { // If there is a warehouse to set + if (!($line->fk_warehouse > 0)) { // If there is no warehouse set. + $langs->load("errors"); + throw new RestException(500, $langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref)); + $error++; + } + if ($tmpproduct->status_batch) { + $langs->load("errors"); + throw new RestException(500, $langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref)); + $error++; + } + } + $idstockmove = 0; + if (!$error && $line->fk_warehouse > 0) { + // Record stock movement + $id_product_batch = 0; + $stockmove->origin = $this->mo; + if ($qtytoprocess >= 0) { + $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + } else { + $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + } + if ($idstockmove < 0) { + $error++; + throw new RestException(500, $stockmove->error); + } + } + if (!$error) { + // Record consumption + $moline = new MoLine($this->db); + $moline->fk_mo = $this->mo->id; + $moline->position = $pos; + $moline->fk_product = $line->fk_product; + $moline->fk_warehouse = $line->fk_warehouse; + $moline->qty = $qtytoprocess; + $moline->batch = $tmpproduct->status_batch; + $moline->role = 'consumed'; + $moline->fk_mrp_production = $line->id; + $moline->fk_stock_movement = $idstockmove; + $moline->fk_user_creat = DolibarrApiAccess::$user->id; + + $resultmoline = $moline->create(DolibarrApiAccess::$user); + if ($resultmoline <= 0) { + $error++; + throw new RestException(500, $moline->error); + } + + $pos++; + } + } + } + } + $pos = 0; + foreach ($this->mo->lines as $line) { + if ($line->role == 'toproduce') { + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($line->fk_product); + if ($line->qty != 0) { + $qtytoprocess = $line->qty; + if (isset($line->fk_warehouse)) { // If there is a warehouse to set + if (!($line->fk_warehouse > 0)) { // If there is no warehouse set. + $langs->load("errors"); + throw new RestException(500, $langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref)); + $error++; + } + if ($tmpproduct->status_batch) { + $langs->load("errors"); + throw new RestException(500, $langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref)); + $error++; + } + } + $idstockmove = 0; + if (!$error && $line->fk_warehouse > 0) { + // Record stock movement + $id_product_batch = 0; + $stockmove->origin = $this->mo; + if ($qtytoprocess >= 0) { + $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + } else { + $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + } + if ($idstockmove < 0) { + $error++; + throw new RestException(500, $stockmove->error); + } + } + if (!$error) { + // Record consumption + $moline = new MoLine($this->db); + $moline->fk_mo = $this->mo->id; + $moline->position = $pos; + $moline->fk_product = $line->fk_product; + $moline->fk_warehouse = $line->fk_warehouse; + $moline->qty = $qtytoprocess; + $moline->batch = $tmpproduct->status_batch; + $moline->role = 'produced'; + $moline->fk_mrp_production = $line->id; + $moline->fk_stock_movement = $idstockmove; + $moline->fk_user_creat = DolibarrApiAccess::$user->id; + + $resultmoline = $moline->create(DolibarrApiAccess::$user); + if ($resultmoline <= 0) { + $error++; + throw new RestException(500, $moline->error); + } + + $pos++; + } + } + } + } + + if (!$error) { + $consumptioncomplete = true; + $productioncomplete = true; + + if ($autoclose > 0) { + foreach ($this->mo->lines as $line) { + if ($line->role == 'toconsume') { + $arrayoflines = $this->mo->fetchLinesLinked('consumed', $line->id); + $alreadyconsumed = 0; + foreach ($arrayoflines as $line2) { + $alreadyconsumed += $line2['qty']; + } + + if ($alreadyconsumed < $line->qty) { + $consumptioncomplete = false; + } + } + if ($line->role == 'toproduce') { + $arrayoflines = $this->mo->fetchLinesLinked('produced', $line->id); + $alreadyproduced = 0; + foreach ($arrayoflines as $line2) { + $alreadyproduced += $line2['qty']; + } + + if ($alreadyproduced < $line->qty) { + $productioncomplete = false; + } + } + } + } else { + $consumptioncomplete = false; + $productioncomplete = false; + } + } + } + // Update status of MO + dol_syslog("consumptioncomplete = ".$consumptioncomplete." productioncomplete = ".$productioncomplete); + //var_dump("consumptioncomplete = ".$consumptioncomplete." productioncomplete = ".$productioncomplete); + if ($consumptioncomplete && $productioncomplete) { + $result = $this->mo->setStatut(self::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); + } else { + $result = $this->mo->setStatut(self::STATUS_INPROGRESS, 0, '', 'MRP_MO_PRODUCED'); + } + if ($result <= 0) { + throw new RestException(500, $this->mo->error); + } return $this->mo->id; } diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php index 62f74ce016e..8fe07df89c1 100644 --- a/htdocs/mrp/lib/mrp_mo.lib.php +++ b/htdocs/mrp/lib/mrp_mo.lib.php @@ -78,7 +78,7 @@ function moPrepareHead($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->mrp->dir_output."/mo/".dol_sanitizeFileName($object->ref); + $upload_dir = $conf->mrp->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = dol_buildpath("/mrp/mo_document.php", 1).'?id='.$object->id; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 093604df9a1..fad22645cd5 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -138,6 +138,16 @@ if (empty($reshook)) { // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + // Action to build doc + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + if ($action == 'set_thirdparty' && $permissiontoadd) { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) { + $object->setProject(GETPOST('projectid', 'int')); + } + // Actions to send emails $triggersendname = 'MO_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; @@ -147,13 +157,6 @@ if (empty($reshook)) { // Action to move up and down lines of object //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); - } - if ($action == 'classin' && $permissiontoadd) { - $object->setProject(GETPOST('projectid', 'int')); - } - // Action close produced if ($action == 'confirm_produced' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setStatut($object::STATUS_PRODUCED, 0, '', 'MRP_MO_PRODUCED'); diff --git a/htdocs/opensurvey/fonctions.php b/htdocs/opensurvey/fonctions.php index cda1bd81f79..3d8d76c5c1e 100644 --- a/htdocs/opensurvey/fonctions.php +++ b/htdocs/opensurvey/fonctions.php @@ -116,6 +116,12 @@ function llxHeaderSurvey($title, $head = "", $disablejs = 0, $disablehead = 0, $ print ''; } + if (!empty($conf->global->OPENSURVEY_IMAGE_PUBLIC_INTERFACE)) { + print '
'; + print ''; + print '
'; + } + print '

'; } diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index ce5f79b1174..817f3d88139 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -55,7 +55,7 @@ if (GETPOST('confirmation')) { $tmphorairesi = GETPOST('horaires'.$i, 'array'); - if (!is_array($tmphorairesi) || empty($tmphorairesi[$j])) { + if (!is_array($tmphorairesi)) { $errheure[$i][$j] = true; $erreur = true; continue; @@ -155,7 +155,7 @@ if (GETPOST('confirmation')) { } } - if (isset($errheure)) { + if (!empty($errheure)) { setEventMessages($langs->trans("ErrorBadFormat"), null, 'errors'); } } diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index b862eddefc5..5d39b55ff76 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -39,7 +39,7 @@ print dol_get_fiche_head('');
" method="post"> - + diff --git a/htdocs/product/canvas/product/tpl/card_edit.tpl.php b/htdocs/product/canvas/product/tpl/card_edit.tpl.php index 21f2edefc2d..2e04f660084 100644 --- a/htdocs/product/canvas/product/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_edit.tpl.php @@ -38,7 +38,7 @@ dol_htmloutput_errors($object->error, $object->errors); ?> " method="post"> - + diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index ce3c4f5cc58..73f79b6efdb 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -39,7 +39,7 @@ print dol_get_fiche_head(''); " method="post"> - + diff --git a/htdocs/product/canvas/service/tpl/card_edit.tpl.php b/htdocs/product/canvas/service/tpl/card_edit.tpl.php index 4906b0dcf2c..a656d749a4b 100644 --- a/htdocs/product/canvas/service/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_edit.tpl.php @@ -38,7 +38,7 @@ dol_htmloutput_errors($object->error, $object->errors); ?> " method="post"> - + diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 1b04a77083c..3528d5ef299 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1188,11 +1188,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "
'.$langs->trans("PublicUrl").''; - print img_picto('', 'globe', 'class="pictofixedwidth"'); - print ''; - print '
'.$langs->trans("PublicUrl").''; + print img_picto('', 'globe', 'class="pictofixedwidth"'); + print ''; + print '
'.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).''; - print ''; - print '
'.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).''; + print ''; + print '
'.$form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1).''; - print ''; - print '
'.$form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1).''; + print ''; + print '
'.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).''; - $statutarray = array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - print $form->selectarray('finished', $statutarray, GETPOST('finished', 'alpha'), 1); - print '
'.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).''; + $statutarray = array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); + print $form->selectarray('finished', $statutarray, GETPOST('finished', 'alpha'), 1); + print '
'.$langs->trans("Weight").''; - print ''; - print $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOSTISSET('weight_units') ?GETPOST('weight_units', 'alpha') : (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? 0 : $conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 2); - print '
'.$langs->trans("Weight").''; + print ''; + print $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOSTISSET('weight_units') ?GETPOST('weight_units', 'alpha') : (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? 0 : $conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 2); + print '
'; - // VAT - print ''; - print '
'.$langs->trans("VATRate").''; - $defaultva = get_default_tva($mysoc, $mysoc); - print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); - print '
'; + if (empty($conf->global->PRODUCT_DISABLE_PRICES)) { + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + // We do no show price array on create when multiprices enabled. + // We must set them on prices tab. + print ''; + // VAT + print ''; + print '
'.$langs->trans("VATRate").''; + $defaultva = get_default_tva($mysoc, $mysoc); + print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); + print '
'; - print '
'; - } else { - print ''; + print '
'; + } else { + print '
'; - // Price - print ''; - print ''; + // Price + print ''; + print ''; - // Min price - print ''; - print ''; + // Min price + print ''; + print ''; - // VAT - print ''; + // VAT + print ''; - print '
'.$langs->trans("SellingPrice").''; - print $form->selectPriceBaseType($conf->global->PRODUCT_PRICE_BASE_TYPE, "price_base_type"); - print '
'.$langs->trans("SellingPrice").''; + print $form->selectPriceBaseType($conf->global->PRODUCT_PRICE_BASE_TYPE, "price_base_type"); + print '
'.$langs->trans("MinPrice").''; - print '
'.$langs->trans("MinPrice").''; + print '
'.$langs->trans("VATRate").''; - $defaultva = get_default_tva($mysoc, $mysoc); - print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); - print '
'.$langs->trans("VATRate").''; + $defaultva = get_default_tva($mysoc, $mysoc); + print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); + print '
'; + print ''; - print '
'; + print '
'; + } } // Accountancy codes print ''."\n"; print ''; - if (!empty($conf->accounting->enabled)) { - // Accountancy_code_sell - print ''; - print ''; - - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) { - print ''; + if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) { + if (!empty($conf->accounting->enabled)) { + // Accountancy_code_sell + print ''; print ''; - } - // Accountancy_code_sell_export - print ''; - print ''; + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { + print ''; + print ''; + } - // Accountancy_code_buy - print ''; - print ''; - - // Accountancy_code_buy_intra - if ($mysoc->isInEEC()) { - print ''; + // Accountancy_code_sell_export + print ''; print ''; + + // Accountancy_code_buy + print ''; + print ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) { + print ''; + print ''; + } + + // Accountancy_code_buy_export + print ''; + print ''; + } else {// For external software + if (!empty($accountancy_code_sell)) { + $object->accountancy_code_sell = $accountancy_code_sell; + } + if (!empty($accountancy_code_sell_intra)) { + $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; + } + if (!empty($accountancy_code_sell_export)) { + $object->accountancy_code_sell_export = $accountancy_code_sell_export; + } + if (!empty($accountancy_code_buy)) { + $object->accountancy_code_buy = $accountancy_code_buy; + } + if (!empty($accountancy_code_buy_intra)) { + $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; + } + if (!empty($accountancy_code_buy_export)) { + $object->accountancy_code_buy_export = $accountancy_code_buy_export; + } + + // Accountancy_code_sell + print ''; + print ''; + + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { + print ''; + print ''; + } + + // Accountancy_code_sell_export + print ''; + print ''; + + // Accountancy_code_buy + print ''; + print ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) { + print ''; + print ''; + } + + // Accountancy_code_buy_export + print ''; + print ''; } - - // Accountancy_code_buy_export - print ''; - print ''; - } else {// For external software - if (!empty($accountancy_code_sell)) { - $object->accountancy_code_sell = $accountancy_code_sell; - } - if (!empty($accountancy_code_sell_intra)) { - $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; - } - if (!empty($accountancy_code_sell_export)) { - $object->accountancy_code_sell_export = $accountancy_code_sell_export; - } - if (!empty($accountancy_code_buy)) { - $object->accountancy_code_buy = $accountancy_code_buy; - } - if (!empty($accountancy_code_buy_intra)) { - $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; - } - if (!empty($accountancy_code_buy_export)) { - $object->accountancy_code_buy_export = $accountancy_code_buy_export; - } - - // Accountancy_code_sell - print ''; - print ''; - - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) { - print ''; - print ''; - } - - // Accountancy_code_sell_export - print ''; - print ''; - - // Accountancy_code_buy - print ''; - print ''; - - // Accountancy_code_buy_intra - if ($mysoc->isInEEC()) { - print ''; - print ''; - } - - // Accountancy_code_buy_export - print ''; - print ''; } print '
'.$langs->trans("ProductAccountancySellCode").''; - if ($type == 0) { - $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ? GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT); - } else { - $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ? GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT); - } - print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); - print '
'.$langs->trans("ProductAccountancySellIntraCode").'
'.$langs->trans("ProductAccountancySellCode").''; if ($type == 0) { - $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ? GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT); + $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ? GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT); } else { - $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ? GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT); + $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ? GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT); } - print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); + print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); print '
'.$langs->trans("ProductAccountancySellExportCode").''; - if ($type == 0) { - $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ? GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT); - } else { - $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ? GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT); - } - print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); - print '
'.$langs->trans("ProductAccountancySellIntraCode").''; + if ($type == 0) { + $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ? GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT); + } else { + $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ? GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); + print '
'.$langs->trans("ProductAccountancyBuyCode").''; - if ($type == 0) { - $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT); - } else { - $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT); - } - print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); - print '
'.$langs->trans("ProductAccountancyBuyIntraCode").'
'.$langs->trans("ProductAccountancySellExportCode").''; if ($type == 0) { - $accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT); + $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ? GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT); } else { - $accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT); + $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ? GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT); } - print $formaccounting->select_account($accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); + print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); + print '
'.$langs->trans("ProductAccountancyBuyCode").''; + if ($type == 0) { + $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT); + } else { + $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); + print '
'.$langs->trans("ProductAccountancyBuyIntraCode").''; + if ($type == 0) { + $accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT); + } else { + $accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); + print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; + if ($type == 0) { + $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT); + } else { + $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_buy_export, 'accountancy_code_buy_export', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); + print '
'.$langs->trans("ProductAccountancySellCode").''; + print '
'.$langs->trans("ProductAccountancySellIntraCode").''; + print '
'.$langs->trans("ProductAccountancySellExportCode").''; + print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print '
'.$langs->trans("ProductAccountancyBuyIntraCode").''; + print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; - if ($type == 0) { - $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT); - } else { - $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT); - } - print $formaccounting->select_account($accountancy_code_buy_export, 'accountancy_code_buy_export', 1, null, 1, 1, 'minwidth150 maxwidth300', 1); - print '
'.$langs->trans("ProductAccountancySellCode").''; - print '
'.$langs->trans("ProductAccountancySellIntraCode").''; - print '
'.$langs->trans("ProductAccountancySellExportCode").''; - print '
'.$langs->trans("ProductAccountancyBuyCode").''; - print '
'.$langs->trans("ProductAccountancyBuyIntraCode").''; - print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; - print '
'; @@ -1708,9 +1722,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "\n"; // Public Url - print ''.$langs->trans("PublicUrl").''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) { + print ''.$langs->trans("PublicUrl").''; + print ''; + print ''; + } // Stock if ($object->isProduct() && !empty($conf->stock->enabled)) { @@ -1743,16 +1759,20 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print $formproduct->selectMeasuringUnits("duration_unit", "time", $object->duration_unit, 0, 1); print ''; } else { - // Nature - print ''.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).''; - print $formproduct->selectProductNature('finished', $object->finished); - print ''; + if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { + // Nature + print ''.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).''; + print $formproduct->selectProductNature('finished', $object->finished); + print ''; + } - // Brut Weight - print ''.$langs->trans("Weight").''; - print ' '; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); - print ''; + if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) { + // Brut Weight + print ''.$langs->trans("Weight").''; + print ' '; + print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); + print ''; + } if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Brut Length @@ -1867,81 +1887,83 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; - if (!empty($conf->accounting->enabled)) { - // Accountancy_code_sell - print ''; - print ''; - - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) { - print ''; + if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) { + if (!empty($conf->accounting->enabled)) { + // Accountancy_code_sell + print ''; print ''; - } - // Accountancy_code_sell_export - print ''; - print ''; + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { + print ''; + print ''; + } - // Accountancy_code_buy - print ''; - print ''; - - // Accountancy_code_buy_intra - if ($mysoc->isInEEC()) { - print ''; + // Accountancy_code_sell_export + print ''; print ''; + + // Accountancy_code_buy + print ''; + print ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) { + print ''; + print ''; + } + + // Accountancy_code_buy_export + print ''; + print ''; + } else { + // For external software + // Accountancy_code_sell + print ''; + print ''; + + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { + print ''; + print ''; + } + + // Accountancy_code_sell_export + print ''; + print ''; + + // Accountancy_code_buy + print ''; + print ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) { + print ''; + print ''; + } + + // Accountancy_code_buy_export + print ''; + print ''; } - - // Accountancy_code_buy_export - print ''; - print ''; - } else { - // For external software - // Accountancy_code_sell - print ''; - print ''; - - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) { - print ''; - print ''; - } - - // Accountancy_code_sell_export - print ''; - print ''; - - // Accountancy_code_buy - print ''; - print ''; - - // Accountancy_code_buy_intra - if ($mysoc->isInEEC()) { - print ''; - print ''; - } - - // Accountancy_code_buy_export - print ''; - print ''; } print '
'.$langs->trans("ProductAccountancySellCode").''; - print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1, 'minwidth150 maxwidth300'); - print '
'.$langs->trans("ProductAccountancySellIntraCode").'
'.$langs->trans("ProductAccountancySellCode").''; - print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1, 'minwidth150 maxwidth300'); print '
'.$langs->trans("ProductAccountancySellExportCode").''; - print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1, 'minwidth150 maxwidth300'); - print '
'.$langs->trans("ProductAccountancySellIntraCode").''; + print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print '
'.$langs->trans("ProductAccountancyBuyCode").''; - print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1, 'minwidth150 maxwidth300'); - print '
'.$langs->trans("ProductAccountancyBuyIntraCode").'
'.$langs->trans("ProductAccountancySellExportCode").''; - print $formaccounting->select_account($object->accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print '
'.$langs->trans("ProductAccountancyBuyIntraCode").''; + print $formaccounting->select_account($object->accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; + print $formaccounting->select_account($object->accountancy_code_buy_export, 'accountancy_code_buy_export', 1, '', 1, 1, 'minwidth150 maxwidth300'); + print '
'.$langs->trans("ProductAccountancySellCode").''; + print '
'.$langs->trans("ProductAccountancySellIntraCode").''; + print '
'.$langs->trans("ProductAccountancySellExportCode").''; + print '
'.$langs->trans("ProductAccountancyBuyCode").''; + print '
'.$langs->trans("ProductAccountancyBuyIntraCode").''; + print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; - print $formaccounting->select_account($object->accountancy_code_buy_export, 'accountancy_code_buy_export', 1, '', 1, 1, 'minwidth150 maxwidth300'); - print '
'.$langs->trans("ProductAccountancySellCode").''; - print '
'.$langs->trans("ProductAccountancySellIntraCode").''; - print '
'.$langs->trans("ProductAccountancySellExportCode").''; - print '
'.$langs->trans("ProductAccountancyBuyCode").''; - print '
'.$langs->trans("ProductAccountancyBuyIntraCode").''; - print '
'.$langs->trans("ProductAccountancyBuyExportCode").''; - print '
'; @@ -2170,9 +2192,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("Description").''.(dol_textishtml($object->description) ? $object->description : dol_nl2br($object->description, 1, true)).''; // Public URL - print ''.$langs->trans("PublicUrl").''; - print dol_print_url($object->url); - print ''; + if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) { + print ''.$langs->trans("PublicUrl").''; + print dol_print_url($object->url); + print ''; + } // Default warehouse if ($object->isProduct() && !empty($conf->stock->enabled)) { @@ -2218,19 +2242,23 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } else { - // Nature - print ''.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).''; - print $object->getLibFinished(); - print ''; + if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { + // Nature + print ''.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).''; + print $object->getLibFinished(); + print ''; + } // Brut Weight - print ''.$langs->trans("Weight").''; - if ($object->weight != '') { - print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units); - } else { - print ' '; + if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) { + print ''.$langs->trans("Weight").''; + if ($object->weight != '') { + print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units); + } else { + print ' '; + } + print "\n"; } - print "\n"; if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Brut Length diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 8d53db4c0b7..9957641c13b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -231,8 +231,8 @@ class Product extends CommonObject public $desiredstock = 0; /* - * Service expiration - */ + * Service expiration + */ public $duration_value; /** @@ -543,7 +543,7 @@ class Product extends CommonObject { global $conf, $langs; - $error = 0; + $error = 0; // Clean parameters $this->ref = dol_sanitizeFileName(dol_string_nospecial(trim($this->ref))); @@ -1154,8 +1154,8 @@ class Product extends CommonObject // Multilangs if (!empty($conf->global->MAIN_MULTILANGS)) { if ($this->setMultiLangs($user) < 0) { - $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; - return -2; + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; + return -2; } } @@ -2253,8 +2253,8 @@ class Product extends CommonObject //For MultiCompany //PMP per entity & Stocks Sharings stock_reel includes only stocks shared with this entity - $separatedEntityPMP = false; - $separatedStock = false; + $separatedEntityPMP = false; // Set to true to get the AWP from table llx_product_perentity instead of field 'pmp' into llx_product. + $separatedStock = false; // Set to true will count stock from subtable llx_product_stock. It is slower than using denormalized field 'stock', but it is required when using multientity and shared warehouses. if (!empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_ENABLED)) { if (!empty($conf->global->MULTICOMPANY_PMP_PER_ENTITY_ENABLED)) { $checkPMPPerEntity = $this->db->query("SELECT pmp FROM " . MAIN_DB_PREFIX . "product_perentity WHERE fk_product = ".((int) $id)." AND entity = ".(int) $conf->entity); @@ -2269,17 +2269,18 @@ class Product extends CommonObject $visibleWarehousesEntities .= "," . implode(",", $mc->sharings['stock']); } } - if ($separatedStock) { - $sql .= " SUM(sp.reel) as stock,"; - } else { - $sql .= " p.stock,"; - } if ($separatedEntityPMP) { - $sql .= " ppe.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,"; + $sql .= " ppe.pmp,"; } else { - $sql .= " p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,"; + $sql .= " p.pmp,"; + } + $sql .= " p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,"; + $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf,"; + if ($separatedStock) { + $sql .= " SUM(sp.reel) as stock"; + } else { + $sql .= " p.stock"; } - $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) || $separatedEntityPMP) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); @@ -2300,11 +2301,30 @@ class Product extends CommonObject } } if ($separatedStock) { - $sql .= " AND sp.fk_entrepot IN ( - SELECT rowid - FROM ".MAIN_DB_PREFIX."entrepot WHERE entity IN (".$this->db->sanitize($visibleWarehousesEntities)."))"; + $sql .= " AND sp.fk_entrepot IN (SELECT rowid FROM ".MAIN_DB_PREFIX."entrepot WHERE entity IN (".$this->db->sanitize($visibleWarehousesEntities)."))"; + } + if ($separatedStock) { + $sql .= " GROUP BY p.rowid, p.ref, p.ref_ext, p.label, p.description, p.url, p.note_public, p.note, p.customcode, p.fk_country, p.fk_state, p.lifetime, p.qc_frequency, p.price, p.price_ttc,"; + $sql .= " p.price_min, p.price_min_ttc, p.price_base_type, p.cost_price, p.default_vat_code, p.tva_tx, p.recuperableonly, p.localtax1_tx, p.localtax2_tx, p.localtax1_type, p.localtax2_type, p.tosell,"; + $sql .= " p.tobuy, p.fk_product_type, p.duration, p.fk_default_warehouse, p.seuil_stock_alerte, p.canvas, p.net_measure, p.net_measure_units, p.weight, p.weight_units,"; + $sql .= " p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,"; + $sql .= " p.surface, p.surface_units, p.volume, p.volume_units, p.barcode, p.fk_barcode_type, p.finished,"; + if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; + } else { + $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export, ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,"; + } + if ($separatedEntityPMP) { + $sql .= " ppe.pmp,"; + } else { + $sql .= " p.pmp,"; + } + $sql .= " p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.batch_mask, p.fk_unit,"; + $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf"; + if (!$separatedStock) { + $sql .= ", p.stock"; + } } - $resql = $this->db->query($sql); if ($resql) { @@ -2435,39 +2455,39 @@ class Product extends CommonObject // Price by quantity /* - $this->prices_by_qty[$i]=$result["price_by_qty"]; - $this->prices_by_qty_id[$i]=$result["rowid"]; - // Récuperation de la liste des prix selon qty si flag positionné - if ($this->prices_by_qty[$i] == 1) - { - $sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql.= " WHERE fk_product_price = ".$this->prices_by_qty_id[$i]; - $sql.= " ORDER BY quantity ASC"; - $resultat=array(); - $resql = $this->db->query($sql); - if ($resql) - { - $ii=0; - while ($result= $this->db->fetch_array($resql)) { - $resultat[$ii]=array(); - $resultat[$ii]["rowid"]=$result["rowid"]; - $resultat[$ii]["price"]= $result["price"]; - $resultat[$ii]["unitprice"]= $result["unitprice"]; - $resultat[$ii]["quantity"]= $result["quantity"]; - $resultat[$ii]["remise_percent"]= $result["remise_percent"]; - $resultat[$ii]["remise"]= $result["remise"]; // deprecated - $resultat[$ii]["price_base_type"]= $result["price_base_type"]; - $ii++; - } - $this->prices_by_qty_list[$i]=$resultat; - } - else - { - dol_print_error($this->db); - return -1; - } - }*/ + $this->prices_by_qty[$i]=$result["price_by_qty"]; + $this->prices_by_qty_id[$i]=$result["rowid"]; + // Récuperation de la liste des prix selon qty si flag positionné + if ($this->prices_by_qty[$i] == 1) + { + $sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; + $sql.= " WHERE fk_product_price = ".$this->prices_by_qty_id[$i]; + $sql.= " ORDER BY quantity ASC"; + $resultat=array(); + $resql = $this->db->query($sql); + if ($resql) + { + $ii=0; + while ($result= $this->db->fetch_array($resql)) { + $resultat[$ii]=array(); + $resultat[$ii]["rowid"]=$result["rowid"]; + $resultat[$ii]["price"]= $result["price"]; + $resultat[$ii]["unitprice"]= $result["unitprice"]; + $resultat[$ii]["quantity"]= $result["quantity"]; + $resultat[$ii]["remise_percent"]= $result["remise_percent"]; + $resultat[$ii]["remise"]= $result["remise"]; // deprecated + $resultat[$ii]["price_base_type"]= $result["price_base_type"]; + $ii++; + } + $this->prices_by_qty_list[$i]=$resultat; + } + else + { + dol_print_error($this->db); + return -1; + } + }*/ } else { $this->error = $this->db->lasterror; return -1; @@ -2581,9 +2601,9 @@ class Product extends CommonObject } if (!empty($conf->dynamicprices->enabled) && !empty($this->fk_price_expression) && empty($ignore_expression)) { - include_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProduct($this); + $price_result = $priceparser->parseProduct($this); if ($price_result >= 0) { $this->price = $price_result; // Calculate the VAT @@ -2601,7 +2621,7 @@ class Product extends CommonObject return 0; } } else { - $this->error = $this->db->lasterror; + $this->error = $this->db->lasterror(); return -1; } } @@ -3996,10 +4016,10 @@ class Product extends CommonObject $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec)'; $sql .= ' VALUES ('.((int) $id_pere).', '.((int) $id_fils).', '.((float) $qty).', '.((int) $incdec).')'; if (!$this->db->query($sql)) { - dol_print_error($this->db); - return -1; + dol_print_error($this->db); + return -1; } else { - return 1; + return 1; } } } @@ -4203,7 +4223,7 @@ class Product extends CommonObject return -1; } } else { - // If the supplier price already exists for this product and quantity + // If the supplier price already exists for this product and quantity $this->product_fourn_price_id = $obj->rowid; return 0; } @@ -4378,16 +4398,16 @@ class Product extends CommonObject // les fournisseurs /*$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur (" - . " datec, fk_product, fk_soc, ref_fourn, fk_user_author )" - . " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, ref_fourn, fk_user_author" - . " FROM ".MAIN_DB_PREFIX."product_fournisseur" - . " WHERE fk_product = ".((int) $fromId); + . " datec, fk_product, fk_soc, ref_fourn, fk_user_author )" + . " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, ref_fourn, fk_user_author" + . " FROM ".MAIN_DB_PREFIX."product_fournisseur" + . " WHERE fk_product = ".((int) $fromId); - if ( ! $this->db->query($sql ) ) - { - $this->db->rollback(); - return -1; - }*/ + if ( ! $this->db->query($sql ) ) + { + $this->db->rollback(); + return -1; + }*/ // les prix de fournisseurs. $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price ("; @@ -4468,7 +4488,7 @@ class Product extends CommonObject // Recursive call if there is childs to child if (is_array($desc_pere['childs'])) { - //print 'YYY We go down for '.$desc_pere[3]." -> \n"; + //print 'YYY We go down for '.$desc_pere[3]." -> \n"; $this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", $desc_pere[1] * $multiply, $level + 1, $id, $ignore_stock_load); } } @@ -4665,17 +4685,17 @@ class Product extends CommonObject } $alreadyfound[$rec['rowid']] = 1; $prods[$rec['rowid']] = array( - 0=>$rec['rowid'], - 1=>$rec['qty'], - 2=>$rec['fk_product_type'], - 3=>$this->db->escape($rec['label']), - 4=>$rec['incdec'], - 5=>$rec['ref'] + 0=>$rec['rowid'], + 1=>$rec['qty'], + 2=>$rec['fk_product_type'], + 3=>$this->db->escape($rec['label']), + 4=>$rec['incdec'], + 5=>$rec['ref'] ); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); if (empty($firstlevelonly)) { - $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1); + $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1); foreach ($listofchilds as $keyChild => $valueChild) { $prods[$rec['rowid']]['childs'][$keyChild] = $valueChild; } @@ -5172,6 +5192,8 @@ class Product extends CommonObject $sql .= " AND w.statut IN (".$this->db->sanitize(implode(',', $warehouseStatus)).")"; } + $sql .= " ORDER BY ps.reel ".(!empty($conf->global->DO_NOT_TRY_TO_DEFRAGMENT_STOCKS_WAREHOUSE)?'DESC':'ASC'); // Note : qty ASC is important for expedition card, to avoid stock fragmentation; + dol_syslog(get_class($this)."::load_stock", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -5804,8 +5826,8 @@ class Product extends CommonObject public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) { $tables = array( - 'product_customer_price', - 'product_customer_price_log' + 'product_customer_price', + 'product_customer_price_log' ); return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 529284af464..f10adee334e 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -436,7 +436,7 @@ class Productbatch extends CommonObject */ public static function findAll($db, $fk_product_stock, $with_qty = 0, $fk_product = 0) { - global $langs; + global $langs, $conf; $ret = array(); $sql = "SELECT"; @@ -462,6 +462,12 @@ class Productbatch extends CommonObject $sql .= " AND t.qty <> 0"; } + $sql .= " ORDER BY "; + // TODO : use product lifo and fifo when product will implement it + if ($fk_product > 0) { $sql .= "pl.eatby ASC, pl.sellby ASC, "; } + $sql .= "t.eatby ASC, t.sellby ASC "; + $sql .= ", t.qty ".(!empty($conf->global->DO_NOT_TRY_TO_DEFRAGMENT_STOCKS_WAREHOUSE)?'DESC':'ASC'); // Note : qty ASC is important for expedition card, to avoid stock fragmentation + dol_syslog("productbatch::findAll", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/product/note.php b/htdocs/product/note.php index fad4df3500b..b758f414035 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -76,23 +76,23 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, $form = new Form($db); -$helpurl = ''; +$help_url = ''; if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } $title = $langs->trans('ProductServiceCard'); $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Notes'); - $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Notes'); - $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $help_url); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 5df8e3a7a5f..824d667e934 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -394,6 +394,11 @@ if (!empty($conf->variants->eabled) && empty($conf->global->VARIANT_ALLOW_STOCK_ if ($fk_supplier > 0) { $sql .= ' AND EXISTS (SELECT pfp.rowid FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid AND pfp.fk_soc = '.((int) $fk_supplier).' AND pfp.entity IN ('.getEntity('product_fournisseur_price').'))'; } +// Add where from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price'; $sql .= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms'; $sql .= ', p.duration, p.tobuy'; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index e381aaabfb3..ce2db90fa5d 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -253,6 +253,7 @@ class Project extends CommonObject 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>210), 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModification', 'enabled'=>1, 'visible'=>0, 'position'=>215), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>0, 'position'=>220), + 'email_msgid'=>array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'enabled'=>1, 'visible'=>-1, 'position'=>250, 'help'=>'EmailMsgIDWhenSourceisEmail'), 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500) ); // END MODULEBUILDER PROPERTIES @@ -583,7 +584,8 @@ class Project extends CommonObject { global $conf; - if (empty($id) && empty($ref)) { + if (empty($id) && empty($ref) && empty($ref_ext) && empty($email_msgid)) { + dol_syslog(get_class($this)."::fetch Bad parameters", LOG_WARNING); return -1; } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index c95ae10e79a..cd532ecd048 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -25,7 +25,7 @@ /** * \file htdocs/projet/list.php - * \ingroup projet + * \ingroup project * \brief Page to list projects */ @@ -333,6 +333,7 @@ $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat,"; $sql .= " p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount,"; $sql .= " p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event,"; +$sql .= " p.email_msgid,"; $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth,"; $sql .= " s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,"; $sql .= " country.code as country_code,"; @@ -861,6 +862,11 @@ if (!empty($arrayfields['p.tms']['checked'])) { print ''; print ''; } +if (!empty($arrayfields['p.email_msgid']['checked'])) { + // Email msg id + print ''; + print ''; +} if (!empty($arrayfields['p.fk_statut']['checked'])) { print ''; $arrayofstatus = array(); @@ -953,6 +959,9 @@ if (!empty($arrayfields['p.datec']['checked'])) { if (!empty($arrayfields['p.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } +if (!empty($arrayfields['p.email_msgid']['checked'])) { + print_liste_field_titre($arrayfields['p.email_msgid']['label'], $_SERVER["PHP_SELF"], "p.email_msgid", "", $param, '', $sortfield, $sortorder, 'center '); +} if (!empty($arrayfields['p.fk_statut']['checked'])) { print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); } @@ -1294,6 +1303,13 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Email MsgID + if (!empty($arrayfields['p.email_msgid']['checked'])) { + print ''; + print $obj->email_msgid; + print ''; + if (!$i) $totalarray['nbfield']++; + } // Status if (!empty($arrayfields['p.fk_statut']['checked'])) { print ''.$object->getLibStatut(5).''; diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 96dd77bce74..19bb2007bda 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -164,6 +164,13 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ } print '
'; } + + if (!empty($conf->global->EVENTORGANIZATION_IMAGE_PUBLIC_INTERFACE)) { + print '
'; + print ''; + print '
'; + } + print ''; print '
'; diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index b45e98b832a..4a81084223d 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -153,6 +153,11 @@ if ($urllogo) { print '
'; } +if (!empty($conf->global->EVENTORGANIZATION_IMAGE_PUBLIC_INTERFACE)) { + print '
'; + print ''; + print '
'; +} print '


'; diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 71446b58779..f9cd88a8c38 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -130,18 +130,25 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ } print '
'; + // Output html code for logo if ($urllogo) { print '
'; print '
'; - print ''; + print ''; print '
'; if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { print ''; } print '
'; } + + if (!empty($conf->global->MEMBER_IMAGE_PUBLIC_REGISTRATION)) { + print '
'; + print ''; + print '
'; + } + print '
'; print '
'; diff --git a/htdocs/public/notice.php b/htdocs/public/notice.php index f85c628e1eb..c41bf81bea4 100644 --- a/htdocs/public/notice.php +++ b/htdocs/public/notice.php @@ -18,7 +18,7 @@ /** * \file htdocs/public/notice.php * \brief Dolibarr page to show a notice. - * Default notice is a message to say network connection is off. + * Default notice is a message to say network connection is off or show another message. * You can also call this page with URL: * /public/notice.php?lang=xx_XX&transkey=translation_key (key must be inside file main.lang, error.lang or other.lang) * /public/notice.php?transphrase=url_encoded_sentence_to_show diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index a4a2de27beb..d034db38be3 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -195,6 +195,11 @@ if ($urllogo) { } print '
'; } +if (!empty($conf->global->PROPOSAL_IMAGE_PUBLIC_SIGN)) { + print '
'; + print ''; + print '
'; +} // Output introduction text $text = ''; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index fb95432256d..aeed346ab87 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -865,6 +865,11 @@ if ($urllogo) { } print ''; } +if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) { + print '
'; + print ''; + print '
'; +} diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 6b4b28f66fe..6894e6a18c8 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -266,6 +266,11 @@ if ($urllogo) { } print ''; } +if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) { + print '
'; + print ''; + print '
'; +} print '

'; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 50a2de7bc68..1fbf420888d 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -226,6 +226,11 @@ if ($urllogo) { } print ''; } +if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) { + print '
'; + print ''; + print '
'; +} print '


'; diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index d3dca7def6f..70e546cdbd9 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -186,6 +186,12 @@ if ($urllogo) { print ''; } +if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) { + print '
'; + print ''; + print '
'; +} + print ''."\n"; $text = ''."\n"; diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 240b3d8f036..ca7101a3679 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -118,6 +118,7 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ } print '
'; + // Output html code for logo if ($urllogo) { print '
'; @@ -130,6 +131,13 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ } print '
'; } + + if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) { + print '
'; + print ''; + print '
'; + } + print '
'; print '
'; diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index f5ef237a9bd..6329441778f 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -152,6 +152,7 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ } print '
'; + // Output html code for logo if ($urllogo) { print '
'; @@ -164,6 +165,13 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ } print '
'; } + + if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH)) { + print '
'; + print ''; + print '
'; + } + print '
'; print '
'; diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php index 4ef1784e2a7..00b093ba215 100644 --- a/htdocs/public/project/suggestconference.php +++ b/htdocs/public/project/suggestconference.php @@ -152,6 +152,7 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ } print '
'; + // Output html code for logo if ($urllogo) { print '
'; @@ -164,6 +165,13 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ } print '
'; } + + if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_SUGGEST_CONFERENCE)) { + print '
'; + print ''; + print '
'; + } + print '
'; print '
'; diff --git a/htdocs/public/project/viewandvote.php b/htdocs/public/project/viewandvote.php index 64307018c38..e78176a5f56 100644 --- a/htdocs/public/project/viewandvote.php +++ b/htdocs/public/project/viewandvote.php @@ -261,6 +261,13 @@ if ($urllogo) { } print '
'; } + +if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_SUGGEST_BOOTH)) { + print '
'; + print ''; + print '
'; +} + print '

'.$langs->trans("EvntOrgRegistrationWelcomeMessage").'
'."\n"; $text = ''."\n"; $text .= ''."\n"; diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index cf7e8f8bc24..f3d84ec996f 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -56,7 +56,7 @@ $email = GETPOST('email', 'alpha'); $object = new RecruitmentJobPosition($db); // Security check -if (empty($conf->recruitement->enabled)) { +if (empty($conf->recruitment->enabled)) { accessforbidden('', 0, 0, 1); } diff --git a/htdocs/public/recruitment/view.php b/htdocs/public/recruitment/view.php index 2fe6a9af21e..cd275d250c4 100644 --- a/htdocs/public/recruitment/view.php +++ b/htdocs/public/recruitment/view.php @@ -39,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class. require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "other", "recruitment")); @@ -75,7 +76,7 @@ if (!$action) { $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. // Security check -if (empty($conf->recruitement->enabled)) { +if (empty($conf->recruitment->enabled)) { accessforbidden('', 0, 0, 1); } @@ -189,7 +190,7 @@ print ''."\n"; print ''; print "\n"; -print ''."\n"; +print ''."\n"; print '

'.$langs->trans("EvntOrgRegistrationWelcomeMessage").'
'.$langs->trans("EvntOrgVoteHelpMessage").' : "'.$project->title.'".

'."\n"; @@ -227,6 +228,12 @@ if ($urllogo) { print ''; } +if (!empty($conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE)) { + print '
'; + print ''; + print '
'; +} + // Output introduction text $text = ''; if (!empty($conf->global->RECRUITMENT_NEWFORM_TEXT)) { diff --git a/htdocs/recruitment/admin/candidature_extrafields.php b/htdocs/recruitment/admin/candidature_extrafields.php index 1f0ac538d0b..efb68e5ff2c 100644 --- a/htdocs/recruitment/admin/candidature_extrafields.php +++ b/htdocs/recruitment/admin/candidature_extrafields.php @@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array('recruitement', 'admin')); +$langs->loadLangs(array('recruitment', 'admin')); $extrafields = new ExtraFields($db); $form = new Form($db); diff --git a/htdocs/recruitment/admin/jobposition_extrafields.php b/htdocs/recruitment/admin/jobposition_extrafields.php index 3b17322d5eb..d1b0651da64 100644 --- a/htdocs/recruitment/admin/jobposition_extrafields.php +++ b/htdocs/recruitment/admin/jobposition_extrafields.php @@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/recruitment/lib/recruitment.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array('recruitement', 'admin')); +$langs->loadLangs(array('recruitment', 'admin')); $extrafields = new ExtraFields($db); $form = new Form($db); diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index 47867e40c5f..06b24ec8b65 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -3,7 +3,7 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2018-2019 Philippe Grand + * Copyright (C) 2018-2021 Philippe Grand * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -85,18 +85,18 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $this->marge_haute = 0; $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_logo = 1; // Display logo + $this->option_tva = 0; // Manage the vat option COMMANDE_TVAOPTION + $this->option_modereg = 0; // Display payment mode + $this->option_condreg = 0; // Display payment terms + $this->option_codeproduitservice = 0; // Display product-service code + $this->option_multilang = 1; // Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts - // Recupere emetteur + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index d0edd54f946..c87289da390 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -675,7 +675,7 @@ foreach ($profid as $key => $val) { print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } else { - print ''; } diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index d2ad361034f..1bf43864cdd 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -6,6 +6,7 @@ * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015 Marcos García + * Copyright (C) 2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -129,8 +130,8 @@ if ($socid) { print dol_get_fiche_end(); $params = ''; - - $newcardbutton .= dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopage='.urlencode($backtopage), '', 1, $params); + $backtopage = $_SERVER['PHP_SELF'].'?socid='.$object->id; + $newcardbutton = dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopage='.urlencode($backtopage), '', 1, $params); print '
'; diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 0aa45028ddd..508d6e670b3 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -154,10 +154,10 @@ function updateplace(idplace, left, top) { console.log("updateplace idplace="+idplace+" left="+left+" top="+top); $.ajax({ type: "POST", - url: "floors.php", - data: { action: "update", left: left, top: top, place: idplace } - }).done(function( msg ) { - window.location.href='floors.php?mode=edit&floor='; + url: "", + data: { action: "update", left: left, top: top, place: idplace, token: '' } + }).done(function( msg ) { + window.location.href='floors.php?mode=edit&floor='; }); } @@ -166,12 +166,12 @@ function updatename(rowid) { console.log("updatename rowid="+rowid+" after="+after); $.ajax({ type: "POST", - url: "floors.php", - data: { action: "updatename", place: rowid, newname: after } - }).done(function( msg ) { - window.location.href='floors.php?mode=edit&floor='; - }); - } + url: "", + data: { action: "updatename", place: rowid, newname: after, token: '' } + }).done(function( msg ) { + window.location.href='floors.php?mode=edit&floor='; + }); +} function LoadPlace(place){ parent.location.href='index.php?place='+place; diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index d51fd21279e..b182f37f787 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -705,6 +705,7 @@ function OpenDrawer(){ console.log("OpenDrawer call ajax url http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print"); $.ajax({ type: "POST", + data: { token: 'notrequired' }, global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { echo "url: '".$conf->global->TAKEPOS_PRINT_SERVER."/printer/drawer.php',"; @@ -717,10 +718,11 @@ function OpenDrawer(){ } function DolibarrOpenDrawer() { - console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&term="); + console.log("DolibarrOpenDrawer call ajax url /takepos/ajax/ajax.php?action=opendrawer&term="); $.ajax({ type: "GET", - url: "", + data: { token: '' }, + url: "", }); } @@ -777,6 +779,7 @@ function WeighingScale(){ console.log("Weighing Scale"); $.ajax({ type: "POST", + data: { token: 'notrequired' }, url: 'global->TAKEPOS_PRINT_SERVER; ?>/scale/index.php', }) .done(function( editnumber ) { diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 60276c545ca..3f7e63d84cb 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1000,7 +1000,7 @@ function TakeposPrinting(id){ function TakeposConnector(id){ console.log("TakeposConnector" + id); - $.get("ajax/ajax.php?action=printinvoiceticket&term=&id="+id, function(data, status){ + $.get("/takepos/ajax/ajax.php?action=printinvoiceticket&term=&id="+id+"&token=", function(data, status) { $.ajax({ type: "POST", url: 'global->TAKEPOS_PRINT_SERVER; ?>/printer/index.php', @@ -1013,7 +1013,8 @@ function DolibarrTakeposPrinting(id) { console.log("DolibarrTakeposPrinting Printing invoice ticket " + id) $.ajax({ type: "GET", - url: "" + id, + data: { token: '' }, + url: "" + id, }); } diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index d4b6c023186..ba8ac8f82f7 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -236,7 +236,10 @@ if ($conf->global->TAKEPOS_NUMPAD == 0) { window.open('sumupmerchant://pay/1.0?affiliate-key=global->TAKEPOS_SUMUP_AFFILIATE ?>&app-id=global->TAKEPOS_SUMUP_APPID ?>&total=' + amountpayed + '¤cy=EUR&title=' + invoiceid + '&callback=/takepos/smpcb.php'); var loop = window.setInterval(function () { - $.ajax('/takepos/smpcb.php?status').done(function (data) { + $.ajax({ + method: 'POST', + data: { token: '' }, + url: '/takepos/smpcb.php?status' }).done(function (data) { console.log(data); if (data === "SUCCESS") { parent.$("#poslines").load("invoice.php?place=&action=valid&pay=CB&amount=" + amountpayed + "&invoiceid=" + invoiceid, function () { diff --git a/htdocs/takepos/send.php b/htdocs/takepos/send.php index 9f98d5fbd7d..af606a65209 100644 --- a/htdocs/takepos/send.php +++ b/htdocs/takepos/send.php @@ -97,7 +97,8 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); function SendMail() { $.ajax({ type: "GET", - url: "" + $("#email"). val(), + data: { token: '' }, + url: "" + $("#email"). val(), }); parent.$.colorbox.close(); } diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index e0976e0e1db..cfd5415a90c 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -392,7 +392,7 @@ a.top-menu-dropdown-link { background-repeat: no-repeat; background-size: 16px 16px; background-position: 95% center; - border-radius: 10px; + border-radius: 20px; border: 1px solid #c4c4c2 !important; transition: all 250ms ease-in-out; backface-visibility: hidden; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 70e5229ba28..d223a70fbc9 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1481,6 +1481,10 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select display: inline-block; } + input.maxwidthinputfileonsmartphone { + width: 175px; + } + .logopublicpayment #dolpaymentlogo { max-width: 260px; } @@ -1648,7 +1652,7 @@ table.tableforfield tr>td:first-of-type, tr.trforfield>td:first-of-type, div.tab } -.hideonprint { display: none; } +.hideonprint { display: none !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 7dd19673b5e..5027c1501e9 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1511,6 +1511,10 @@ table[summary="list_of_modules"] .fa-cog { display: inline-block; } + input.maxwidthinputfileonsmartphone { + width: 175px; + } + .poweredbyimg { width: 48px; } @@ -1664,7 +1668,7 @@ table.tableforfield tr>td:first-of-type, tr.trforfield>td:first-of-type, div.tab } -.hideonprint { display: none; } +.hideonprint { display: none !important; } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index f2edf617ff5..1831a4078c5 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1329,10 +1329,14 @@ if ($action == 'create' || $action == 'presend') { $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); - } - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) { + } elseif ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) { $newlang = $object->thirdparty->default_lang; } + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $arrayoffamiliestoexclude = array('objectamount'); $action = 'add_message'; // action to use to post the message @@ -1341,7 +1345,7 @@ if ($action == 'create' || $action == 'presend') { // Substitution array $morehtmlright = ''; $help = ""; - $substitutionarray = getCommonSubstitutionArray($newlang, 0, $arrayoffamiliestoexclude, $object); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object); if ($object->fk_soc > 0) { $substitutionarray['__THIRDPARTY_NAME__'] = $object->thirdparty->name; } diff --git a/htdocs/ticket/class/cticketcategory.class.php b/htdocs/ticket/class/cticketcategory.class.php new file mode 100644 index 00000000000..4e3e6311354 --- /dev/null +++ b/htdocs/ticket/class/cticketcategory.class.php @@ -0,0 +1,819 @@ + + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/modulebuilder/template/class/myobject.class.php + * \ingroup mymodule + * \brief This file is a CRUD class file for MyObject (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class for MyObject + */ +class CTicketCategory extends CommonObject +{ + /** + * @var string ID of module. + */ + public $module = 'ticket'; + + /** + * @var string ID to identify managed object. + */ + public $element = 'cticketcategory'; + + /** + * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. + */ + public $table_element = 'c_ticket_category'; + + /** + * @var int Does this object support multicompany module ? + * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 0; + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'ticket'; + + + const STATUS_DISABLED = 0; + const STATUS_ENABLED = 1; + + + /** + * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'picto' is code of a picto to show before value in forms + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200' + * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar' + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'position'=>15, 'index'=>1), + 'code' =>array('type'=>'varchar(32)', 'label'=>'Code', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), + 'pos' =>array('type'=>'integer', 'label'=>'Pos', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), + 'label' =>array('type'=>'varchar(128)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>30, 'showoncombobox'=>1), + 'active' =>array('type'=>'integer', 'label'=>'Active', 'enabled'=>1, 'visible'=>-1, 'position'=>35), + 'use_default' =>array('type'=>'integer', 'label'=>'Usedefault', 'enabled'=>1, 'visible'=>-1, 'position'=>40), + 'description' =>array('type'=>'varchar(255)', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>45), + 'fk_parent' =>array('type'=>'integer', 'label'=>'Fkparent', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>50), + 'force_severity' =>array('type'=>'varchar(32)', 'label'=>'Forceseverity', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'public' =>array('type'=>'integer', 'label'=>'Public', 'enabled'=>1, 'visible'=>-1, 'position'=>60), + ); + + /** + * @var int ID + */ + public $rowid; + + /** + * @var string Ref + */ + public $ref; + + /** + * @var int Entity + */ + public $entity; + + /** + * @var string label + */ + public $label; + + /** + * @var string amount + */ + public $amount; + + /** + * @var int Status + */ + public $status; + + /** + * @var integer|string date_creation + */ + public $date_creation; + + /** + * @var integer tms + */ + public $tms; + + /** + * @var int ID + */ + public $fk_user_creat; + + /** + * @var int ID + */ + public $fk_user_modif; + + /** + * @var string public $last_main_doc + */ + public $last_main_doc; + + /** + * @var string import_key + */ + public $import_key; + // END MODULEBUILDER PROPERTIES + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + $this->fields['entity']['enabled'] = 0; + } + + // Example to show how to set values of fields definition dynamically + /*if ($user->rights->mymodule->myobject->read) { + $this->fields['myfield']['visible'] = 1; + $this->fields['myfield']['noteditable'] = 0; + }*/ + + // Unset fields that are disabled + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); + } + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + $resultcreate = $this->createCommon($user, $notrigger); + + //$resultvalidate = $this->validate($user, $notrigger); + + return $resultcreate; + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $result = $object->fetchCommon($fromid); + if ($result > 0 && !empty($object->table_element_line)) { + $object->fetchLines(); + } + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + if (property_exists($object, 'ref')) { + $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; + } + if (property_exists($object, 'label')) { + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + } + if (property_exists($object, 'status')) { + $object->status = self::STATUS_DRAFT; + } + if (property_exists($object, 'date_creation')) { + $object->date_creation = dol_now(); + } + if (property_exists($object, 'date_modification')) { + $object->date_modification = null; + } + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) { + $extrafields->fetch_name_optionals_label($this->table_element); + foreach ($object->array_options as $key => $option) { + $shortkey = preg_replace('/options_/', '', $key); + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + if (!$error) { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) { + $error++; + } + } + + if (!$error) { + // copy external contacts if same company + if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) { + $error++; + } + } + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchLines() + { + $this->lines = array(); + + $result = $this->fetchLinesCommon(); + return $result; + } + + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList('t'); + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + } else { + $sql .= ' WHERE 1 = 1'; + } + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key.' IN ('.$this->db->sanitize($this->db->escape($value)).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Delete a line of object in database + * + * @param User $user User that delete + * @param int $idline Id of line to delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int >0 if OK, <0 if KO + */ + public function deleteLine(User $user, $idline, $notrigger = false) + { + if ($this->status < 0) { + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; + return -2; + } + + return $this->deleteLineCommon($user, $idline, $notrigger); + } + + + /** + * Validate object + * + * @param User $user User making status change + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <=0 if OK, 0=Nothing done, >0 if KO + */ + public function validate($user, $notrigger = 0) + { + global $conf, $langs; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $error = 0; + + // Protection + if ($this->status == self::STATUS_VALIDATED) { + dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->myobject->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->myobject->myobject_advance->validate)))) + { + $this->error='NotEnoughPermissions'; + dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); + return -1; + }*/ + + $now = dol_now(); + + $this->db->begin(); + + // Define new ref + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life + $num = $this->getNextNumRef(); + } else { + $num = $this->ref; + } + $this->newref = $num; + + if (!empty($num)) { + // Validate + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED; + if (!empty($this->fields['date_validation'])) { + $sql .= ", date_validation = '".$this->db->idate($now)."'"; + } + if (!empty($this->fields['fk_user_valid'])) { + $sql .= ", fk_user_valid = ".((int) $user->id); + } + $sql .= " WHERE rowid = ".((int) $this->id); + + dol_syslog(get_class($this)."::validate()", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + $error++; + } + + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('MYOBJECT_VALIDATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + } + + if (!$error) { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { + // Now we rename also files into index + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'myobject/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'myobject/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->error = $this->db->lasterror(); + } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->mymodule->dir_output.'/myobject/'.$oldref; + $dirdest = $conf->mymodule->dir_output.'/myobject/'.$newref; + if (!$error && file_exists($dirsource)) { + dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->mymodule->dir_output.'/myobject/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + // Set new ref and current status + if (!$error) { + $this->ref = $num; + $this->status = self::STATUS_VALIDATED; + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_DISABLED, $notrigger, 'CTICKETCATEGORY_CANCEL'); + } + + /** + * 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 $conf, $langs, $hookmanager; + + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } + + $result = ''; + + /*$label = img_picto('', $this->picto).' '.$langs->trans("MyObject").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; + */ + $label = ''; + + //$url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id; + $url = ''; + + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } + } + + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } + + if ($option == 'nolink') { + $linkstart = ''; + if ($option == 'nolink') { + $linkend = ''; + } else { + $linkend = ''; + } + + //$result .= $linkstart; + $result .= $this->label; + //$result .= $linkend; + + global $action, $hookmanager; + $hookmanager->initHooks(array('cticketcategorydao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } + + return $result; + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("mymodule@mymodule"); + $this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled'); + $this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Disabled'); + $this->labelStatusShort[self::STATUS_ENABLED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_DISABLED] = $langs->trans('Disabled'); + } + + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_DISABLED) { + $statusType = 'status6'; + } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.((int) $id); + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } +} diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 31f1b0b243a..42b04640def 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -531,7 +531,7 @@ class Ticket extends CommonObject global $langs; // Check parameters - if (!$id && !$track_id && !$ref && !$email_msgid) { + if (empty($id) && empty($ref) && empty($track_id) && empty($email_msgid)) { $this->error = 'ErrorWrongParameters'; dol_print_error(get_class($this)."::fetch ".$this->error); return -1; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index fcd6baa2c05..135e2072fdf 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -87,6 +87,8 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write); } +$childids = $user->getAllChildIds(1); // For later, test on salary visibility + // Define value to know what current user can do on properties of edited user if ($id) { // $user is the current logged user, $id is the user we want to edit @@ -137,7 +139,7 @@ if ($reshook < 0) { if (empty($reshook)) { if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) { - if ($id <> $user->id) { // A user can't disable itself + if ($id != $user->id) { // A user can't disable itself $object->fetch($id); if ($object->admin && empty($user->admin)) { // If user to delete is an admin user and if logged user is not admin, we deny the operation. @@ -150,10 +152,11 @@ if (empty($reshook)) { } } } + if ($action == 'confirm_enable' && $confirm == "yes" && $candisableuser) { $error = 0; - if ($id <> $user->id) { + if ($id != $user->id) { $object->fetch($id); if (!empty($conf->file->main_limit_users)) { @@ -173,7 +176,7 @@ if (empty($reshook)) { } if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser) { - if ($id <> $user->id) { + if ($id != $user->id) { if (!GETPOSTISSET('token')) { print 'Error, token required for this critical operation'; exit; @@ -1201,7 +1204,8 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print '
'; - if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read) && in_array($id, $childids)) + || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->readall)) || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); @@ -1499,9 +1503,8 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''."\n"; - //$childids = $user->getAllChildIds(1); - - if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read) && in_array($id, $childids)) + || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->readall)) || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { // Even a superior can't see this info of its subordinates wihtout $user->rights->salaries->read and $user->rights->hrm->employee->read (setting/viewing is reserverd to HR people). // However, he can see the valuation of timesheet of its subordinates even without these permissions. @@ -1776,17 +1779,14 @@ if ($action == 'create' || $action == 'adduserldap') { print ''."\n"; // API key - if (!empty($conf->api->enabled) && $user->admin) { + if (!empty($conf->api->enabled) && ($user->id == $id || $user->admin)) { print ''; print ''; } @@ -2158,7 +2158,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; print ''; print '\n"; // API key - if (!empty($conf->api->enabled) && $user->admin) { + if (!empty($conf->api->enabled) && ($user->id == $id || $user->admin)) { print ''; print '".''; print '".''; print '".''; print '".'global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.$langs->trans("EMail").''; print ''; print ''; print ''; print ''; print ''; } @@ -2624,14 +2624,15 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; - if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read) && in_array($id, $childids)) + || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->readall)) || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); diff --git a/htdocs/user/document.php b/htdocs/user/document.php index 8cf6c2b2a81..a5d88d04c5d 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -60,6 +60,9 @@ if ($id) { || (($user->id != $id) && $user->rights->user->user->password)); } +$permissiontoadd = $caneditfield; +$permtoedit = $caneditfield; + // Security check $socid = 0; if ($user->socid > 0) { @@ -174,10 +177,7 @@ if ($object->id) { print dol_get_fiche_end(); - $modulepart = 'user'; - $permissiontoadd = $user->rights->user->user->creer; - $permtoedit = $user->rights->user->user->creer; $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 5c8185069c9..a3b69d1dff8 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -681,10 +681,10 @@ if (!empty($arrayfields['u.accountancy_code']['checked'])) { print ''; } if (!empty($arrayfields['u.office_phone']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['u.user_mobile']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['u.email']['checked'])) { print ''; @@ -851,8 +851,20 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $li = $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); + $canreadhrmdata = 0; + if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read) && in_array($obj->rowid, $childids)) + || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->readall)) + || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) { + $canreadhrmdata = 1; + } + $canreadsecretapi = 0; + if ($user->id = $obj->rowid || !empty($user->admin)) { // Current user or admin + $canreadsecretapi = 1; + } + print ''; + // Login if (!empty($arrayfields['u.login']['checked'])) { print ''; if (!$i) { @@ -951,14 +964,22 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } } if (!empty($arrayfields['u.api_key']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['u.fk_soc']['checked'])) { print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 469823f0358..978c2d990b7 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -72,7 +72,7 @@ $permissiontoadd = (($object->id == $user->id) || (!empty($user->rights->user->u if ($user->socid) { $id = $user->socid; } -$result = restrictedArea($user, 'user', '', ''); +$result = restrictedArea($user, 'user', '', '', 'user'); /* diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index cb0a093867d..2136d0f07c5 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -293,10 +293,10 @@ if ($user->admin) { print ''."\n"; //print "xx".$conf->global->MAIN_USE_ADVANCED_PERMS; -$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position"; +$sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" -$sql .= " AND r.entity = ".$entity; +$sql .= " AND r.entity = ".((int) $entity); if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled } @@ -342,10 +342,12 @@ if ($result) { } } + // Break found, it's a new module to catch if (isset($obj->module) && ($oldmod <> $obj->module)) { $oldmod = $obj->module; // Break detected, we get objMod + $objMod = $modules[$obj->module]; $picto = ($objMod->picto ? $objMod->picto : 'generic'); // Show break line @@ -436,9 +438,9 @@ if ($result) { print ''; } - // Descrption of permission + // Description of permission $permlabel = (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $langs->trans($obj->label))); - print '
'; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print '
'.dol_escape_htmltag($object->job).'
'.$langs->trans("ApiKey").''; if (!empty($object->api_key)) { print ''; - print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); + print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste print ''; } - if ($user->admin || $user->id == $object->id) { - // TODO Add a feature to reveal the hash - } print '
'.$langs->trans("HierarchicalResponsible").''; if ($caneditfield) { - print img_picto('', 'user').$form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300'); + print img_picto('', 'user').$form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); } else { print ''; $huser = new User($db); @@ -2176,7 +2176,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; if ($caneditfield) { - print img_picto('', 'user').$form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300'); + print img_picto('', 'user').$form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); } else { print ''; $evuser = new User($db); @@ -2195,7 +2195,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; if ($caneditfield) { - print img_picto('', 'user').$form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300'); + print img_picto('', 'user').$form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); } else { print ''; $hvuser = new User($db); @@ -2302,7 +2302,7 @@ if ($action == 'create' || $action == 'adduserldap') { print "
'.$langs->trans("ApiKey").''; print ''; @@ -2373,7 +2373,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Tel pro print "
'.$langs->trans("PhonePro").''; - print img_picto('', 'object_phoning'); + print img_picto('', 'phoning', 'class="pictofixedwidth"'); if ($caneditfield && empty($object->ldap_sid)) { print ''; } else { @@ -2385,7 +2385,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Tel mobile print "
'.$langs->trans("PhoneMobile").''; - print img_picto('', 'object_phoning_mobile'); + print img_picto('', 'phoning_mobile', 'class="pictofixedwidth"'); if ($caneditfield && empty($object->ldap_sid)) { print ''; } else { @@ -2397,7 +2397,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Fax print "
'.$langs->trans("Fax").''; - print img_picto('', 'object_phoning_fax'); + print img_picto('', 'phoning_fax', 'class="pictofixedwidth"'); if ($caneditfield && empty($object->ldap_sid)) { print ''; } else { @@ -2409,7 +2409,7 @@ if ($action == 'create' || $action == 'adduserldap') { // EMail print "
'; - print img_picto('', 'object_email'); + print img_picto('', 'object_email', 'class="pictofixedwidth"'); if ($caneditfield && empty($object->ldap_sid)) { print ''; } else { @@ -2424,10 +2424,10 @@ if ($action == 'create' || $action == 'adduserldap') { print '
'.$langs->trans($value['label']).''; if (!empty($value['icon'])) { - print ''; + print ''; } if ($caneditfield && empty($object->ldap_sid)) { - print ''; + print ''; } else { print ''; print $object->socialnetworks[$key]; @@ -2461,7 +2461,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''.$langs->trans("AccountancyCode").''; if ($caneditfield) { - print ''; + print ''; } else { print ''; print $object->accountancy_code; @@ -2494,7 +2494,7 @@ if ($action == 'create' || $action == 'adduserldap') { if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { print '
'.$form->editfieldkey('Categories', 'usercats', '', $object, 0).''; - print img_picto('', 'category'); + print img_picto('', 'category', 'class="pictofixedwidth"'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_USER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_USER); @@ -2512,7 +2512,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Default language if (!empty($conf->global->MAIN_MULTILANGS)) { print '
'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0, 'string', '', 0, 0, 'id', $langs->trans("WarningNotLangOfInterface", $langs->transnoentitiesnoconv("UserGUISetup"))).''."\n"; - print img_picto('', 'language').$formadmin->select_language($object->lang, 'default_lang', 0, 0, 1); + print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language($object->lang, 'default_lang', 0, null, '1', 0, 0, 'widthcentpercentminusx maxwidth300'); print '
'.$langs->trans("PostOrFunction").''; if ($caneditfield) { - print ''; + print ''; } else { print ''; print dol_escape_htmltag($object->job); } print '
'; print $li; @@ -888,6 +900,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $totalarray['nbfield']++; } } + // Employee yes/no if (!empty($arrayfields['u.employee']['checked'])) { print ''.yn($obj->employee).''.$obj->api_key.''; + if ($obj->api_key) { + if ($canreadsecretapi) { + print $obj->api_key; + } else { + print ''.$langs->trans("Hidden").''; + } + } + print ''; - if ($obj->fk_soc) { + if ($obj->fk_soc > 0) { $companystatic->id = $obj->fk_soc; $companystatic->name = $obj->name; $companystatic->canvas = $obj->canvas; @@ -992,7 +1013,15 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Salary if (!empty($arrayfields['u.salary']['checked'])) { - print ''.($obj->salary ? price($obj->salary) : '').''; + if ($obj->salary) { + if ($canreadhrmdata) { + print price($obj->salary); + } else { + print ''.$langs->trans("Hidden").''; + } + } + print '
 '; + print ''; print $permlabel; if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { if (preg_match('/_advance$/', $obj->perms)) { diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index 37d86dcded9..3a1a627863a 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -626,6 +626,7 @@ function updateContact($authentication, $contact) if (!empty($object->id)) { $objectfound = true; + $object->ref_ext = $contact['ref_ext']; $object->firstname = $contact['firstname']; $object->lastname = $contact['lastname']; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 9361aae865f..aa2b357a794 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -403,8 +403,10 @@ if ($sortfield) { if ($sortorder) { $backtopage .= '&sortorder='.urlencode($sortorder); } -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; +include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; // This manage 'sendit' action when submitting new file. + $backtopage = $savbacktopage; +//var_dump($backtopage); var_dump($action); if ($action == 'renamefile') { // Must be after include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; If action were renamefile, we set it to 'file_manager' $action = 'file_manager'; @@ -2504,7 +2506,8 @@ $moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("WebsiteSetup"), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss, '', '', ''."\n".'
'); print "\n"; -print ''; +print ''."\n"; +print ''; print ''; print ''; @@ -2647,7 +2650,7 @@ if (!GETPOST('hide_websitemenu')) { $out .= ' jQuery("#website").change(function () {'; $out .= ' console.log("We select "+jQuery("#website option:selected").val());'; $out .= ' if (jQuery("#website option:selected").val() == \'-2\') {'; - $out .= ' window.location.href = "'.$urltocreatenewwebsite.'";'; + $out .= ' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).'";'; $out .= ' } else {'; $out .= ' window.location.href = "'.$_SERVER["PHP_SEFL"].'?website="+jQuery("#website option:selected").val();'; $out .= ' }'; @@ -4039,7 +4042,9 @@ if ($action == 'editfile' || $action == 'file_manager' || $action == 'convertimg print '

'; //print '
'.$langs->trans("FeatureNotYetAvailable").''; + $module = 'medias'; + $formalreadyopen = 2; // So the form to submit a new file will not be opened another time inside the core/tpl/filemanager.tpl.php if (empty($url)) { $url = DOL_URL_ROOT.'/website/index.php'; // Must be an url without param } diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 7ff09de495e..7c6cda9f997 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -528,4 +528,26 @@ class DateLibTest extends PHPUnit\Framework\TestCase return 1; } + + /** + * testDolSqlDateFilter + * + * @return int + */ + public function testDolSqlDateFilter() + { + global $conf; + + $result = dolSqlDateFilter('field1', 0, 0, 1970, 0); + print __METHOD__." result = ".$result."\n"; + $this->assertEquals(" AND field1 BETWEEN '1970-01-01 00:00:00' AND '1970-12-31 23:59:59'", $result, 'Test dolSqlDateFilter 1'); + + /* If server/company is in TZ America/Bahia, and we need range with a date set in GMT + $result = dolSqlDateFilter('field1', 0, 0, 1970, 0, 'gmt'); + print __METHOD__." result = ".$result."\n"; + $this->assertEquals(" AND field1 BETWEEN '1969-12-31 21:00:00' AND '1970-12-31 20:59:59'", $result, 'Test dolSqlDateFilter 2'); + */ + + return 1; + } } diff --git a/test/phpunit/phpunittest.xml b/test/phpunit/phpunittest.xml index 7e903daa16d..84b31a8dd3b 100644 --- a/test/phpunit/phpunittest.xml +++ b/test/phpunit/phpunittest.xml @@ -8,8 +8,7 @@ convertWarningsToExceptions="true" colors="true" processIsolation="false" - stopOnFailure="true" - syntaxCheck="true"> + stopOnFailure="true"> @@ -42,19 +41,5 @@ ../../htdocs/includes/ - - ../../build/ - ../../dev/ - ../../doc/ - ../../test/ - ../../documents/ - ../../htdocs/custom/ - ../../htdocs/documents/custom/ - ../../htdocs/nltechno/ - ../../htdocs/products/canvas/ - ../../htdocs/contact/canvas/ - ../../htdocs/societe/canvas/ - ../../htdocs/includes/ -