diff --git a/COPYRIGHT b/COPYRIGHT index a2101a1db0a..de293e3867e 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -24,7 +24,6 @@ Component Version License GPL Compatible ------------------------------------------------------------------------------------- PHP libraries: ADOdb-Date 0.36 Modified BSD License Yes Date convertion (not into rpm package) -CKEditor 4.12.1 LGPL-2.1+ Yes Editor WYSIWYG EvalMath 1.0 BSD Yes Safe math expressions evaluation Escpos-php 2.2 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers GeoIP2 0.2.0 Apache License 2.0 Yes Lib to make geoip convert @@ -50,6 +49,7 @@ TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes JS libraries: Ace 1.4.14 BSD Yes JS library to get code syntaxique coloration in a textarea. ChartJS 3.7.1 MIT License Yes JS library for graph +CKEditor 4.18 LGPL-2.1+ Yes Editor WYSIWYG jQuery 3.6.0 MIT License Yes JS library jQuery UI 1.13.1 GPL and MIT License Yes JS library plugin UI jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect. Warning: 4.0.6+ create troubles without patching css diff --git a/ChangeLog b/ChangeLog index 1a0a95aab9e..f4945b44df0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,21 +9,177 @@ English Dolibarr ChangeLog For users: --------------- -NEW: PHP 8.0 compatibility - - +NEW: PHP 8.1 compatibility +NEW: Support for recurring purchase invoices. +NEW: #20292 Include German public holidays +NEW: #17123 added ExtraFields for Stock Mouvement +NEW: #20609 : new massaction to assign a sale representatives on a selection of thirdparties +NEW: #20653 edit discount pourcentage for all lines in one shot +NEW: Accept 'auto' for ref of object on import of purchase order/proposal +NEW: Accountancy - Add more filters and info on page to bind accounting accounts +NEW: Accountancy - Add subledger account when we generate a transaction with a deposit invoice +NEW: Accountancy - Add a massaction to preselect an account (customer and supplier list) +NEW: ACE Editor is restored at same cursor position after a save. +NEW: Add "addMoreActionsButtons" hook to subscription form +NEW: Add an option in GUI to show a Quick add button into top menu bar +NEW: Module Recruitment - Add a public page with all list of open job positions. +NEW: Module Recruitment - Add a tab with list of application on the jobposition file. +NEW: Add a workflow to auto link contract on a ticket +NEW: Add column date of Signature on proposal list +NEW: Add column template invoice in invoice list +NEW: Add column "Total HT" to products array on document creation card +NEW: ADD configuration for text color of button action +NEW: Add constant to hide categories in TakePos +NEW: Add constant to show category description in TakePos +NEW: Add constant to show only the products in stock in TakePos +NEW: Add entity filter in exports +NEW: Show the event block on recurring invoices #20870 +NEW: Add filter "opportunity status" on statistics of projects. +NEW: Add firstname, lastname and max number of attendees for module "Event Organization" +NEW: add margin info in proposal and order list +NEW: Add massaction "Edit Extrafield" for Product +NEW: Add more fields to detect duplicate during import of thirdparties +NEW: Add option to foce delivery on email for purchase order receipt to yes +NEW: Add param boder table for md theme +NEW: Add param color button action +NEW: Add possibility to create contract from invoice +NEW: Add possibility with constant MAIN_LOGIN_BADCHARUNAUTHORIZED to define bad character unauthorized into login name +NEW: Add private and public notes on tax files. +NEW: Add status "Obsolete" to KM articles +NEW: Add substitutions "user numbers" +NEW: Add the possibility to add sub-BOMs to BOM +NEW: allow a ticket to be automatically marked as read when created from backend. +NEW: allow cut&paste as real numeric value to excel +NEW: A public form to send a message and create a lead is available +NEW: automatically set totally received status in reception +NEW: Auto set invoice paid when adding credit not and remain to pay is 0 +NEW: Availibility dictionnary has a new column unit and number +NEW: barcode rule to insert product in takepos +NEW: Can change value of AWP during the inventory +NEW: Can enter price with tax for predefined products on purchase objects +NEW: Can filter on a thirdparty on product statistics +NEW: Can removed doc templates from setup page of thirdparty +NEW: Can set the parent company during the creation of thirdparty (action=add of societe/card.php) +NEW: Can use ! to make a search that exclude a string +NEW: Change in theme colors does not need to use the refresh button +NEW: clean values and amount in FEC import +NEW: const MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND for mailing mass action +NEW: Contact filter project list +NEW: Create contract from invoice +NEW: create third-party with contact if not found on public ticket +NEW: Default value for MAIN_SECURITY_CSRF_WITH_TOKEN is now 2 (GET are also protected agains CSRF attacks) +NEW: deposit payment terms: add field into dictionary admin page to define default percentage of deposit. +NEW: Dictionaries - add possibility to manage countries in EEC +NEW: display errors in a message box after generating documents +NEW: Display physical and virtual stock of the products when creating OF from a BOM +NEW: Display product ref in "Object link" product tab for BOM +NEW: Enhance the import. Can use 'auto' for the ref (import of orders) +NEW: Events on Proposal to Return to Draft +NEW: Page to list expense report payments +NEW: JS inventory autocalc input +NEW: language support for more emailing target selectors +NEW: leave requests: add field into type dictionary to block request if balance is negative +NEW: MAIN_MAIL_AUTOCOPY_TO can accept several email and special keys +NEW: MAIN_SEARCH_CAT_OR_BY_DEFAULT const for search by category +NEW: Mass action "Close shipments" +NEW: Module website now supports the multicompany module +NEW: More mode for THEME_TOPMENU_DISABLE_IMAGE (2, 3, ...) +NEW: Add option to move checkbox column as first column on Thirdparty list (only few screens) +NEW: Add tabs for nets Bom +NEW: on redirect of page in website module, GET parameters are kept. +NEW: optional display warning icons on ticket list +NEW: option to default check "notify tier at creation" in ticket module +NEW: option update prices on proposal cloning +NEW: payment conditions enabling semi-automatic deposit creation (Issue #18439) +NEW: possibility to consume multiple batch +NEW: Reverse movement product consumption +NEW: Send email to the supplier order contact +NEW: New permission to report time on timesheet. +NEW: SEPA XML - option to place payment Type Info at Credit transfer Transaction level +NEW: Show number of votes into the label of tab "Results" of a survey +NEW: Show product reference in Takepos +NEW: Some core tables are created only at module activation +NEW: split consumption line on MO +NEW: stock filter in reassort lists +NEW: stock limit in stock export CSV +NEW: Sub-bom are availables +NEW: Supplier order - Show ref supplier of reception in linked object block +NEW: support user_modif in order +NEW: TakePos - pagination on search results +NEW: The backup tools has an "lowmemory" option for mysqldump on large database +NEW: The 'reposition' class works on ajax constantonoff that make redirects +NEW: Thirdparty - Add rules "customer accountancy code" is mandatory to validate invoice +NEW: thumbnail field in product list +NEW: total mark rate in list +NEW: uncheck "send message" by default on a ticket when private messages has been checked +NEW: VAT Report by month - Show detail by rate and also by code +NEW: Ticket triggers: allow to automatically send messages on new tickets +NEW: Accountancy - Add hidden feature for accounting reconciliation +NEW: Can store the session into database (instead of beeing managed by PHP) Modules +NEW: Module Partnership Management NEW: Experimental module Event Organization Management -NEW: Experimental module Workstations Management -NEW: Experimental module Partnership Management -For developers: ---------------- - -NEW: A lot of addition of hooks. - +For developers or integrators: +------------------------------ +NEW: dol_uncompress() supports more extensions (.gz, .bz2, .zstd). Only .zip was supported before. +NEW: Implement a generic method for Kaban views +NEW: Upgrade chartjs library to 3.7.1 +NEW: update rank line is possible on API for customer invoices, sales orders and supplier invoice +NEW: stripe element with more gateways +NEW: solde() function evolution to be able to get solde until a chosen date +NEW: Suggest a way to run upgrade per entities. +NEW: Support html content for multiselect component. +NEW: ModuleBuilder - Add tabs view in module builder +NEW: ModuleBuilder - More feature that can be modifed after module generation +NEW: Hook getNomUrl available everywhere in tooltip of ref links +NEW: Identification of tr is possible with by attribute data-id on some pages +NEW: Import with select boxes V2 +NEW: Can update rank of invoice, proposal and order lines with API update +NEW: Can use current entity filter on 'chkbxlst' +NEW: Creation of the function select_bom() used to display bom select list +NEW: add printFieldListWhere hook in product reassort card +NEW: Add trigger and event on completely received status change +NEW: Add utility function send backup by mail +NEW: add WordPress OAuth to save a token (not SSO) +NEW: A module can embed a sql script run at each Dolibarr upgrade +NEW: API Proposals - Add POST lines +NEW: API REST filter states by country +NEW: Add option INVOICEREC_SET_AUTOFILL_DATE_START/END +NEW: Add option MAIN_API_DEBUG to save API logs into a file +NEW: Add param to keep the robot=index meta tag on public pages +NEW: Add method hintindex() in database handlers. +NEW: add modifications for new function "$db->prefix()" +NEW: addMoreActionsButtonsList hook for button in list +NEW: Add API to get a template invoice +NEW: Standardize a lot of code. +NEW: #20736 Allow extrafields SQL filters on REST API product lookup +NEW: #19294 implement detailed timespent in task of project API +NEW: Add a protection into PHPunit to avoid to forget a var_dump +NEW: Add datem and type parameters to API to create movements +NEW: Add hidden option on contract PDF line to hide qty and price +NEW: Option MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND to send last document in mass mailing action +NEW: Add hooks: selectContactListWhere hook, selectThirdpartyListWhere hook +NEW: TakePos - add hooks complete product display +NEW: TakePos - add hooks for cart display +NEW: TakePos - add hooks to complete ajax return array +NEW: Add hook before the public ticket list +NEW: Add hook doaction in takepos invoice +NEW: Add Hook for Notif +NEW: Add hook for more buttons +NEW: Add hook printFieldListWhere in "show_contacts" function +NEW: Add hook printFieldWhere in load_state_board function +NEW: Add hooks contact tab badge and hooks parameter for avoid conflicts +NEW: Add hook selectProductsListWhere in select_produits_list function +NEW: Add hooks in commercial index +NEW: Add hooks in customers and products boxes +NEW: Add hooks in thirdparty index page +NEW: Add hooks on project task time page +NEW: Add hooks on salaries and sociales card +NEW: Add hooks select product list and select thirdparty list function +NEW: Add hook to getSellPrice function Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: @@ -39,6 +195,105 @@ Following changes may create regressions for some external modules, but were nec * Move massaction 'confirm_createbills' from actions_massactions.inc.php to commande/list.php * Method fetch_all_resources(), fetch_all_used(), fetch_all_available() of DolResource has been removed (they were not used by core code). * Method fetch_all of DolResource has been renamed into fetchAll() to match naming conventions. +* The hook 'upgrade' and 'doUpgrade2" has been renamed 'doUpgradeBefore' and 'doUpgradeAfterDB'. A new trigger 'doUpgradeAfterFiles' has been introduced. + + + +***** ChangeLog for 15.0.2 compared to 15.0.1 ***** + +FIX: #19777 #20281 +FIX: #20140 #20301 +FIX: #20279 Accountancy - PostGreSQL - Error on mass update lines already binded +FIX: #20476 migration postgresql 14.0.x to 15.0.x packaging type +FIX: #20733 Inventory: Do not use batch qty even if present if batch module is disabled. +FIX: action comm list: holiday last day not included + handle duration with halfdays +FIX: Add missing entity on salary's payment +FIX: Add 'recruitment' into check array +FIX: add tools to fix bad bank amount in accounting with multicurrency +FIX: assign member cateogry to a member +FIX: backport +FIX: bad bank amount in accounting with multicurrency +FIX: Bad condition on remx +FIX: Bad filter on date on salary list +FIX: bad link to add a customer price (token duplicated) +FIX: bad status of member on widget by type and status +FIX: better error management at product selling price update +FIX: Can't edit bank record +FIX: check mandatory thirdparty fields for mass action +FIX: check thirdparty object loaded and properties exist +FIX: comment +FIX: compatibility for ticket number sharing +FIX: compatibility with multicompany sharings +FIX: contact card: single extrafield update failed +FIX: country not visible into list of states +FIX: Delete an extrafield where type is double +FIX: deprecated module are not more viewed as external modules +FIX: Disable customer type by default if type prospect/customer is disabled +FIX: each time we create a supplier order, we need to give it a ref_supplier +FIX: Error management +FIX: fatal error for $db usage in tpl +FIX: filter into the list of product lots +FIX: Filter on Object Referent page give CRSF page +FIX: Fix default options ($hidedetails, $hidedesc, $hideref) with globales when generate PDF in mass actions +FIX: Fix search by filters +FIX: Fix the adding of lines in the create invoice functions +FIX: forgotten form confirm before various payment delete +FIX: holiday/leave requests: write status change emails in HTML +FIX: include discount price for PMP after a reception (Issue #20029) +FIX: incrementation +FIX: in salary stats and payment list, we must check right perms as well as salary list +FIX: intervention entity missing +FIX: label tax cat trad +FIX: Mass action ship orders +FIX: missing advanced perms +FIX: missing call to executeHooks() +FIX: Missing entity on adding new VAT +FIX: missing hook for row ordering +FIX: missing hook parameter ($possiblelinks) +FIX: missing parenthesis +FIX: missing picto in combo of mass actions of thirdparties. +FIX: missing signature library when ODT model is used +FIX: Missing unset fields after updateline expensereport +FIX: ModuileBuilder - Fix getLinesArray() error reporting +FIX: Move delete task time trigger position +FIX: Navigation between invoices +FIX: No empty line inserted into accounting_bookkeeping +FIX: Numbering of sepa files +FIX: object cloning: set unique extrafield values to null to prevent duplicates +FIX: on update with action reminder in future there is user key error +FIX: originproductline array td identification data-id +FIX: out of memory when more than 100 000 invoices. +FIX: permit access to medias when logged in a different entity +FIX: phpcs +FIX: project creation prevented if PROJECTLEADER contact role renamed, de-activated or deleted +FIX: project timesheet by week: cleanup unused code +FIX: project timesheet: public holidays offset by 1 day +FIX: project timesheets: assume Saturday and Sunday as default weekend days when working days conf is empty or badly formed +FIX: propal list: bad error management when setting "not signed" mass action +FIX: propal list mass action translations and error management (v14 edition) +FIX: propal list: missing not signed massaction translation keys for transifex +FIX: PR returns +FIX: ref_client doesn't exists on supplier invoice, then ref_fourn needs to have a default value when we want to bill several supplier orders +FIX: replenish and manage product stock by warhouse +FIX: sending email on payment of registration of event +FIX: SEPA ICS is not mandatory for bank transfer +FIX: Set datec when add time spent on a project task +FIX: status filter on supplierOrder stats doesn't work +FIX: stickler-ci +FIX: still prevent project creation if PROJECTLEADER role unavailable, but with a specific error message +FIX: Supplier order stats +FIX: Tabulation must be allowed for HTML content +FIX: tool to fix bank account not in main currency for vendor invoice +FIX: translations +FIX: Travis + Update dev +FIX: truncate Customer Reference too long on PDF header (PR #20718) +FIX: uniformize code +FIX: Update of sale price (log not correctly updated) +FIX: user actions rights when mulit-company transverse mode is enabled +FIX: user employee tab: offset in open days messes up holiday length calculation +FIX: We need to have a different default_ref_supplier for each new fourn invoice +FIX: "WHERE" clause missing on resource export +FIX: #yogosha9754 ***** ChangeLog for 15.0.1 compared to 15.0.0 ***** diff --git a/SECURITY.md b/SECURITY.md index c55d6d26ab0..cd3156bece9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,8 +6,9 @@ This file contains some policies about the security reports on Dolibarr ERP CRM | Version | Supported | | ---------- | ---------------------- | -| <= 14.0.4 | :x: | -| >= 14.0.5+ | :white_check_mark: except CSRF attacks| +| <= 15.0.0 | :x: | +| >= 15.0.1+ | :white_check_mark: except CSRF attacks| +| >= 16.0.0 | :white_check_mark: | | >= develop | :white_check_mark: | ## Reporting a Vulnerability diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index dbf74a96f67..c316e0f91d6 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -27,12 +27,12 @@ OutputBaseFilename=__FILENAMEEXEDOLIWAMP__ ;SourceDir=Z:\home\ldestailleur\git\dolibarrxxx SourceDir=..\..\.. AppId=doliwamp -AppPublisher=NLTechno -AppPublisherURL=https://www.nltechno.com +AppPublisher=DoliCloud +AppPublisherURL=https://www.dolicloud.com AppSupportURL=https://www.dolibarr.org AppUpdatesURL=https://www.dolibarr.org AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql software. -AppCopyright=Copyright (C) 2008-2020 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) +AppCopyright=Copyright (C) 2008-2022 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) DefaultDirName=c:\dolibarr DefaultGroupName=Dolibarr ;LicenseFile=COPYING @@ -99,13 +99,12 @@ Source: "build\exe\doliwamp\startdoliwamp_manual_donotuse.bat.install"; DestDir: Source: "build\exe\doliwamp\builddemosslfiles.bat.install"; DestDir: "{app}\"; Flags: ignoreversion; Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversion; -; PhpMyAdmin, Apache, Php, Mysql +; Apache, Php, Mysql ; Put here path of Wampserver applications ; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45 ; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45 ; Value OK: apache 2.4.9, php 5.5.12, mysql 5.0.45 instead of 5.6.17 (wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe) ; Value OK: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe) -Source: "C:\wamp64\apps\phpmyadmin4.9.2\*.*"; DestDir: "{app}\apps\phpmyadmin4.9.2"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" ;Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" Source: "C:\wamp64\bin\apache\apache2.4.41\*.*"; DestDir: "{app}\bin\apache\apache2.4.41"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" ;Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" @@ -125,9 +124,7 @@ Source: "scripts\*.*"; DestDir: "{app}\www\dolibarr\scripts"; Flags: ignoreversi Source: "*.*"; DestDir: "{app}\www\dolibarr"; Flags: ignoreversion; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,default.properties,install.lock" ; Config files -Source: "build\exe\doliwamp\phpmyadmin.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion; Source: "build\exe\doliwamp\dolibarr.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion; -Source: "build\exe\doliwamp\config.inc.php.install"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion; ;Source: "build\exe\doliwamp\httpd.conf.install"; DestDir: "{app}\bin\apache\apache2.4.9\conf"; Flags: ignoreversion; Source: "build\exe\doliwamp\httpd.conf.install"; DestDir: "{app}\bin\apache\apache2.4.41\conf"; Flags: ignoreversion; Source: "build\exe\doliwamp\my.ini.install"; DestDir: "{app}\bin\mysql\mysql5.0.45"; Flags: ignoreversion; @@ -196,7 +193,6 @@ var destFileA: String; var srcContents: String; var browser: String; var mysqlVersion: String; -var phpmyadminVersion: String; var phpDllCopy: String; var batFile: String; @@ -246,7 +242,6 @@ begin phpVersion := '7.3.12' ; //mysqlVersion := '5.0.45'; mysqlVersion := '10.4.10'; - phpmyadminVersion := '4.1.14'; smtpServer := 'localhost'; apachePort := '80'; @@ -635,27 +630,6 @@ begin begin - //---------------------------------------------- - // Create file alias phpmyadmin (always) - //---------------------------------------------- - - destFile := pathWithSlashes+'/alias/phpmyadmin.conf'; - srcFile := pathWithSlashes+'/alias/phpmyadmin.conf.install'; - - if FileExists(srcFile) then - begin - LoadStringFromFile (srcFile, srcContents); - - //installDir et version de phpmyadmin - StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True); - StringChangeEx (srcContents, 'WAMPPHPMYADMINVERSION', phpmyadminVersion, True); - - SaveStringToFile(destFile,srcContents, False); - end; - DeleteFile(srcFile); - - - //---------------------------------------------- // Create file alias dolibarr (if not exists) //---------------------------------------------- @@ -691,35 +665,6 @@ begin - //---------------------------------------------- - // Create file configuration for phpmyadmin (if not exists) - //---------------------------------------------- - - destFile := pathWithSlashes+'/apps/phpmyadmin'+phpmyadminVersion+'/config.inc.php'; - srcFile := pathWithSlashes+'/apps/phpmyadmin'+phpmyadminVersion+'/config.inc.php.install'; - - if FileExists(srcFile) then - begin - if not FileExists (destFile) then - begin - LoadStringFromFile (srcFile, srcContents); - StringChangeEx (srcContents, 'WAMPMYSQLNEWPASSWORD', mypass, True); - StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True); - SaveStringToFile(destFile,srcContents, False); - end - else - begin - // We must replace to use format 2.4 of apache - DeleteFile(destFile); - LoadStringFromFile (srcFile, srcContents); - StringChangeEx (srcContents, 'WAMPMYSQLNEWPASSWORD', mypass, True); - StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True); - SaveStringToFile(destFile,srcContents, False); - end; - end; - - - //---------------------------------------------- // Create file httpd.conf (if not exists) //---------------------------------------------- diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 906601d94d4..b648bd7aff7 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -582,9 +582,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/timesheet*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/webmail*`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/allscreen*`; - $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/theme/common/fontawesome-5/svgs`; # Removed other test files $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/test`; diff --git a/dev/tools/test/namespacemig/main.inc.php b/dev/tools/test/namespacemig/main.inc.php index 555a4b36ff5..d46d8e38c1c 100644 --- a/dev/tools/test/namespacemig/main.inc.php +++ b/dev/tools/test/namespacemig/main.inc.php @@ -1,7 +1,7 @@ loan->enabled) { $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST'; $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'; } +$list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE'; if ($conf->societe->enabled) { + $list_account[] = '---Deposits---'; $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'; } -$list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE'; /* * Actions @@ -134,6 +135,20 @@ if ($action == 'update') { } } +if ($action == 'setdisableauxiliaryaccountoncustomerdeposit') { + $setDisableAuxiliaryAccountOnCustomerDeposit = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT", $setDisableAuxiliaryAccountOnCustomerDeposit, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View @@ -231,6 +246,20 @@ foreach ($list_account as $key) { } } +if ($conf->societe->enabled) { + print ''; + print '' . img_picto('', 'bill', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnCustomerDeposit") . ''; + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; +} print "\n"; print "\n"; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 1a682636077..c8cb62cd7e0 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -395,8 +395,8 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; @@ -406,9 +406,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/admin/productaccount.php", LOG_DEBUG); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); $i = 0; $param = ''; @@ -608,7 +608,7 @@ if ($result) { $i = 0; while ($i < min($num, $limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); // Ref produit as link $product_static->ref = $obj->ref; @@ -891,7 +891,7 @@ if ($result) { print ''; - $db->free($result); + $db->free($resql); } else { dol_print_error($db); } diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 3c2e8763fe1..7a65fa0ffaa 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -349,7 +349,7 @@ if ($action != 'export_csv') { $sql .= " GROUP BY t.numero_compte"; $resql = $db->query($sql); - $nrows = $resql->num_rows; + $nrows = $db->num_rows($resql); $opening_balances = array(); for ($i = 0; $i < $nrows; $i++) { $arr = $resql->fetch_array(); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 511b12de3c2..61e131ff47d 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -431,12 +431,12 @@ if ($action == 'create') { // Account movement print ''; print ''.$langs->trans("NumMvts").''; - print ''.$object->piece_num.''; + print ''.($mode == '_tmp' ? ''.$langs->trans("Draft").'' : $object->piece_num).''; print ''; // Date print ''; - print ''; print ''; print ''; print ''; + // Create third-party with contact if email not linked to a contact + print ''; + print ''; + print ''; + print ''; + /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // Show logo for module @@ -341,7 +408,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print '

'; - print_fiche_titre($langs->trans("Emails")); + print load_fiche_titre($langs->trans("Emails")); print '
'; print '
'; + print ''; if ($action != 'editdate') { diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index ac943180b58..28c35016054 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -586,11 +586,11 @@ class AccountingAccount extends CommonObject $sql .= ' WHERE a.rowid = ' . ((int) $id); dol_syslog(get_class($this) . '::info sql=' . $sql); - $result = $this->db->query($sql); + $resql = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; if ($obj->fk_user_author) { $cuser = new User($this->db); @@ -605,7 +605,7 @@ class AccountingAccount extends CommonObject $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } - $this->db->free($result); + $this->db->free($resql); } else { dol_print_error($this->db); } @@ -748,6 +748,7 @@ class AccountingAccount extends CommonObject $reshook = $hookmanager->executeHooks('accoutancyBindingCalculation', $parameters); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { + $const_name = ''; if ($type == 'customer') { $const_name = "SOLD"; } elseif ($type == 'supplier') { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 21b723b003b..d01ad89293f 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1843,8 +1843,8 @@ class BookKeeping extends CommonObject /** * Transform transaction * - * @param number $direction If 0 tmp => real, if 1 real => tmp - * @param string $piece_num Piece num + * @param number $direction If 0: tmp => real, if 1: real => tmp + * @param string $piece_num Piece num = Transaction ref * @return int int <0 if KO, >0 if OK */ public function transformTransaction($direction = 0, $piece_num = '') @@ -1862,57 +1862,82 @@ class BookKeeping extends CommonObject if ($next_piecenum < 0) { $error++; } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' (doc_date, doc_type,'; - $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; - $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; - $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation)'; - $sql .= ' SELECT doc_date, doc_type,'; - $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; - $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; - $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.((int) $next_piecenum).", '".$this->db->idate($now)."'"; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + if (!$error) { + // Delete if there is an empty line + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity)." AND numero_compte IS NULL AND debit = 0 AND credit = 0"; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } } - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + if (!$error) { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' (doc_date, doc_type,'; + $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; + $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; + $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation)'; + $sql .= ' SELECT doc_date, doc_type,'; + $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; + $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; + $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.((int) $next_piecenum).", '".$this->db->idate($now)."'"; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND numero_compte IS NOT NULL AND entity = ' .((int) $conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } + } + + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } } } elseif ($direction == 1) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'_tmp (doc_date, doc_type,'; - $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; - $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; - $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)'; - $sql .= ' SELECT doc_date, doc_type,'; - $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; - $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; - $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + if (!$error) { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'_tmp (doc_date, doc_type,'; + $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; + $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; + $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)'; + $sql .= ' SELECT doc_date, doc_type,'; + $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; + $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; + $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } } - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + } } } if (!$error) { diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index a2718973185..405a630942e 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -266,14 +266,14 @@ class Lettering extends BookKeeping $sql .= " ORDER BY ab2.lettering_code DESC"; $sql .= " LIMIT 1 "; - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + $resqla = $this->db->query($sql); + if ($resqla) { + $obj = $this->db->fetch_object($resqla); $lettre = (empty($obj->lettering_code) ? 'AAA' : $obj->lettering_code); if (!empty($obj->lettering_code)) { $lettre++; } - $this->db->free($result); + $this->db->free($resqla); } else { $this->errors[] = 'Error'.$this->db->lasterror(); $error++; @@ -281,14 +281,14 @@ class Lettering extends BookKeeping $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE "; $sql .= " rowid IN (".$this->db->sanitize(implode(',', $ids)).") AND lettering_code IS NULL AND subledger_account != ''"; - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + $resqlb = $this->db->query($sql); + if ($resqlb) { + $obj = $this->db->fetch_object($resqlb); if (!(round(abs($obj->deb), 2) === round(abs($obj->cred), 2))) { $this->errors[] = 'Total not exacts '.round(abs($obj->deb), 2).' vs '.round(abs($obj->cred), 2); $error++; } - $this->db->free($result); + $this->db->free($resqlb); } else { $this->errors[] = 'Erreur sql'.$this->db->lasterror(); $error++; @@ -699,6 +699,8 @@ class Lettering extends BookKeeping return $grouped_payments; } + $save_payment_by_element = null; + $save_element_by_payment = null; if ($element_id == 0) { // Save list when is the begin of recursive function $save_payment_by_element = $payment_by_element; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index bc6713f0846..b9ea4fc0e54 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2013-2021 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,6 +47,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha'); +$default_account = GETPOST('default_account', 'int'); // Select Box $mesCasesCochees = GETPOST('toselect', 'array'); @@ -434,12 +436,15 @@ if ($result) { $arrayofmassactions = array( 'ventil'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate") + ,'set_default_account'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ConfirmPreselectAccount") //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); + if ($massaction !== 'set_default_account') { + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); + } print '
'."\n"; print ''; @@ -454,6 +459,14 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); + if ($massaction == 'set_default_account') { + $formquestion[]=array('type' => 'other', + 'name' => 'set_default_account', + 'label' => $langs->trans("AccountancyCode"), + 'value' => $formaccounting->select_account('', 'default_account', 1, array(), 0, 0, 'maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone')); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmPreselectAccount"), $langs->trans("ConfirmPreselectAccountQuestion", count($toselect)), "confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1); + } + print ''.$langs->trans("DescVentilTodoCustomer").'

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

'; if ($msg) { @@ -736,7 +749,7 @@ if ($result) { // Suggested accounting account print '
'; // Column with checkbox @@ -745,6 +758,14 @@ if ($result) { if (!empty($suggestedid) && $suggestedaccountingaccountfor != '' && $suggestedaccountingaccountfor != 'eecwithoutvatnumber') { $ischecked = 1; } + + if (!empty($toselect)) { + $ischecked = 0; + if (in_array($objp->rowid."_".$i, $toselect)) { + $ischecked=1; + } + } + print ''; print ''; diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index d51dd8ef730..ed2453ef793 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -64,7 +64,7 @@ if ($action == 'set_default') { } elseif ($action == 'del_default') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->MEMBER_ADDON_PDF_ODT == "$value") { + if (getDolGlobalString('MEMBER_ADDON_PDF_ODT') == "$value") { dolibarr_del_const($db, 'MEMBER_ADDON_PDF_ODT', $conf->entity); } } @@ -248,8 +248,8 @@ if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty( $arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice"); } print ''; @@ -378,16 +378,16 @@ foreach ($dirmodels as $reldir) { print ''; } else { print '"; } // Defaut print ''; @@ -398,8 +398,8 @@ foreach ($dirmodels as $reldir) { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn(!empty($module->option_logo) ? $module->option_logo : 0, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn(!empty($module->option_multilang) ? $module->option_multilang : 0, 1, 1); print ''; // EMail - print ''; + print ''; print ''; // Website @@ -2030,7 +2030,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $MAX = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index cafc9338ae8..3f857ce827b 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -121,6 +121,9 @@ class AdherentType extends CommonObject /** @var array Array of members */ public $members = array(); + /** @var string string other */ + public $other = array(); + public $multilangs = array(); diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 9aef78174de..b3cfe027197 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -490,17 +490,17 @@ class Subscription extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; $sql .= ' WHERE c.rowid = '.((int) $id); - $result = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); } - $this->db->free($result); + $this->db->free($resql); } else { dol_print_error($this->db); } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 2b0c295afbd..1ef98dddb6d 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -99,12 +99,12 @@ $sql .= " WHERE t.entity IN (".getEntity('member_type').")"; $sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; dol_syslog("index.php::select nb of members per type", LOG_DEBUG); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($result); + $objp = $db->fetch_object($resql); $adhtype = new AdherentType($db); $adhtype->id = $objp->rowid; @@ -127,7 +127,7 @@ if ($result) { $i++; } - $db->free($result); + $db->free($resql); } $now = dol_now(); @@ -143,16 +143,16 @@ $sql .= " AND t.rowid = d.fk_adherent_type"; $sql .= " GROUP BY d.fk_adherent_type"; dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($result); + $objp = $db->fetch_object($resql); $MembersUpToDate[$objp->fk_adherent_type] = $objp->somme; $i++; } - $db->free(); + $db->free($resql); } /* diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index c2ef4583bdc..72f75cdf4c8 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -305,6 +305,8 @@ $formother = new FormOther($db); $membertypestatic = new AdherentType($db); $memberstatic = new Adherent($db); +$title = $langs->trans("Members"); + $now = dol_now(); if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) { @@ -471,42 +473,41 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ exit; } -llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); +llxHeader('', $title, 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); -$titre = $langs->trans("MembersList"); if (GETPOSTISSET("search_status")) { if ($search_status == '-1,1') { // TODO : check this test as -1 == Adherent::STATUS_DRAFT and -2 == Adherent::STATUS_EXLCUDED - $titre = $langs->trans("MembersListQualified"); + $title = $langs->trans("MembersListQualified"); } if ($search_status == Adherent::STATUS_DRAFT) { - $titre = $langs->trans("MembersListToValid"); + $title = $langs->trans("MembersListToValid"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == '') { - $titre = $langs->trans("MenuMembersValidated"); + $title = $langs->trans("MenuMembersValidated"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'withoutsubscription') { - $titre = $langs->trans("MembersWithSubscriptionToReceive"); + $title = $langs->trans("MembersWithSubscriptionToReceive"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'uptodate') { - $titre = $langs->trans("MembersListUpToDate"); + $title = $langs->trans("MembersListUpToDate"); } if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'outofdate') { - $titre = $langs->trans("MembersListNotUpToDate"); + $title = $langs->trans("MembersListNotUpToDate"); } if ((string) $search_status == (string) Adherent::STATUS_RESILIATED) { // The cast to string is required to have test false when search_status is '' - $titre = $langs->trans("MembersListResiliated"); + $title = $langs->trans("MembersListResiliated"); } if ($search_status == Adherent::STATUS_EXCLUDED) { - $titre = $langs->trans("MembersListExcluded"); + $title = $langs->trans("MembersListExcluded"); } } elseif ($action == 'search') { - $titre = $langs->trans("MembersListQualified"); + $title = $langs->trans("MembersListQualified"); } if ($search_type > 0) { $membertype = new AdherentType($db); $result = $membertype->fetch($search_type); - $titre .= " (".$membertype->label.")"; + $title .= " (".$membertype->label.")"; } $param = ''; @@ -623,7 +624,7 @@ print ''; print ''; print ''; -print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "Information"; $modelmail = "member"; diff --git a/htdocs/adherents/partnership.php b/htdocs/adherents/partnership.php index 160a037c187..a01e7d28ed2 100644 --- a/htdocs/adherents/partnership.php +++ b/htdocs/adherents/partnership.php @@ -85,11 +85,18 @@ $usercanclose = $user->rights->partnership->write; // Used by the include of $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; -if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR != 'member') accessforbidden(); -if (empty($conf->partnership->enabled)) accessforbidden(); -if (empty($permissiontoread)) accessforbidden(); -if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); - +if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') != 'member') { + accessforbidden('Partnership module is not activated for members'); +} +if (empty($conf->partnership->enabled)) { + accessforbidden(); +} +if (empty($permissiontoread)) { + accessforbidden(); +} +if ($action == 'edit' && empty($permissiontoadd)) { + accessforbidden(); +} if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT) { accessforbidden(); } diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index af09d32bc73..52926cf1b19 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -173,6 +173,9 @@ if (!empty($triggers)) { if ($module == 'contact') { $module = 'societe'; } + if ($module == 'facturerec') { + $module = 'facture'; + } // If 'element' value is myobject@mymodule instead of mymodule $tmparray = explode('@', $module); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 493203231b5..2ac4fa76682 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -225,7 +225,7 @@ $tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFI $tabsql[25] = "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity = ".getEntity($tabname[25]); //$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcomm"; -$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.block_if_negative, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; +$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.block_if_negative, h.sortorder, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; $tabsql[29] = "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; $tabsql[30] = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; //$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s"; @@ -272,7 +272,7 @@ $tabsqlsort[24] = "code ASC, label ASC"; $tabsqlsort[25] = "t.module ASC, t.code ASC, t.label ASC"; //$tabsqlsort[26]="code ASC"; $tabsqlsort[27] = "code ASC"; -$tabsqlsort[28] = "country ASC, code ASC"; +$tabsqlsort[28] = "sortorder ASC, country ASC, code ASC"; $tabsqlsort[29] = "position ASC"; $tabsqlsort[30] = "code ASC"; //$tabsqlsort[31]="pcg_version ASC"; @@ -319,7 +319,7 @@ $tabfield[24] = "code,label"; $tabfield[25] = "code,label"; //$tabfield[26]= "code,label,short_label"; $tabfield[27] = "code,libelle,picto"; -$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country,block_if_negative"; +$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country,block_if_negative,sortorder"; $tabfield[29] = "code,label,percent,position"; $tabfield[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfield[31]= "pcg_version,label"; @@ -366,7 +366,7 @@ $tabfieldvalue[24] = "code,label"; $tabfieldvalue[25] = "code,label"; //$tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27] = "code,libelle,picto"; -$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country,block_if_negative"; +$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country,block_if_negative,sortorder"; $tabfieldvalue[29] = "code,label,percent,position"; $tabfieldvalue[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldvalue[31]= "pcg_version,label"; @@ -413,7 +413,7 @@ $tabfieldinsert[24] = "code,label"; $tabfieldinsert[25] = "code,label"; //$tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27] = "code,libelle,picto"; -$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country,block_if_negative"; +$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country,block_if_negative,sortorder"; $tabfieldinsert[29] = "code,label,percent,position"; $tabfieldinsert[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldinsert[31]= "pcg_version,label"; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 32b55d0a612..35c483f33e6 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -420,7 +420,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index 900754ef4b4..10b14f8ee99 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -36,10 +36,10 @@ $langs->loadLangs(array("admin", "trips", "errors", "other", "dict")); $error = 0; $action = GETPOST('action', 'aZ09'); + $id = GETPOST('id', 'int'); $ikoffset = GETPOST('ikoffset', 'int'); $coef = GETPOST('coef', 'int'); - $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); $fk_range = GETPOST('fk_range', 'int'); @@ -62,9 +62,16 @@ if ($action == 'updateik') { } } - $expIk->setValues($_POST); - $result = $expIk->create($user); + $expIk->coef = $coef; + $expIk->ikoffset = $ikoffset; + $expIk->fk_c_exp_tax_cat = $fk_c_exp_tax_cat; + $expIk->fk_range = $fk_range; + if ($expIk->id > 0) { + $result = $expIk->update($user); + } else { + $result = $expIk->create($user); + } if ($result > 0) { setEventMessages('SetupSaved', null, 'mesgs'); diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 1146232dca3..7c27ee6e408 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -34,13 +34,19 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_rule.class.ph // Load translation files required by the page $langs->loadLangs(array("admin", "other", "trips", "errors", "dict")); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('admin', 'dictionaryadmin','expensereport_rules')); + +$object = new ExpenseReportRule($db); + if (!$user->admin) { accessforbidden(); } -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('admin', 'dictionaryadmin','expensereport_rules')); +/* + * Action + */ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -51,7 +57,6 @@ if ($reshook < 0) { if (empty($reshook)) { //Init error $error = false; - $message = false; $action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); @@ -59,21 +64,20 @@ if (empty($reshook)) { $apply_to = GETPOST('apply_to'); $fk_user = GETPOST('fk_user', 'int'); $fk_usergroup = GETPOST('fk_usergroup', 'int'); - - $fk_c_type_fees = GETPOST('fk_c_type_fees'); + $restrictive = GETPOST('restrictive', 'int'); + $fk_c_type_fees = GETPOST('fk_c_type_fees', 'int'); $code_expense_rules_type = GETPOST('code_expense_rules_type'); $dates = dol_mktime(12, 0, 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear')); $datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - $amount = GETPOST('amount'); + $amount = price2num(GETPOST('amount'), 'MT', 2); - $object = new ExpenseReportRule($db); if (!empty($id)) { $result = $object->fetch($id); if ($result < 0) { dol_print_error('', $object->error, $object->errors); } } - // TODO do action + if ($action == 'save') { $error = 0; @@ -104,8 +108,6 @@ if (empty($reshook)) { } if (empty($error)) { - $object->setValues($_POST); - if ($apply_to == 'U') { $object->fk_user = (int) $fk_user; $object->fk_usergroup = 0; @@ -122,18 +124,30 @@ if (empty($reshook)) { $object->dates = $dates; $object->datee = $datee; - + $object->restrictive = $restrictive; + $object->fk_c_type_fees = $fk_c_type_fees; + $object->code_expense_rules_type = $code_expense_rules_type; + $object->amount = $amount; $object->entity = $conf->entity; - $res = $object->create($user); + if ($object->id > 0) { + $res = $object->update($user); + } else { + $res = $object->create($user); + } if ($res > 0) { setEventMessages($langs->trans('ExpenseReportRuleSave'), null); } else { dol_print_error($object->db); + $error++; } - header('Location: ' . $_SERVER['PHP_SELF']); - exit; + if (!$error) { + header('Location: ' . $_SERVER['PHP_SELF']); + exit; + } else { + $action = ''; + } } } elseif ($action == 'delete') { // TODO add confirm @@ -207,7 +221,7 @@ if ($action != 'edit') { echo '
'; echo ''; echo ''; + echo ''; echo ''; echo ''; echo ''; @@ -266,11 +280,11 @@ foreach ($rules as $rule) { if ($rule->fk_c_type_fees == -1) { echo $langs->trans('AllExpenseReport'); } else { - $key = getDictionaryValue(MAIN_DB_PREFIX . 'c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id'); + $key = getDictionaryValue('c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id'); if ($key && $key != $langs->trans($key)) { echo $langs->trans($key); } else { - $value = getDictionaryValue(MAIN_DB_PREFIX . 'c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id'); + $value = getDictionaryValue('c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id'); echo $langs->trans($value ? $value : 'Undefined'); // TODO check to return trans of 'code' } } @@ -304,10 +318,10 @@ foreach ($rules as $rule) { } echo ''; - + // Amount echo ''; print ''; print "\n"; -/*var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY); -*/ +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY); + if (!isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY)) { $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY = 1; } if (!isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY)) { $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY = 1; } -/* -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY); -var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY); -*/ + +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY); +//var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY); + // Set working days print ''; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 8ed6615965b..dbf4ca53686 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -529,7 +529,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { $moreforfilter .= dolGetButtonTitle($langs->trans('CheckForModuleUpdate'), $langs->trans('CheckForModuleUpdate').'
'.$langs->trans('CheckForModuleUpdateHelp'), 'fa fa-sync', $_SERVER["PHP_SELF"].'?action=checklastversion&token='.newToken().'&mode='.$mode.$param, '', 1, array('morecss'=>'reposition')); $moreforfilter .= dolGetButtonTitleSeparator(); $moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', ($mode == 'commonkanban' ? 2 : 1), array('morecss'=>'reposition')); - $moreforfilter .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.$param, '', ($mode == 'common' ? 2 : 1), array('morecss'=>'reposition')); + $moreforfilter .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.$param, '', ($mode == 'common' ? 2 : 1), array('morecss'=>'reposition')); $moreforfilter .= ''; //$moreforfilter .= '
'.$moreinfo.' '.$moreinfo2.'
'; diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index ebd1269f74a..1d3e29c9cd4 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -78,7 +78,7 @@ print '
'; print '
'; print $langs->trans('Docdate'); print ''; - print $formaccounting->select_account($suggestedid, 'codeventil'.$facture_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); + print $formaccounting->select_account(($default_account > 0 && $confirm === 'yes' && in_array($objp->rowid."_".$i, $toselect)) ? $default_account : $suggestedid, 'codeventil'.$facture_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); print '"; - if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { - if (($accountoshow == "") || $accountoshow == 'NotDefined') { - print ''.$langs->trans("ThirdpartyAccountNotDefined").''; - } else { + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { + if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) { print length_accounta($tabcompany[$key]['code_compta']); } + } elseif (($accountoshow == "") || $accountoshow == 'NotDefined') { + print '' . $langs->trans("ThirdpartyAccountNotDefined") . ''; } print ''; - print $formaccounting->select_account($suggestedid, 'codeventil'.$facturefourn_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); + print $formaccounting->select_account(($default_account > 0 && $confirm === 'yes' && in_array($objp->rowid."_".$i, $toselect)) ? $default_account : $suggestedid, 'codeventil'.$facturefourn_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; -print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0); -if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') { +print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, getDolGlobalString('ADHERENT_BANK_USE'), 0); +if (getDolGlobalString('ADHERENT_BANK_USE') == 'bankdirect' || getDolGlobalString('ADHERENT_BANK_USE') == 'bankviainvoice') { print '
'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'
'; } print '
'."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir) ? $module->scandir : '').'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'; - if ($conf->global->MEMBER_ADDON_PDF == $name) { + if (getDolGlobalString('MEMBER_ADDON_PDF') == $name) { print img_picto($langs->trans("Default"), 'on'); } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + print 'scandir) ? $module->scandir : '').'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; } print ''; diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index ed09c206abf..6199991f29c 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -95,12 +95,13 @@ if ($action == 'update') { $form = new Form($db); +$title = $langs->trans("MembersSetup"); $help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; -llxHeader('', $langs->trans("MembersSetup"), $help_url); +llxHeader('', $title, $help_url); $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup'); +print load_fiche_titre($title, $linkback, 'title_setup'); $head = member_admin_prepare_head(); diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 9132dae5802..0a6abcd4955 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -163,7 +163,7 @@ if ($object->id > 0) { $newcardbutton = ''; if (!empty($conf->agenda->enabled)) { - $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).($object->id > 0 ? '?id='.$object->id : '').'&origin=member&originid='.$id); } if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 5bdb99330f6..88a63af0ae1 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1286,7 +1286,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').'
'.(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '' : '').$langs->trans("EMail").(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '' : '').''.img_picto('', 'object_email', 'class="pictofixedwidth"').'email).'">
' . $form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0) . '' . $form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0) . ' ' . $conf->currency . '' . $form->selectyesno('restrictive', 0, 1) . '
'; if ($action == 'edit' && $object->id == $rule->id) { - echo '' . $conf->currency; + echo ''; } else { echo price($rule->amount, 0, $langs, 1, -1, -1, $conf->currency); } diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index c1755b17edf..7b0aa577a87 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -442,23 +442,23 @@ print ''.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print ''; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''; @@ -106,6 +106,15 @@ if (empty($conf->use_javascript_ajax)) { print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +/* print ''; print ''; print ''; print ''; print ''; - - -print ''; -print ''; -print ''; -print ''; -print ''; +*/ print '
'.$langs->trans("Parameters").''.$langs->trans("Value").''.$langs->trans("Value").'
'.$langs->trans('EnableResourceUsedInEventCheck').''; +echo ajax_constantonoff('RESOURCE_USED_IN_EVENT_CHECK'); +print '
'.$langs->trans('DisabledResourceLinkUser').''; @@ -122,15 +131,7 @@ echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_THIPARTY'); print '
'.$langs->trans('EnableResourceUsedInEventCheck').''; -echo ajax_constantonoff('RESOURCE_USED_IN_EVENT_CHECK'); -print '
'; print ''; diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index c4967f75313..0af4a3384e0 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -74,7 +74,6 @@ llxHeader('', $langs->trans("ResourceSetup")); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ResourceSetup"), $linkback, 'title_setup'); -print "
\n"; $head = resource_admin_prepare_head(); diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 10edae1a24b..58c27cbb1e4 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -407,10 +407,10 @@ if (empty($error) && !empty($xml)) { $checksumget = md5(join(',', $checksumconcat)); $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); - /*var_dump(count($file_list['added'])); - var_dump($checksumget); - var_dump($checksumtoget); - var_dump($checksumget == $checksumtoget);*/ + //var_dump(count($file_list['added'])); + //var_dump($checksumget); + //var_dump($checksumtoget); + //var_dump($checksumget == $checksumtoget); $resultcomment = ''; diff --git a/htdocs/admin/system/xcache.php b/htdocs/admin/system/xcache.php index 8bdca5be40e..4e2f881a14c 100644 --- a/htdocs/admin/system/xcache.php +++ b/htdocs/admin/system/xcache.php @@ -58,23 +58,6 @@ print $langs->trans("xcache.optimizer").': '.yn(ini_get('xcache.optimizer')).' ( print $langs->trans("xcache.stat").': '.yn(ini_get('xcache.stat')).'
'."\n"; print $langs->trans("xcache.coverager").': '.yn(ini_get('xcache.coverager')).'
'."\n"; -//print xcache_get(); -/* -$cacheinfos = array(); -for ($i = 0; $i < 10; $i ++) -{ - $data = xcache_info(XC_TYPE_PHP, $i); - $data['cacheid'] = $i; - $cacheinfos[] = $data; -} - -var_dump($cacheinfos); - -if ($action == 'clear') -{ - xcache_clear_cache(); -} -*/ // End of page llxFooter(); diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index f257b040636..f902c3fb39b 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -99,6 +99,50 @@ if ($action == 'updateMask') { // par appel methode canBeActivated dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity); +} elseif ($action == 'setvarworkflow') { + $param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (GETPOSTISSET('product_category_id')) { + $param_ticket_product_category = GETPOST('product_category_id', 'int'); + $res = dolibarr_set_const($db, 'TICKET_PRODUCT_CATEGORY', $param_ticket_product_category, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + } + + $param_delay_first_response = GETPOST('delay_first_response', 'int'); + $res = dolibarr_set_const($db, 'TICKET_DELAY_BEFORE_FIRST_RESPONSE', $param_delay_first_response, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + $param_delay_between_responses = GETPOST('delay_between_responses', 'int'); + $res = dolibarr_set_const($db, 'TICKET_DELAY_SINCE_LAST_RESPONSE', $param_delay_between_responses, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + $param_auto_notify_close = GETPOST('TICKET_NOTIFY_AT_CLOSING', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_NOTIFY_AT_CLOSING', $param_auto_notify_close, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } } elseif ($action == 'setvar') { include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; @@ -146,50 +190,6 @@ if ($action == 'updateMask') { if (!($res > 0)) { $error++; } -} - -if ($action == 'setvarworkflow') { - $param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } -} - -if ($action == 'setvarworkflowother' || $action == 'setvarworkflow') { - $param_ticket_product_category = GETPOST('product_category_id', 'int'); - $res = dolibarr_set_const($db, 'TICKET_PRODUCT_CATEGORY', $param_ticket_product_category, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } -} - -if ($action == 'setvarother') { - $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - $param_disable_email = GETPOST('TICKET_DISABLE_NOTIFICATION_MAILS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_DISABLE_NOTIFICATION_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); @@ -198,34 +198,9 @@ if ($action == 'setvarother') { $error++; } } - - $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - $param_delay_first_response = GETPOST('delay_first_response', 'int'); - $res = dolibarr_set_const($db, 'TICKET_DELAY_BEFORE_FIRST_RESPONSE', $param_delay_first_response, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - $param_delay_between_responses = GETPOST('delay_between_responses', 'int'); - $res = dolibarr_set_const($db, 'TICKET_DELAY_SINCE_LAST_RESPONSE', $param_delay_between_responses, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - - $param_auto_notify_close = GETPOST('TICKET_NOTIFY_AT_CLOSING', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_NOTIFY_AT_CLOSING', $param_auto_notify_close, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } } - /* * View */ @@ -384,8 +359,8 @@ if ($resql) { print '
'; -print "\n"; -print "\n"; +print '
'."\n"; +print ''."\n"; print ''; print ''; print '\n"; @@ -502,13 +477,14 @@ foreach ($dirmodels as $reldir) { print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."
'; print '

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

'; -print '
'; -print ''; -print '
'; +print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition'); print ''; @@ -622,9 +585,10 @@ print load_fiche_titre($langs->trans("Notification"), '', ''); print ''; -print ''; +print ''; print ''; print ''; +print ''; print ''; print ''; @@ -699,7 +663,7 @@ print ''; print '
'.$langs->trans("Email").'
'; -print $formcategory->buttonsSaveCancel("Save", ''); +print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition'); print ''; diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 88a7db9b1d7..621eceb50a3 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -42,21 +42,24 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scandir', 'alpha'); $type = 'ticket'; -$error = 0; /* * Actions */ +$error = 0; +$errors = array(); if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { if (GETPOST('value')) { - dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); } else { - dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); } -} - -if ($action == 'setvar') { + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } +} elseif ($action == 'setvar') { include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; if (GETPOSTISSET('TICKET_ENABLE_PUBLIC_INTERFACE')) { // only for no js case @@ -64,14 +67,7 @@ if ($action == 'setvar') { $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; - } - } - - if (GETPOSTISSET('TICKET_EMAIL_MUST_EXISTS')) { // only for no js case - $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; + $errors[] = $db->lasterror(); } } @@ -80,6 +76,7 @@ if ($action == 'setvar') { $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } } @@ -88,6 +85,7 @@ if ($action == 'setvar') { $res = dolibarr_set_const($db, 'TICKET_SHOW_COMPANY_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } } @@ -99,6 +97,7 @@ if ($action == 'setvar') { } if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml'); @@ -109,6 +108,7 @@ if ($action == 'setvar') { } if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml'); @@ -119,6 +119,7 @@ if ($action == 'setvar') { } if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml'); @@ -129,6 +130,7 @@ if ($action == 'setvar') { } if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); @@ -139,12 +141,14 @@ if ($action == 'setvar') { } if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } $param_public_notification_new_message_default_email = GETPOST('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', $param_public_notification_new_message_default_email, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { @@ -152,10 +156,60 @@ if ($action == 'setvar') { $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; + $errors[] = $db->lasterror(); } } +} elseif (preg_match('/set_(.*)/', $action, $reg)) { + $code = $reg[1]; + $value = GETPOSTISSET($code) ? GETPOST($code, 'int') : 1; + $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } + + if (!$error) { + if ($code == 'TICKET_EMAIL_MUST_EXISTS') { + $res = dolibarr_del_const($db, 'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } + } elseif ($code == 'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST') { + $res = dolibarr_del_const($db, 'TICKET_EMAIL_MUST_EXISTS', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } + + // enable captcha by default + $res = dolibarr_set_const($db, 'MAIN_SECURITY_ENABLECAPTCHA', 1, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } + } + } +} elseif (preg_match('/del_(.*)/', $action, $reg)) { + $code = $reg[1]; + $res = dolibarr_del_const($db, $code, $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } } +if ($action != '') { + if (!$error) { + $db->commit(); + setEventMessage($langs->trans('SetupSaved')); + header("Location: " . $_SERVER['PHP_SELF']); + exit; + } else { + $db->rollback(); + setEventMessages('', $errors, 'errors'); + } +} /* @@ -180,7 +234,7 @@ $head = ticketAdminPrepareHead(); print dol_get_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket"); -print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php', 2).''; +print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php?entity='.$conf->entity, 2).''; print dol_get_fiche_end(); @@ -220,11 +274,10 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { // Check if email exists print '
'.$langs->trans("TicketsEmailMustExist").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); + if (empty(getDolGlobalInt('TICKET_EMAIL_MUST_EXISTS'))) { + print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); + print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; } print ''; @@ -232,6 +285,20 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print '
'.$langs->trans("TicketCreateThirdPartyWithContactIfNotExist").''; + if (empty(getDolGlobalInt('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST'))) { + print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; + } else { + print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketCreateThirdPartyWithContactIfNotExistHelp"), 1, 'help'); + print '
'; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 18ce707c839..4968e75989a 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -444,9 +444,9 @@ if ($mode == 'overwrite') { if ($mode == 'searchkey') { $nbempty = 0; - /*var_dump($langcode); - var_dump($transkey); - var_dump($transvalue);*/ + //var_dump($langcode); + //var_dump($transkey); + //var_dump($transvalue); if (empty($langcode) || $langcode == '-1') { $nbempty++; } diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 81ba8e3b09d..d4d652f3e74 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -568,10 +568,9 @@ class Documents extends DolibarrApi { global $db, $conf; - /*var_dump($modulepart); - var_dump($filename); - var_dump($filecontent); - exit;*/ + //var_dump($modulepart); + //var_dump($filename); + //var_dump($filecontent);exit; if (empty($modulepart)) { throw new RestException(400, 'Modulepart not provided.'); diff --git a/htdocs/api/index.php b/htdocs/api/index.php index c66573e8022..afb0289aa32 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -100,7 +100,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $url = $_SERVER['PHP_SELF']; if (preg_match('/api\/index\.php$/', $url)) { // sometimes $_SERVER['PHP_SELF'] is 'api\/index\.php' instead of 'api\/index\.php/explorer.php' or 'api\/index\.php/method' - $url = $_SERVER['PHP_SELF'].$_SERVER['PATH_INFO']; + $url = $_SERVER['PHP_SELF'].(empty($_SERVER['PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']); } // Fix for some NGINX setups (this should not be required even with NGINX, however setup of NGINX are often mysterious and this may help is such cases) if (!empty($conf->global->MAIN_NGINX_FIX)) { diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index c516866b7d0..d94ba613d91 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -408,7 +408,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $MAXEVENT = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/asset/agenda.php?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/asset/agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 19c15839231..410af398bc7 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -144,6 +144,7 @@ class Asset extends CommonObject public $fk_disposal_type; public $disposal_depreciated; public $disposal_subject_to_vat; + public $supplier_invoice_id; public $note_public; public $note_private; public $date_creation; diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index eae7b5d0fde..6390ad74c18 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -129,6 +129,7 @@ class AssetModel extends CommonObject public $import_key; public $model_pdf; public $status; + public $asset_depreciation_options; // /** // * @var string Field with ID of parent key if this object has a parent diff --git a/htdocs/asset/model/card.php b/htdocs/asset/model/card.php index 3e0858da55e..89843f0fc4e 100644 --- a/htdocs/asset/model/card.php +++ b/htdocs/asset/model/card.php @@ -315,7 +315,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // $MAXEVENT = 10; // - // $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id); + // $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id); // // // List of actions on element // include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index eb851af169a..e6f9ea0de15 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -92,11 +92,11 @@ function formatObject($objtoshow, $prefix) $s .= ''; $s .= ''; print ''; print ''; + print $langs->trans("Name").':'; + print ''; print '
'.($prefix ? $prefix.' > ' : '').$key.''; if (in_array($key, array('date', 'datef', 'dateh', 'datec', 'datem', 'datep'))) { - /*var_dump(is_object($val)); - var_dump(is_array($val)); - var_dump(is_array($val)); - var_dump(@get_class($val)); - var_dump($val);*/ + //var_dump(is_object($val)); + //var_dump(is_array($val)); + //var_dump(is_array($val)); + //var_dump(@get_class($val)); + //var_dump($val); $s .= dol_print_date($val, 'dayhour'); } else { $s .= $val; diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index 2b9c6f57bbd..4bc9095a57e 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -40,6 +40,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); +$socid = GETPOST('socid', 'int'); if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); @@ -79,7 +80,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->bom->multidir_output[$object->entity]."/".$object->id; + $upload_dir = (!empty($conf->bom->multidir_output[$object->entity]) ? $conf->bom->multidir_output[$object->entity] : $conf->bom->dir_output)."/".$object->id; } // Security check - Protection if external user diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 96fb68b6e9b..3de176a1995 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -742,7 +742,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $MAXEVENT = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/bom/bom_agenda.php?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/bom/bom_agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index 64f3cdbfac1..a0390ef5105 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -104,6 +104,7 @@ $form = new Form($db); $title = $langs->trans("BillOfMaterials").' - '.$langs->trans("Files"); $help_url = 'EN:Module_BOM'; +$morehtmlref = ""; llxHeader('', $title, $help_url); diff --git a/htdocs/bom/bom_net_needs.php b/htdocs/bom/bom_net_needs.php index 30cd6792c55..d08cce70382 100644 --- a/htdocs/bom/bom_net_needs.php +++ b/htdocs/bom/bom_net_needs.php @@ -34,6 +34,7 @@ $langs->loadLangs(array("mrp", "other", "stocks")); // Get parameters $id = GETPOST('id', 'int'); +$lineid = GETPOST('lineid', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); @@ -184,7 +185,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); - $viewlink = dolGetButtonTitle($langs->trans('GroupByProduct'), '', 'fa fa-list-alt imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&token='.newToken(), '', 1, array('morecss' => 'reposition '.($action !== 'treeview' ? 'btnTitleSelected':''))); + $viewlink = dolGetButtonTitle($langs->trans('GroupByProduct'), '', 'fa fa-bars imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&token='.newToken(), '', 1, array('morecss' => 'reposition '.($action !== 'treeview' ? 'btnTitleSelected':''))); $viewlink .= dolGetButtonTitle($langs->trans('TreeStructure'), '', 'fa fa-stream imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=treeview&token='.newToken(), '', 1, array('morecss' => 'reposition marginleftonly '.($action == 'treeview' ? 'btnTitleSelected':''))); print load_fiche_titre($langs->trans("BillOfMaterials"), $viewlink, 'cubes'); diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index 8ace40cc900..9984a1498b8 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -54,7 +54,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->bom->multidir_output[$object->entity]."/".$object->id; + $upload_dir = (!empty($conf->bom->multidir_output[$object->entity]) ? $conf->bom->multidir_output[$object->entity] : $conf->bom->dir_output)."/".$object->id; } $permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 86e07ed424d..fb7fd68e13a 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -916,27 +916,27 @@ class BOM extends CommonObject if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) { + if (!empty($obj->fk_user_author)) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) { + if (!empty($obj->fk_user_valid)) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) { + if (!empty($obj->fk_user_cloture)) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); + $this->date_modification = !empty($obj->datem) ? $this->db->jdate($obj->datem) : ""; + $this->date_validation = !empty($obj->datev) ? $this->db->jdate($obj->datev) : ""; } $this->db->free($result); @@ -1134,6 +1134,9 @@ class BOM extends CommonObject if (! empty($line->childBom)) { foreach ($line->childBom as $childBom) $childBom->getNetNeeds($TNetNeeds, $line->qty*$qty); } else { + if (empty($TNetNeeds[$line->fk_product])) { + $TNetNeeds[$line->fk_product] = 0; + } $TNetNeeds[$line->fk_product] += $line->qty*$qty; } } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 434b994ccd2..bf9442b82af 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -113,7 +113,7 @@ class Categorie extends CommonObject * * @todo Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_CAT_FK = array( + public $MAP_CAT_FK = array( 'customer' => 'soc', 'supplier' => 'soc', 'contact' => 'socpeople', @@ -125,7 +125,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_CAT_TABLE = array( + public $MAP_CAT_TABLE = array( 'customer' => 'societe', 'supplier' => 'fournisseur', 'bank_account'=> 'account', @@ -136,7 +136,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_OBJ_CLASS = array( + public $MAP_OBJ_CLASS = array( 'product' => 'Product', 'customer' => 'Societe', 'supplier' => 'Fournisseur', @@ -178,7 +178,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - protected $MAP_OBJ_TABLE = array( + public static $MAP_OBJ_TABLE = array( 'customer' => 'societe', 'supplier' => 'societe', 'member' => 'adherent', @@ -258,6 +258,12 @@ class Categorie extends CommonObject */ public $motherof = array(); + /** + * @var array Childs + */ + public $childs = array(); + + /** * Constructor * diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index f4456ed79bf..4a9e771416c 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -102,7 +102,8 @@ if (empty($nosearch)) { print ''.$langs->trans("Search").'
'; - print $langs->trans("Name").':
'; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index aa513e07794..737ff059eee 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -461,6 +461,13 @@ if (empty($reshook) && $action == 'add') { } } + // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page. + /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0'; + $moreparam .= ($moreparam ? '&' : '').'search_status=-1'; + $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid; + */ + $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1'; + if ($error) { $db->rollback(); } else { @@ -674,7 +681,7 @@ if (empty($reshook) && $action == 'update') { $object->errors[] = $object->error; } else { if ($db->num_rows($resql) > 0) { - // already in use + // Resource already in use $error++; $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; while ($obj = $db->fetch_object($resql)) { @@ -853,7 +860,7 @@ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { $object->errors[] = $object->error; } else { if ($db->num_rows($resql) > 0) { - // already in use + // Resource already in use $error++; $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; while ($obj = $db->fetch_object($resql)) { @@ -952,16 +959,17 @@ if ($action == 'create') { console.log("setdatefields"); setdatefields(); }); + $("#selectcomplete").change(function() { - if ($("#selectcomplete").val() == 100) - { + console.log("we change the complete status - set the doneby"); + if ($("#selectcomplete").val() == 100) { if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).'\'); } - if ($("#selectcomplete").val() == 0) - { + if ($("#selectcomplete").val() == 0) { $("#doneby").val(-1); } }); + $("#actioncode").change(function() { if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired"); else $("#dateend").removeClass("fieldrequired"); @@ -1019,59 +1027,15 @@ if ($action == 'create') { print 'global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Label").''; // Full day - print ''; + print ''.$langs->trans("Date").''; - $datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep)); - if (GETPOST('datep', 'int', 1)) { - $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuser'); - } - $datef = ($datef ? $datef : $object->datef); - if (GETPOST('datef', 'int', 1)) { - $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuser'); - } - if (empty($datef) && !empty($datep)) { - if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) { - $datef = dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h'); - } - } - - // Date start - print ''; - print ''.$langs->trans("DateActionStart").''; - print ' - '; - print ''.$langs->trans("DateActionEnd").''; - print ''; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); // Empty value not allowed for start date and hours if "todo" - } else { - print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); - } - print '     -     '; - //print ' - '; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); - } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); - } - print ''; - - // Date end - /*print ''; - print ''.$langs->trans("DateActionEnd").''; - print ''; - print ''; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); - } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); - } - print '';*/ - - // Dev in progress + // Recurring event $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); if ($userepeatevent) { // Repeat - print ''; + //print ''; + print '        
'; + print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); print ''; $selectedrecurrulefreq = 'no'; $selectedrecurrulebymonthday = ''; @@ -1120,34 +1084,51 @@ if ($action == 'create') { }); }); '; - print ''; + print '
'; + //print ''; } - // Status - print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - print ''; - $percent = $complete !=='' ? $complete : -1; - if (GETPOSTISSET('status')) { - $percent = GETPOST('status'); - } elseif (GETPOSTISSET('percentage')) { - $percent = GETPOST('percentage', 'int'); - } else { - if ($complete == '0' || GETPOST("afaire") == 1) { - $percent = '0'; - } elseif ($complete == 100 || GETPOST("afaire") == 2) { - $percent = 100; - } - } - $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { - print ''.$langs->trans("Location").''; + $datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep)); + if (GETPOST('datep', 'int', 1)) { + $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuser'); + } + $datef = ($datef ? $datef : $object->datef); + if (GETPOST('datef', 'int', 1)) { + $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuser'); + } + if (empty($datef) && !empty($datep)) { + if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) { + $datef = dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h'); + } } + // Date start + print ''; + /* + print ''.$langs->trans("DateActionStart").''; + print ' - '; + print ''.$langs->trans("DateActionEnd").''; + */ + print ''; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); // Empty value not allowed for start date and hours if "todo" + } else { + print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); + } + print '     -     '; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); + } else { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); + } + print ''; + + print ' '; + // Assigned to - print ''.$langs->trans("ActionAffectedTo").''; + print ''.$langs->trans("ActionAffectedTo").''; $listofuserid = array(); $listofcontactid = array(); $listofotherid = array(); @@ -1181,6 +1162,29 @@ if ($action == 'create') { print ''; } + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { + print ''.$langs->trans("Location").''; + } + + // Status + print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; + print ''; + $percent = $complete !=='' ? $complete : -1; + if (GETPOSTISSET('status')) { + $percent = GETPOST('status'); + } elseif (GETPOSTISSET('percentage')) { + $percent = GETPOST('percentage', 'int'); + } else { + if ($complete == '0' || GETPOST("afaire") == 1) { + $percent = '0'; + } elseif ($complete == 100 || GETPOST("afaire") == 2) { + $percent = 100; + } + } + $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); + print ''; + if ($conf->categorie->enabled) { // Categories print ''.$langs->trans("Categories").''; @@ -1523,6 +1527,7 @@ if ($id > 0) { if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''.$langs->trans("Type").''; if ($object->type_code != 'AC_OTH_AUTO') { + print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"'); print $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ? GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto", 0, 0, 0, 1); } else { print ''; @@ -1533,40 +1538,19 @@ if ($id > 0) { } // Title - print ''.$langs->trans("Title").''; + print 'global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Title").''; // Full day event - print ''.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>'; + print ''.$langs->trans("Date").'fulldayevent ? ' checked' : '').'>'; + print ''; - // Date start - end - print ''; - print ''.$langs->trans("DateActionStart").''; - print ' - '; - print 'type_code == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").''; - print ''; - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - if (GETPOST("afaire") == 1) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } else { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } - print ' - '; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } else { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } - print ''; - - // Dev in progress + // Recurring event $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); if ($userepeatevent) { // Repeat - print ''; + //print ''; + print '        
'; + print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); print ''; $selectedrecurrulefreq = 'no'; $selectedrecurrulebymonthday = ''; @@ -1615,19 +1599,37 @@ if ($id > 0) { }); }); '; - print ''; + print '
'; + //print ''; } - - // Status - print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - $percent = GETPOSTISSET("percentage") ? GETPOST("percentage", "int") : $object->percentage; - $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { - print ''.$langs->trans("Location").''; + // Date start - end + print ''; + /*print ''.$langs->trans("DateActionStart").''; + print ' - '; + print 'type_code == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").''; + */ + print ''; + $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); + if (GETPOST("afaire") == 1) { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + } else { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); } + print '     -     '; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + } else { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); + } + print ''; + + print ' '; // Assigned to $listofuserid = array(); // User assigned @@ -1678,6 +1680,18 @@ if ($id > 0) { print $form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1, 'doneby', 1); print ''; } + + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { + print ''.$langs->trans("Location").''; + } + + // Status + print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; + $percent = GETPOSTISSET("percentage") ? GETPOST("percentage", "int") : $object->percentage; + $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); + print ''; + // Tags-Categories if ($conf->categorie->enabled) { print ''.$langs->trans("Categories").''; @@ -1786,7 +1800,7 @@ if ($id > 0) { print ''.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', $object->note_private, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor('note', $object->note_private, '', 120, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); $doleditor->Create(); print ''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9d122cfce7e..aeb20e6c7b4 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1598,7 +1598,7 @@ class ActionComm extends CommonObject //$tooltip .= '
'.img_picto('', 'email').' '.$langs->trans("Email").''; $tooltip .= '
'.$langs->trans('MailTopic').': '.$this->email_subject; $tooltip .= '
'.$langs->trans('MailFrom').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_from); - $tooltip .= '
'.$langs->trans('MailTo').':, '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_to); + $tooltip .= '
'.$langs->trans('MailTo').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_to); if (!empty($this->email_tocc)) { $tooltip .= '
'.$langs->trans('MailCC').': '.str_replace(array('<', '>'), array('&lt', '&gt'), $this->email_tocc); } @@ -1621,7 +1621,7 @@ class ActionComm extends CommonObject $label = $langs->trans("ShowAction"); $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, 0, '', 1).'"'; + $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1, 0, '', 1).'"'; $linkclose .= ' class="'.$classname.' classfortooltip"'; /* $hookmanager->initHooks(array('actiondao')); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 4f8b8509f4e..dee6c459433 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -49,6 +49,8 @@ if (empty($conf->global->AGENDA_EXT_NB)) { } $MAXAGENDA = $conf->global->AGENDA_EXT_NB; +$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); + $check_holiday = GETPOST('check_holiday', 'int'); $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); @@ -110,7 +112,7 @@ $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); $pid = GETPOST("search_projectid", "int", 3) ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo' -$type = GETPOSTISSET("search_type", 'aZ09') ? GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09'); +$type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09'); $maxprint = GETPOSTISSET("maxprint") ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW; $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -128,14 +130,11 @@ if (GETPOST('search_actioncode', 'array:aZ09')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} -if ($actioncode == '' && empty($actioncodearray)) { - $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($status == '' && !GETPOSTISSET('search_status')) { - $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + $status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } $defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); @@ -1191,7 +1190,8 @@ if (count($listofextcals)) { foreach ($icalevents as $icalevent) { //var_dump($icalevent); - //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'
';exit; + //print $icalevent['SUMMARY'].'->'; + //var_dump($icalevent);exit; if (!empty($icalevent['RRULE'])) { continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. } diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 86b8a3b5ce5..7d8861aded3 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -45,6 +45,11 @@ $langs->loadLangs(array("users", "companies", "agenda", "commercial", "other", " $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search +$optioncss = GETPOST('optioncss', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$confirm = GETPOST('confirm', 'alpha'); + +$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); $mode = GETPOST('mode', 'aZ09'); if (empty($mode) && preg_match('/show_/', $action)) { @@ -54,12 +59,9 @@ $resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", $pid = GETPOST("search_projectid", 'int', 3) ?GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3); $search_status = (GETPOST("search_status", 'aZ09') != '') ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); $type = GETPOST('search_type', 'alphanohtml') ?GETPOST('search_type', 'alphanohtml') : GETPOST('type', 'alphanohtml'); -$optioncss = GETPOST('optioncss', 'alpha'); $year = GETPOST("year", 'int'); $month = GETPOST("month", 'int'); $day = GETPOST("day", 'int'); -$toselect = GETPOST('toselect', 'array'); -$confirm = GETPOST('confirm', 'alpha'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { @@ -68,11 +70,9 @@ if (GETPOST('search_actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} -if ($actioncode == '' && empty($actioncodearray)) { - $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } + $search_id = GETPOST('search_id', 'alpha'); $search_title = GETPOST('search_title', 'alpha'); $search_note = GETPOST('search_note', 'alpha'); @@ -83,7 +83,7 @@ $datestart_dtend = dol_mktime(23, 59, 59, GETPOST('datestart_dtendmonth', 'int') $dateend_dtstart = dol_mktime(0, 0, 0, GETPOST('dateend_dtstartmonth', 'int'), GETPOST('dateend_dtstartday', 'int'), GETPOST('dateend_dtstartyear', 'int'), 'tzuserrel'); $dateend_dtend = dol_mktime(23, 59, 59, GETPOST('dateend_dtendmonth', 'int'), GETPOST('dateend_dtendday', 'int'), GETPOST('dateend_dtendyear', 'int'), 'tzuserrel'); if ($search_status == '' && !GETPOSTISSET('search_status')) { - $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + $search_status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } if (empty($mode) && !GETPOSTISSET('mode')) { $mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); @@ -216,7 +216,14 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $datestart_dtend = ''; $dateend_dtstart = ''; $dateend_dtend = ''; + $actioncode = ''; $search_status = ''; + $pid = ''; + $socid = ''; + $resourceid = ''; + $filter = ''; + $filtert = ''; + $usergroup = ''; $toselect = array(); $search_array_options = array(); } @@ -299,7 +306,7 @@ if ($actioncode != '') { if ($resourceid > 0) { $param .= "&search_resourceid=".urlencode($resourceid); } -if ($search_status != '' && $search_status > -1) { +if ($search_status != '') { $param .= "&search_status=".urlencode($search_status); } if ($filter) { diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 9869bd2d305..d4e005ae3e5 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -45,6 +45,8 @@ if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { $action = GETPOST('action', 'aZ09'); +$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); + $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); @@ -110,10 +112,7 @@ if (GETPOST('search_actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} -if ($actioncode == '' && empty($actioncodearray)) { - $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); @@ -145,7 +144,7 @@ $begin_d = 1; $end_d = 53; if ($status == '' && !GETPOSTISSET('search_status')) { - $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + $status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } if (empty($mode) && !GETPOSTISSET('mode')) { $mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); @@ -961,7 +960,9 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); $nextindextouse = count($colorindexused); // At first run, this is 0, so fist user has 0, next 1, ... - //if ($username->id && $day==1) var_dump($eventarray); + //if ($username->id && $day==1) { + //var_dump($eventarray); + //} // We are in a particular day for $username, now we scan all events foreach ($eventarray as $daykey => $notused) { diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 68c9088815d..b9e190729e0 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -45,6 +45,8 @@ if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { $action = GETPOST('action', 'aZ09'); +$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); + $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); @@ -110,10 +112,7 @@ if (GETPOST('search_actioncode', 'array:aZ09')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} -if ($actioncode == '' && empty($actioncodearray)) { - $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); @@ -154,7 +153,7 @@ if ($end_d < $begin_d) { } if ($status == '' && !GETPOSTISSET('search_status')) { - $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + $status = ((empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } if (empty($mode) && !GETPOSTISSET('mode')) { @@ -1130,7 +1129,9 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 $nextindextouse = count($colorindexused); // At first run this is 0, so first user has 0, next 1, ... - //if ($username->id && $day==1) var_dump($eventarray); + //if ($username->id && $day==1) { + //var_dump($eventarray); + //} // We are in a particular day for $username, now we scan all events foreach ($eventarray as $daykey => $notused) { diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index dafc1e7ee16..5903b7e4bdb 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -634,7 +634,11 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { print $s; print ''; - print ''.dol_print_date($db->jdate($objp->tms), 'day').''; + + $datem = $db->jdate($objp->tms); + print ''; + print dol_print_date($datem, 'day', 'tzuserrel'); + print ''; print ''; $i++; @@ -725,7 +729,11 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S print $s; print ''; - print ''.dol_print_date($db->jdate($objp->dm), 'day').''; + + $datem = $db->jdate($objp->dm); + print ''; + print dol_print_date($datem, 'day', 'tzuserrel'); + print ''; print ''; $i++; @@ -922,7 +930,10 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { print ''; print ''.$companystatic->getNomUrl(1, 'customer', 44).''; - print ''.dol_print_date($db->jdate($obj->dp), 'day').''; + $datem = $db->jdate($obj->dp); + print ''; + print dol_print_date($datem, 'day', 'tzserver'); + print ''; print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; print ''.$propalstatic->LibStatut($obj->fk_statut, 3).''; @@ -1039,7 +1050,11 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { print ''; print ''.$companystatic->getNomUrl(1, 'customer', 44).''; - print ''.dol_print_date($db->jdate($obj->dv), 'day').''; + $datem = $db->jdate($obj->dv); + print ''; + print dol_print_date($datem, 'day', 'tzserver'); + print ''; + print ''.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).''; print ''.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).''; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index f82df06313b..b3d3dd25e90 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -961,7 +961,7 @@ if ($action == 'create') { if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) { print "\n\n
\n"; - if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id)) { + if (($object->statut == 1) && ($user->rights->mailing->valider || $object->user_validation == $user->id)) { print ''.$langs->trans("SetToDraft").''; } @@ -1066,7 +1066,7 @@ if ($action == 'create') { print dol_get_fiche_end(); - print dol_set_focus('#sendto'); + dol_set_focus('#sendto'); } diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 588faa392e3..0c2bf539384 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -86,6 +86,11 @@ class Mailing extends CommonObject */ public $email_from; + /** + * @var string email to + */ + public $sendto; + /** * @var string email reply to */ @@ -175,6 +180,11 @@ class Mailing extends CommonObject */ public $statuts = array(); + /** + * @var array substitutionarray + */ + public $substitutionarray; + /** * Constructor diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 229919d7e5d..22a816acc1d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -692,7 +692,7 @@ if (empty($reshook)) { $deposit = null; $locationTarget = ''; - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if ( !$error && GETPOST('statut', 'int') == $object::STATUS_SIGNED && GETPOST('generate_deposit', 'alpha') == 'on' @@ -1999,7 +1999,7 @@ if ($action == 'create') { array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace) ); - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if (! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)) { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 59a03f78bb2..258e264c5a7 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -135,8 +135,13 @@ class Proposals extends DolibarrApi } // Add external contacts ids. - $this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->propal->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->propal->contacts_ids = $tmparray; + } + $this->propal->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->propal); } @@ -228,7 +233,10 @@ class Proposals extends DolibarrApi $proposal_static = new Propal($this->db); if ($proposal_static->fetch($obj->rowid)) { // Add external contacts ids - $proposal_static->contacts_ids = $proposal_static->liste_contact(-1, 'external', 1); + $tmparray = $proposal_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $proposal_static->contacts_ids = $tmparray; + } $obj_ret[] = $this->_cleanObjectDatas($proposal_static); } $i++; @@ -519,7 +527,9 @@ class Proposals extends DolibarrApi isset($request_data->date_end) ? $request_data->date_end : $propalline->date_end, isset($request_data->array_options) ? $request_data->array_options : $propalline->array_options, isset($request_data->fk_unit) ? $request_data->fk_unit : $propalline->fk_unit, - isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice + isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice, + 0, + isset($request_data->rang) ? $request_data->rang : $propalline->rang ); if ($updateRes > 0) { @@ -643,7 +653,7 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $contacts = $this->invoice->liste_contact(); + $contacts = $this->propal->liste_contact(); foreach ($contacts as $contact) { if ($contact['id'] == $contactid && $contact['code'] == $type) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0d7c301f7b0..73e73fbe2f9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -296,8 +296,8 @@ class Propal extends CommonObject 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>20), 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>22), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>40), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>23), - 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>24), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'position'=>23), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>'$conf->projet->enabled', 'visible'=>-1, 'position'=>24), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>55), 'datep' =>array('type'=>'date', 'label'=>'Date', 'enabled'=>1, 'visible'=>-1, 'position'=>60), @@ -317,7 +317,7 @@ class Propal extends CommonObject 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LocalTax1', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LocalTax2', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1), - 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>1, 'visible'=>-1, 'position'=>150), + 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>'$conf->banque->enabled', 'visible'=>-1, 'position'=>150), 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'Currency', 'enabled'=>1, 'visible'=>-1, 'position'=>155), 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>160), 'deposit_percent' =>array('type'=>'varchar(63)', 'label'=>'DepositPercent', 'enabled'=>1, 'visible'=>-1, 'position'=>161), @@ -327,7 +327,7 @@ class Propal extends CommonObject 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>180), 'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>185), 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>190), - 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>191), + 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>'$conf->stock->enabled', 'visible'=>-1, 'position'=>191), 'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>195), 'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated 'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>205), @@ -490,7 +490,6 @@ class Propal extends CommonObject $line->subprice = -$remise->amount_ht; $line->fk_product = 0; // Id produit predefined $line->qty = 1; - $line->remise = 0; $line->remise_percent = 0; $line->rang = -1; $line->info_bits = 2; @@ -736,7 +735,6 @@ class Propal extends CommonObject // TODO deprecated $this->line->price = $price; - $this->line->remise = $remise; if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; @@ -806,9 +804,10 @@ class Propal extends CommonObject * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in currency * @param int $notrigger disable line update trigger + * @param integer $rang line rank * @return int 0 if OK, <0 if KO */ - public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $rang = 0) { global $mysoc, $langs; @@ -894,6 +893,7 @@ class Propal extends CommonObject $line->oldline = $staticline; $this->line = $line; $this->line->context = $this->context; + $this->line->rang = $rang; // Reorder if fk_parent_line change if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { @@ -934,7 +934,6 @@ class Propal extends CommonObject // TODO deprecated $this->line->price = $price; - $this->line->remise = $remise; if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options @@ -1518,6 +1517,7 @@ class Propal extends CommonObject $sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql .= ", p.total_ttc, p.total_tva, p.localtax1, p.localtax2, p.total_ht"; $sql .= ", p.datec"; + $sql .= ", p.date_signature as dates"; $sql .= ", p.date_valid as datev"; $sql .= ", p.datep as dp"; $sql .= ", p.fin_validite as dfv"; @@ -1601,6 +1601,7 @@ class Propal extends CommonObject $this->date_creation = $this->db->jdate($obj->datec); //Creation date $this->date_validation = $this->db->jdate($obj->datev); //Validation date $this->date_modification = $this->db->jdate($obj->date_modification); // tms + $this->date_signature = $this->db->jdate($obj->dates); // Signature date $this->date = $this->db->jdate($obj->dp); // Proposal date $this->datep = $this->db->jdate($obj->dp); // deprecated $this->fin_validite = $this->db->jdate($obj->dfv); @@ -1898,14 +1899,15 @@ class Propal extends CommonObject // multilangs if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($objp->fk_product); + $tmpproduct->getMultiLangs(); + + $line->multilangs = $tmpproduct->multilangs; } $this->lines[$i] = $line; - //dol_syslog("1 ".$line->fk_product); - //print "xx $i ".$this->lines[$i]->fk_product; + $i++; } @@ -3991,6 +3993,7 @@ class PropaleLigne extends CommonObjectLine public $multicurrency_total_tva; public $multicurrency_total_ttc; + /** * Class line Contructor * @@ -4130,9 +4133,6 @@ class PropaleLigne extends CommonObjectLine if (empty($this->rang)) { $this->rang = 0; } - if (empty($this->remise)) { - $this->remise = 0; - } if (empty($this->remise_percent) || !is_numeric($this->remise_percent)) { $this->remise_percent = 0; } @@ -4362,9 +4362,6 @@ class PropaleLigne extends CommonObjectLine if (empty($this->price)) { $this->price = 0; // TODO A virer } - if (empty($this->remise)) { - $this->remise = 0; // TODO A virer - } if (empty($this->remise_percent)) { $this->remise_percent = 0; } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index eb5b310edd1..d59505e5fb7 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -377,14 +377,14 @@ if ($action == 'validate' && $permissiontovalidate) { if ($tmpproposal->fetch($checked) > 0) { if ($tmpproposal->statut == $tmpproposal::STATUS_DRAFT) { if ($tmpproposal->valid($user) > 0) { - setEventMessage($langs->trans('hasBeenValidated', $tmpproposal->ref), 'mesgs'); + setEventMessages($langs->trans('hasBeenValidated', $tmpproposal->ref), null, 'mesgs'); } else { - setEventMessage($tmpproposal->error, $tmpproposal->errors, 'errors'); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } else { $langs->load("errors"); - setEventMessage($langs->trans('ErrorIsNotADraft', $tmpproposal->ref), 'errors'); + setEventMessages($langs->trans('ErrorIsNotADraft', $tmpproposal->ref), null, 'errors'); $error++; } } else { @@ -410,7 +410,7 @@ if ($action == "sign" && $permissiontoclose) { if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) { $tmpproposal->statut = $tmpproposal::STATUS_SIGNED; if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_SIGNED) >= 0) { - setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs'); + setEventMessages($tmpproposal->ref." ".$langs->trans('Signed'), null, 'mesgs'); } else { setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; @@ -765,12 +765,12 @@ if ($resql) { if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfProposals').' - '.$soc->name; + $title = $langs->trans('Proposals').' - '.$soc->name; if (empty($search_societe)) { $search_societe = $soc->name; } } else { - $title = $langs->trans('ListOfProposals'); + $title = $langs->trans('Proposals'); } $num = $db->num_rows($resql); @@ -2133,7 +2133,7 @@ if ($resql) { $totalarray['nbfield']++; } - print "\n"; + print ''."\n"; $i++; } @@ -2141,6 +2141,17 @@ if ($resql) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + // If no record found + if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; + } + $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6ba7b9086c3..f1423ffa12b 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1184,7 +1184,7 @@ if (empty($reshook)) { $error = 0; $deposit = null; - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if ( GETPOST('generate_deposit', 'alpha') == 'on' && ! empty($deposit_percent_from_payment_terms) @@ -1733,10 +1733,10 @@ if ($action == 'create' && $usercancreate) { $form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx'); print ''; - // Terms of the settlement + // Terms of payment print ''.$langs->trans('PaymentConditionsShort').''; - print img_picto('', 'paiment', 'class="pictofixedwidth"'); - $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', $deposit_percent); + print img_picto('', 'payment', 'class="pictofixedwidth"'); + $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); print ''; // Payment mode @@ -1836,7 +1836,7 @@ if ($action == 'create' && $usercancreate) { print ''; print ''.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; print ''; - print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print img_picto('', 'currency', 'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0, '', false, 'maxwidth200 widthcentpercentminusx'); print ''; } @@ -2025,7 +2025,7 @@ if ($action == 'create' && $usercancreate) { if ($nbMandated > 0 ) $text .= '
'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'
'; - $deposit_percent_from_payment_terms = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $object->cond_reglement_id); + $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); if (! empty($deposit_percent_from_payment_terms) && ! empty($conf->facture->enabled) && ! empty($user->rights->facture->creer)) { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 17528001d1b..ac9ce98777d 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -133,7 +133,10 @@ class Orders extends DolibarrApi } // Add external contacts ids - $this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->commande->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->commande->contacts_ids = $tmparray; + } $this->commande->fetchObjectLinked(); // Add online_payment_url, cf #20477 @@ -234,7 +237,10 @@ class Orders extends DolibarrApi $commande_static = new Commande($this->db); if ($commande_static->fetch($obj->rowid)) { // Add external contacts ids - $commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1); + $tmparray = $commande_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $commande_static->contacts_ids = $tmparray; + } // Add online_payment_url, cf #20477 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; $commande_static->online_payment_url = getOnlinePaymentUrl(0, 'order', $commande_static->ref); @@ -439,7 +445,8 @@ class Orders extends DolibarrApi $request_data->fk_unit, $request_data->multicurrency_subprice, 0, - $request_data->ref_ext + $request_data->ref_ext, + $request_data->rang ); if ($updateRes > 0) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ca149d1f681..a7d237bc780 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -313,8 +313,8 @@ class Commande extends CommonOrder 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>26), 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>27), // deprecated 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>28), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), - 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>20), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>'$conf->projet->enabled', 'visible'=>-1, 'position'=>25), 'date_commande' =>array('type'=>'date', 'label'=>'Date', 'enabled'=>1, 'visible'=>1, 'position'=>60), 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>62), 'date_cloture' =>array('type'=>'datetime', 'label'=>'DateClosing', 'enabled'=>1, 'visible'=>-1, 'position'=>65), @@ -334,14 +334,14 @@ class Commande extends CommonOrder 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>155), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>160), //'facture' =>array('type'=>'tinyint(4)', 'label'=>'ParentInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>165), - 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>1, 'visible'=>-1, 'position'=>170), + 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>'$conf->banque->enabled', 'visible'=>-1, 'position'=>170), 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'MulticurrencyID', 'enabled'=>1, 'visible'=>-1, 'position'=>175), 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>180), 'deposit_percent' =>array('type'=>'varchar(63)', 'label'=>'DepositPercent', 'enabled'=>1, 'visible'=>-1, 'position'=>181), 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>185), 'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>190), 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>195), - 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>200), + 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>'$conf->stock->enabled', 'visible'=>-1, 'position'=>200), 'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>205), 'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>210), //'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>-1, 'position'=>215), @@ -1666,7 +1666,6 @@ class Commande extends CommonOrder // TODO Ne plus utiliser $this->line->price = $price; - $this->line->remise = $remise; if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; @@ -2010,7 +2009,6 @@ class Commande extends CommonOrder $line->price = -$remise->amount_ht; $line->fk_product = 0; // Id produit predefini $line->qty = 1; - $line->remise = 0; $line->remise_percent = 0; $line->rang = -1; $line->info_bits = 2; @@ -2154,9 +2152,11 @@ class Commande extends CommonOrder // multilangs if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($objp->fk_product); + $tmpproduct->getMultiLangs(); + + $line->multilangs = $tmpproduct->multilangs; } $this->lines[$i] = $line; @@ -3087,9 +3087,10 @@ class Commande extends CommonOrder * @param double $pu_ht_devise Amount in currency * @param int $notrigger disable line update trigger * @param string $ref_ext external reference + * @param integer $rang line rank * @return int < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '') + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) { global $conf, $mysoc, $langs, $user; @@ -3214,6 +3215,7 @@ class Commande extends CommonOrder $line->oldline = $staticline; $this->line = $line; $this->line->context = $this->context; + $this->line->rang = $rang; // Reorder if fk_parent_line change if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { @@ -3260,7 +3262,6 @@ class Commande extends CommonOrder // TODO deprecated $this->line->price = $price; - $this->line->remise = $remise; if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options @@ -4402,9 +4403,6 @@ class OrderLine extends CommonOrderLine if (empty($this->rang)) { $this->rang = 0; } - if (empty($this->remise)) { - $this->remise = 0; - } if (empty($this->remise_percent)) { $this->remise_percent = 0; } @@ -4445,7 +4443,7 @@ class OrderLine extends CommonOrderLine $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet'; $sql .= ' (fk_commande, fk_parent_line, label, description, qty, ref_ext,'; $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; - $sql .= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,'; + $sql .= ' fk_product, product_type, remise_percent, subprice, price, fk_remise_except,'; $sql .= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,'; $sql .= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,'; $sql .= ' fk_unit'; @@ -4468,7 +4466,6 @@ class OrderLine extends CommonOrderLine $sql .= " '".price2num($this->remise_percent)."',"; $sql .= " ".(price2num($this->subprice) !== '' ?price2num($this->subprice) : "null").","; $sql .= " ".($this->price != '' ? "'".price2num($this->price)."'" : "null").","; - $sql .= " '".price2num($this->remise)."',"; $sql .= ' '.(!empty($this->fk_remise_except) ? $this->fk_remise_except : "null").','; $sql .= ' '.((int) $this->special_code).','; $sql .= ' '.((int) $this->rang).','; @@ -4577,9 +4574,6 @@ class OrderLine extends CommonOrderLine if (empty($this->marge_tx)) { $this->marge_tx = 0; } - if (empty($this->remise)) { - $this->remise = 0; - } if (empty($this->remise_percent)) { $this->remise_percent = 0; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index b2bf9615d17..5d4dce6872d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1015,12 +1015,12 @@ if ($resql) { if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfOrders').' - '.$soc->name; + $title = $langs->trans('CustomersOrders').' - '.$soc->name; if (empty($search_company)) { $search_company = $soc->name; } } else { - $title = $langs->trans('ListOfOrders'); + $title = $langs->trans('CustomersOrders'); } if (strval($search_status) == '0') { $title .= ' - '.$langs->trans('StatusOrderDraftShort'); diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index cdcd26490a3..77aded9c594 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -165,7 +165,7 @@ class PaymentVarious extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; $this->element = 'payment_various'; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index bc70d27ba70..3cde5212e2d 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -52,11 +52,12 @@ if (!empty($conf->salaries->enabled)) { $id = GETPOST('rowid', 'int'); -$accountid = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int')); +$rowid = GETPOST("rowid", 'int'); +$accountoldid = GETPOST('account', 'int'); // GETPOST('account') is old account id +$accountid = GETPOST('accountid', 'int'); // GETPOST('accountid') is new account id $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -$rowid = GETPOST("rowid", 'int'); $orig_account = GETPOST("orig_account"); $backtopage = GETPOST('backtopage', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -69,7 +70,7 @@ if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'banque', $accountid, 'bank_account'); +$result = restrictedArea($user, 'banque', $accountoldid, 'bank_account'); if (empty($user->rights->banque->lire) && empty($user->rights->banque->consolidate)) { accessforbidden(); } @@ -124,18 +125,26 @@ if ($user->rights->banque->modifier && $action == "update") { $error = 0; $acline = new AccountLine($db); - $acline->fetch($rowid); + $result = $acline->fetch($rowid); + if ($result <= 0) { + dol_syslog('Failed to read bank line with id '.$rowid, LOG_WARNING); // This happens due to old bug that has set fk_account to null. + $acline->id = $rowid; + } $acsource = new Account($db); - $acsource->fetch($id); + $acsource->fetch($accountoldid); $actarget = new Account($db); if (GETPOST('accountid', 'int') > 0 && !$acline->rappro && !$acline->getVentilExportCompta()) { // We ask to change bank account $actarget->fetch(GETPOST('accountid', 'int')); } else { - $actarget->fetch($id); + $actarget->fetch($accountoldid); } + if (!($actarget->id > 0)) { + setEventMessages($langs->trans("ErrorFailedToLoadBankAccount"), null, 'errors'); + $error++; + } if ($actarget->courant == Account::TYPE_CASH && GETPOST('value', 'alpha') != 'LIQ') { setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors'); $error++; @@ -229,7 +238,7 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql .= " SET num_releve=".($num_rel ? "'".$db->escape($num_rel)."'" : "null"); + $sql .= " SET num_releve = ".($num_rel ? "'".$db->escape($num_rel)."'" : "null"); if (empty($num_rel)) { $sql .= ", rappro = 0"; } else { @@ -307,7 +316,6 @@ if ($result) { print ''; print ''; print ''; - print ''; print dol_get_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0); @@ -326,11 +334,12 @@ if ($result) { // Bank account print ''.$langs->trans("Account").''; print ''; - if (!$objp->rappro && !$bankline->getVentilExportCompta()) { - print img_picto('', 'bank_account', 'class="paddingright"'); - print $form->select_comptes($acct->id, 'accountid', 0, '', 0, '', 0, '', 1); - } else { + // $objp->fk_account may be not > 0 if data was lost by an old bug. In such a case, we let a chance to user to fix it. + if (($objp->rappro || $bankline->getVentilExportCompta()) && $objp->fk_account > 0) { print $acct->getNomUrl(1, 'transactions', 'reflabel'); + } else { + print img_picto('', 'bank_account', 'class="paddingright"'); + print $form->select_comptes($acct->id, 'accountid', 0, '', ($acct->id > 0 ? $acct->id : 1), '', 0, '', 1); } print ''; print ''; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 19b47430fad..90bc79483bf 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -534,7 +534,7 @@ foreach ($accounts as $key => $type) { // Ref if (!empty($arrayfields['b.ref']['checked'])) { - print ''.$objecttmp->getNomUrl(1).''; + print ''.$objecttmp->getNomUrl(1).''; if (!$i) { $totalarray['nbfield']++; } @@ -586,7 +586,7 @@ foreach ($accounts as $key => $type) { // Accountancy journal if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { - print ''; + print ''; if (!empty($conf->accounting->enabled)) { if (empty($objecttmp->fk_accountancy_journal)) { print img_warning($langs->trans("Mandatory")); @@ -606,7 +606,7 @@ foreach ($accounts as $key => $type) { // Currency if (!empty($arrayfields['b.currency_code']['checked'])) { - print ''; + print ''; print $objecttmp->currency_code; print ''; if (!$i) { @@ -616,7 +616,7 @@ foreach ($accounts as $key => $type) { // Transactions to reconcile if (!empty($arrayfields['toreconcile']['checked'])) { - print ''; + print ''; $conciliate = $objecttmp->canBeConciliated(); if ($conciliate == -2) { @@ -663,7 +663,7 @@ foreach ($accounts as $key => $type) { print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['b.datec']['checked'])) { - print ''; + print ''; print dol_print_date($objecttmp->date_creation, 'dayhour'); print ''; if (!$i) { @@ -672,7 +672,7 @@ foreach ($accounts as $key => $type) { } // Date modification if (!empty($arrayfields['b.tms']['checked'])) { - print ''; + print ''; print dol_print_date($objecttmp->date_update, 'dayhour'); print ''; if (!$i) { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index bbec4f23fc6..98cb0e27804 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -40,7 +40,6 @@ $socid = GETPOST("socid", "int"); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'banque', '', '', ''); $optioncss = GETPOST('optioncss', 'alpha'); @@ -173,6 +172,11 @@ $arrayfields = array( $arrayfields = dol_sort_array($arrayfields, 'position'); +$object = new PaymentVarious($db); + +$result = restrictedArea($user, 'banque', '', '', ''); + + /* * Actions */ @@ -271,19 +275,19 @@ if ($search_all) { $sql .= $db->order($sortfield, $sortorder); $totalnboflines = 0; -$result = $db->query($sql); -if ($result) { - $totalnboflines = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $totalnboflines = $db->num_rows($resql); } $sql .= $db->plimit($limit + 1, $offset); -$result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); // Direct jump if only one record found if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$id); exit; @@ -535,13 +539,13 @@ if ($result) { $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch center '); print ''; $totalarray = array(); while ($i < min($num, $limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); $variousstatic->id = $obj->rowid; $variousstatic->ref = $obj->rowid; @@ -652,7 +656,7 @@ if ($result) { if ($arrayfields['account']['checked']) { $accountingaccount->fetch('', $obj->accountancy_code, 1); - print ''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''; + print ''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''; if (!$i) { $totalarray['nbfield']++; } @@ -660,7 +664,7 @@ if ($result) { // Accounting subledger account if ($arrayfields['subledger']['checked']) { - print ''.length_accounta($obj->subledger_account).''; + print ''.length_accounta($obj->subledger_account).''; if (!$i) { $totalarray['nbfield']++; } @@ -704,7 +708,7 @@ if ($result) { $totalarray['nbfield']++; } - print ""; + print ''."\n"; $i++; } @@ -712,11 +716,27 @@ if ($result) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - print ""; - print '
'; - print ''; + // If no record found + if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; + } - $db->free($result); + $db->free($resql); + + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print ''."\n"; + print ''."\n"; + + print ''."\n"; } else { dol_print_error($db); } diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index e05750918da..c09943540bc 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -121,7 +121,7 @@ class Deplacement extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 9f92cecc4a7..2aa03441e9b 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -158,7 +158,7 @@ if ($resql) { print ''; } print ''; - $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); + print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 5); print ''; print ''; print ''; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 6300e387067..39b8c16614d 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1695,7 +1695,20 @@ if ($action == 'create') { $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print ''; + print ''; + print '
'; + + $MAXEVENT = 10; + + //$morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); + + print '
'; + print ''; } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e3fac863c77..f2e57c8b536 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -305,7 +305,7 @@ if (empty($reshook)) { $object->fetch($id); if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { - $last_of_type = $object->willBeLastOfSameType(); + $last_of_type = $object->willBeLastOfSameType(true); if (empty($object->date_validation) && !$last_of_type[0]) { setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref, dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors'); $action = ''; @@ -3290,7 +3290,7 @@ if ($action == 'create') { $typedeposit = GETPOST('typedeposit', 'aZ09'); $valuedeposit = GETPOST('valuedeposit', 'int'); if (empty($typedeposit) && ! empty($objectsrc->deposit_percent)) { - $origin_payment_conditions_deposit_percent = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $objectsrc->cond_reglement_id); + $origin_payment_conditions_deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $objectsrc->cond_reglement_id); if (! empty($origin_payment_conditions_deposit_percent)) { $typedeposit = 'variable'; } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 3623a36cbb9..3dababa3dc3 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -148,7 +148,10 @@ class Invoices extends DolibarrApi // Add external contacts ids if ($contact_list > -1) { - $this->invoice->contacts_ids = $this->invoice->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->invoice->liste_contact(-1, 'external', $contact_list); + if(is_array($tmparray)) { + $this->invoice->contacts_ids = $tmparray; + } } $this->invoice->fetchObjectLinked(); @@ -267,8 +270,10 @@ class Invoices extends DolibarrApi $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); // Add external contacts ids - $invoice_static->contacts_ids = $invoice_static->liste_contact(-1, 'external', 1); - + $tmparray = $invoice_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $invoice_static->contacts_ids = $tmparray; + } $obj_ret[] = $this->_cleanObjectDatas($invoice_static); } $i++; @@ -451,7 +456,8 @@ class Invoices extends DolibarrApi $request_data->fk_unit, $request_data->multicurrency_subprice, 0, - $request_data->ref_ext + $request_data->ref_ext, + $request_data->rang ); if ($updateRes > 0) { @@ -1767,7 +1773,10 @@ class Invoices extends DolibarrApi // Add external contacts ids if ($contact_list > -1) { - $this->template_invoice->contacts_ids = $this->template_invoice->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->template_invoice->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->template_invoice->contacts_ids = $tmparray; + } } $this->template_invoice->fetchObjectLinked(); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 7058364d1f1..927da1bf17a 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -169,7 +169,7 @@ class FactureRec extends CommonInvoice 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'titre' =>array('type'=>'varchar(100)', 'label'=>'Titre', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>15), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>25), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>30), //'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>40), @@ -181,7 +181,7 @@ class FactureRec extends CommonInvoice 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'Total', 'enabled'=>1, 'visible'=>-1, 'position'=>70, 'isameasure'=>1), 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>75, 'isameasure'=>1), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>80), - 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>85), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>'$conf->projet->enabled', 'visible'=>-1, 'position'=>85), 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Fk cond reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>90), 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'Fk mode reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>95), 'date_lim_reglement' =>array('type'=>'date', 'label'=>'Date lim reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>100), @@ -199,7 +199,7 @@ class FactureRec extends CommonInvoice 'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'RevenueStamp', 'enabled'=>1, 'visible'=>-1, 'position'=>160, 'isameasure'=>1), 'auto_validate' =>array('type'=>'integer', 'label'=>'Auto validate', 'enabled'=>1, 'visible'=>-1, 'position'=>165), 'generate_pdf' =>array('type'=>'integer', 'label'=>'Generate pdf', 'enabled'=>1, 'visible'=>-1, 'position'=>170), - 'fk_account' =>array('type'=>'integer', 'label'=>'Fk account', 'enabled'=>1, 'visible'=>-1, 'position'=>175), + 'fk_account' =>array('type'=>'integer', 'label'=>'Fk account', 'enabled'=>'$conf->banque->enabled', 'visible'=>-1, 'position'=>175), 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'Fk multicurrency', 'enabled'=>1, 'visible'=>-1, 'position'=>180), 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'Multicurrency code', 'enabled'=>1, 'visible'=>-1, 'position'=>185), 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency tx', 'enabled'=>1, 'visible'=>-1, 'position'=>190, 'isameasure'=>1), @@ -222,7 +222,7 @@ class FactureRec extends CommonInvoice * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; } @@ -270,6 +270,7 @@ class FactureRec extends CommonInvoice if ($result > 0) { // On positionne en mode brouillon la facture $this->brouillon = 1; + $this->fk_soc = $facsrc->socid; $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec ("; $sql .= "titre"; @@ -301,7 +302,7 @@ class FactureRec extends CommonInvoice $sql .= ", suspended"; $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'"; - $sql .= ", ".((int) $facsrc->socid); + $sql .= ", ".((int) $this->fk_soc); $sql .= ", ".((int) $conf->entity); $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", ".(!empty($facsrc->total_ttc) ? ((float) $facsrc->total_ttc) : '0'); @@ -1256,9 +1257,10 @@ class FactureRec extends CommonInvoice * * @param int $restrictioninvoiceid 0=All qualified template invoices found. > 0 = restrict action on invoice ID * @param int $forcevalidation 1=Force validation of invoice whatever is template auto_validate flag. + * @param int $notrigger Disable the trigger * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - public function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidation = 0) + public function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidation = 0, $notrigger = 0) { global $conf, $langs, $db, $user, $hookmanager; @@ -1338,6 +1340,8 @@ class FactureRec extends CommonInvoice $this->error = $facture->error; $error++; } + + if (!$error && ($facturerec->auto_validate || $forcevalidation)) { $result = $facture->validate($user); if ($result <= 0) { @@ -1356,6 +1360,16 @@ class FactureRec extends CommonInvoice $error++; } } + if (!$error && !$notrigger) { + // Call trigger + $result = $facturerec->call_trigger('BILLREC_CREATEBILL', $user); + if ($result < 0) { + $this->errors = $facturerec->errors; + $this->error = $facturerec->error; + $error++; + } + // End call triggers + } } else { $error++; $this->error = "Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity."\n"; @@ -1788,10 +1802,13 @@ class FactureRec extends CommonInvoice * * @param int $frequency value of frequency * @param string $unit unit of frequency (d, m, y) + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setFrequencyAndUnit($frequency, $unit) + public function setFrequencyAndUnit($frequency, $unit, $notrigger = 0) { + global $user; + if (!$this->table_element) { dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1815,6 +1832,16 @@ class FactureRec extends CommonInvoice if (!empty($unit)) { $this->unit_frequency = $unit; } + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } + return 1; } else { dol_print_error($this->db); @@ -1827,10 +1854,14 @@ class FactureRec extends CommonInvoice * * @param datetime $date date of execution * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setNextDate($date, $increment_nb_gen_done = 0) + public function setNextDate($date, $increment_nb_gen_done = 0, $notrigger = 0) { + + global $user; + if (!$this->table_element) { dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1848,6 +1879,15 @@ class FactureRec extends CommonInvoice if ($increment_nb_gen_done > 0) { $this->nb_gen_done++; } + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } return 1; } else { dol_print_error($this->db); @@ -1859,10 +1899,14 @@ class FactureRec extends CommonInvoice * Update the maximum period * * @param int $nb number of maximum period + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setMaxPeriod($nb) + public function setMaxPeriod($nb, $notrigger = 0) { + + global $user; + if (!$this->table_element) { dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1879,6 +1923,16 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); if ($this->db->query($sql)) { $this->nb_gen_max = $nb; + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } + return 1; } else { dol_print_error($this->db); @@ -1890,10 +1944,13 @@ class FactureRec extends CommonInvoice * Update the auto validate flag of invoice * * @param int $validate 0 to create in draft, 1 to create and validate invoice + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setAutoValidate($validate) + public function setAutoValidate($validate, $notrigger = 0) { + global $user; + if (!$this->table_element) { dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1906,6 +1963,16 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); if ($this->db->query($sql)) { $this->auto_validate = $validate; + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } + return 1; } else { dol_print_error($this->db); @@ -1917,10 +1984,13 @@ class FactureRec extends CommonInvoice * Update the auto generate documents * * @param int $validate 0 no document, 1 to generate document + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setGeneratePdf($validate) + public function setGeneratePdf($validate, $notrigger = 0) { + global $user; + if (!$this->table_element) { dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1933,6 +2003,16 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); if ($this->db->query($sql)) { $this->generate_pdf = $validate; + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } + return 1; } else { dol_print_error($this->db); @@ -1944,10 +2024,12 @@ class FactureRec extends CommonInvoice * Update the model for documents * * @param string $model model of document generator + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setModelPdf($model) + public function setModelPdf($model, $notrigger = 0) { + global $user; if (!$this->table_element) { dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -1960,6 +2042,16 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); if ($this->db->query($sql)) { $this->model_pdf = $model; + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('BILLREC_MODIFY', $user); + if ($result < 0) { + return $result; + } + // End call triggers + } + return 1; } else { dol_print_error($this->db); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0804f55b1ee..64d83cb2123 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -428,7 +428,7 @@ class Facture extends CommonInvoice * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; } @@ -560,7 +560,6 @@ class Facture extends CommonInvoice $this->array_options = $_facrec->array_options; - //if (! $this->remise) $this->remise = 0; if (!$this->mode_reglement_id) { $this->mode_reglement_id = 0; } @@ -1501,7 +1500,7 @@ class Facture extends CommonInvoice return null; } - $payment_conditions_deposit_percent = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $origin->cond_reglement_id); + $payment_conditions_deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $origin->cond_reglement_id); if (empty($payment_conditions_deposit_percent)) { $origin->error = 'ErrorPaymentConditionsNotEligibleToDepositCreation'; @@ -1652,13 +1651,13 @@ class Facture extends CommonInvoice 0, // date_start 0, // date_end 0, - $lines[$i]->info_bits, // info_bits + 0, // info_bits 0, 'HT', 0, 0, // product_type 1, - $lines[$i]->special_code, + 0, // special_code $deposit->origin, 0, 0, @@ -2194,9 +2193,11 @@ class Facture extends CommonInvoice // multilangs if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($objp->fk_product); + $tmpproduct->getMultiLangs(); + + $line->multilangs = $tmpproduct->multilangs; } $this->lines[$i] = $line; @@ -3009,7 +3010,7 @@ class Facture extends CommonInvoice return -1; } if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) { - $last_of_type = $this->willBeLastOfSameType(); + $last_of_type = $this->willBeLastOfSameType(true); if (!$last_of_type[0]) { $this->error = $langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $this->ref, dol_print_date($this->date, 'day'), dol_print_date($last_of_type[1], 'day')); return -1; @@ -3840,9 +3841,10 @@ class Facture extends CommonInvoice * @param double $pu_ht_devise Unit price in currency * @param int $notrigger disable line update trigger * @param string $ref_ext External reference of the line + * @param integer $rang rank of line * @return int < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '') + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) { global $conf, $user; // Deprecation warning @@ -3970,6 +3972,7 @@ class Facture extends CommonInvoice $line->oldline = $staticline; $this->line = $line; $this->line->context = $this->context; + $this->line->rang = $rang; // Reorder if fk_parent_line change if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { @@ -5022,7 +5025,7 @@ class Facture extends CommonInvoice $sql .= " WHERE f.entity IN (".getEntity('invoice', 0).")"; $resql = $this->db->query($sql); if ($resql) { - if ($resql->num_rows > 0) { + if ($this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); $ref = $res['max(situation_cycle_ref)']; $ref++; @@ -5067,7 +5070,7 @@ class Facture extends CommonInvoice $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); $res = array(); - if ($resql && $resql->num_rows > 0) { + if ($resql && $this->db->num_rows($resql) > 0) { while ($row = $this->db->fetch_object($resql)) { $id = $row->rowid; $situation = new Facture($this->db); @@ -5145,7 +5148,7 @@ class Facture extends CommonInvoice $sql .= ' AND entity = '.($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); - if ($resql && $resql->num_rows > 0) { + if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); $last = $res['max(situation_counter)']; return ($last == $this->situation_counter); @@ -5501,6 +5504,7 @@ class Facture extends CommonInvoice $sendContent = make_substitutions($content, $substitutionarray, $outputlangs, 1); // Recipient + $to = ''; $res = $tmpinvoice->fetch_thirdparty(); $recipient = $tmpinvoice->thirdparty; if ($res > 0) { @@ -5522,7 +5526,7 @@ class Facture extends CommonInvoice $error++; } - if (!$error) { + if (!$error && $to) { // Errors Recipient $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; @@ -5565,9 +5569,10 @@ class Facture extends CommonInvoice /** * See if current invoice date is posterior to the last invoice date among validated invoices of same type. + * @param boolean $allow_validated_drafts return true if the invoice has been validated before returning to DRAFT state. * @return boolean */ - public function willBeLastOfSameType() + public function willBeLastOfSameType($allow_validated_drafts = false) { // get date of last validated invoices of same type $sql = "SELECT datef"; @@ -5584,7 +5589,12 @@ class Facture extends CommonInvoice $last_date = $this->db->jdate($obj->datef); $invoice_date = $this->date; - return [$invoice_date >= $last_date, $last_date]; + $is_last_of_same_type = $invoice_date >= $last_date; + if ($allow_validated_drafts) { + $is_last_of_same_type = $is_last_of_same_type || (!strpos($this->ref, 'PROV') && $this->status == self::STATUS_DRAFT); + } + + return [$is_last_of_same_type, $last_date]; } else { // element is first of type to be validated return [true]; @@ -6278,7 +6288,7 @@ class FactureLigne extends CommonInvoiceLine $sql = "SELECT situation_percent FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".((int) $this->fk_prev_id); $resql = $this->db->query($sql); - if ($resql && $resql->num_rows > 0) { + if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); $returnPercent = floatval($res['situation_percent']); diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index a54cd1a6668..522fe9aa2e2 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -57,7 +57,7 @@ class FactureStats extends Stats * @param int $typentid Id typent of thirdpary for filter * @param int $categid Id category of thirdpary for filter */ - public function __construct($db, $socid, $mode, $userid = 0, $typentid = 0, $categid = 0) + public function __construct(DoliDB $db, $socid, $mode, $userid = 0, $typentid = 0, $categid = 0) { global $user, $conf; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index f94ad573a81..a4441804570 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -68,7 +68,7 @@ class PaymentTerm // extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; } diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index af1ab95c2b5..02925225df9 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -857,7 +857,7 @@ if ($resql) { } } if (!empty($arrayfields['f.datec']['checked'])) { - print ''; + print ''; print dol_print_date($db->jdate($objp->datec), 'dayhour'); print ''; if (!$i) { @@ -865,7 +865,7 @@ if ($resql) { } } if (!empty($arrayfields['f.tms']['checked'])) { - print ''; + print ''; print dol_print_date($db->jdate($objp->tms), 'dayhour'); print ''; if (!$i) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 2ef50801717..5937eda916c 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -2415,16 +2415,27 @@ if ($resql) { include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; } + // If no record found + if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; + } + $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print "\n"; - print ''; + print ''."\n"; + print ''."\n"; - print "\n"; + print ''."\n"; // Show the file area only when this page is not opend from the Extended POS if ($contextpage != 'poslist') { diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 316254b0398..989fa28b2f0 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -281,8 +281,8 @@ if ($object->id > 0) { } $author = new User($db); - if ($object->user_author) { - $author->fetch($object->user_author); + if ($object->fk_user_author) { + $author->fetch($object->fk_user_author); } if ($type == 'bank-transfer') { @@ -310,9 +310,9 @@ if ($object->id > 0) { $sql .= " AND pfd.ext_payment_id IS NULL"; $sql .= " ORDER BY pfd.date_demande DESC"; - $result_sql = $db->query($sql); - if ($result_sql) { - $num = $db->num_rows($result_sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); $numopen = $num; } else { dol_print_error($db); @@ -695,9 +695,9 @@ if ($object->id > 0) { $sql .= " AND pfd.traite = 0"; $sql .= " AND pfd.ext_payment_id IS NULL"; - $result_sql = $db->query($sql); - if ($result_sql) { - $obj = $db->fetch_object($result_sql); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); if ($obj) { $pending = $obj->amount; } @@ -797,17 +797,17 @@ if ($object->id > 0) { $sql .= " AND pfd.ext_payment_id IS NULL"; $sql .= " ORDER BY pfd.date_demande DESC"; - $result_sql = $db->query($sql); + $resql = $db->query($sql); $num = 0; - if ($result_sql) { + if ($resql) { $i = 0; $tmpuser = new User($db); $num = $db->num_rows($result); while ($i < $num) { - $obj = $db->fetch_object($result_sql); + $obj = $db->fetch_object($resql); $tmpuser->id = $obj->user_id; $tmpuser->login = $obj->login; @@ -840,7 +840,7 @@ if ($object->id > 0) { $i++; } - $db->free($result_sql); + $db->free($resql); } else { dol_print_error($db); } diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 6ee1a057664..cb0e38b7a34 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -102,7 +102,7 @@ if ($mode == 'customer') { $stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($object_status).')'; } if (is_array($custcats) && !empty($custcats)) { - $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat OmdN (f.fk_soc = cat.fk_soc)'; + $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat ON (f.fk_soc = cat.fk_soc)'; $stats->where .= ' AND cat.fk_categorie IN ('.$db->sanitize(implode(',', $custcats)).')'; } } diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index d12caf36bbe..1c3abfe87bd 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -172,7 +172,7 @@ if ($resql) { print ''; } print ''; - $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); + print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 5); print ''; print ''; $form->select_comptes($search_account, 'search_account', 0, '', 1); diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index cf02c2aeb74..326be7144a8 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -102,7 +102,7 @@ $syear = GETPOST("reyear") ?GETPOST("reyear") : date("Y", time()); print $formother->select_month($cmonth, 'remonth'); -print $formother->select_year($syear, 'reyear'); +print $formother->selectyear($syear, 'reyear'); print ''; print ''; diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 7cd49a9427c..640ffc78d99 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -198,7 +198,7 @@ if ($action == 'create') { if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } /*print ''.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).''; print ''.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'';*/ diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index 28bc838c296..84d2765b278 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -194,7 +194,7 @@ if ($action == 'create') { if ($resql) { $obj = $db->fetch_object($resql); $sumpaid = $obj->total; - $db->free(); + $db->free($resql); } /*print ''.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).''; print ''.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'';*/ diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 4f9eb4e456e..df142fb6531 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1066,8 +1066,8 @@ class BonPrelevement extends CommonObject // This also set the property $this->total with amount that is included into file $result = $this->generate($format, $executiondate, $type); if ($result < 0) { - /*var_dump($this->error); - var_dump($this->invoice_in_error); */ + //var_dump($this->error); + //var_dump($this->invoice_in_error); $error++; } } diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index 9c30db6e08a..8ee4c854600 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -143,7 +143,8 @@ if ($resql) { print price($total); print ' '; print ""; - $db->free(); + + $db->free($resql); } else { dol_print_error($db); } diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 0ea9b1ba30d..b586d4c88a6 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -863,7 +863,7 @@ if ($id > 0) { /* $MAXEVENT = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 6996c689922..70d8da4c27b 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -123,7 +123,7 @@ class ChargeSociales extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 9a4b50e3474..b6a611a47ee 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -105,7 +105,7 @@ class PaymentSocialContribution extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; } diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 8d63e52256e..082a485f817 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -713,16 +713,35 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } - print ''; + print ''."\n"; + $i++; } // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; -print ''; -print ''; -print ''; +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; +} + +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ''."\n"; +print ''."\n"; + +print ''."\n"; // End of page llxFooter(); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index ed37c72c1c4..26f8e754dd2 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -853,7 +853,7 @@ if ($id > 0) { /* $MAXEVENT = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index f1731420852..5f76b2e9190 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -190,8 +190,8 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { @@ -202,15 +202,15 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $sql .= $db->plimit($limit + 1, $offset); -$result = $db->query($sql); -if (!$result) { +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); llxFooter(); $db->close(); exit; } -$num = $db->num_rows($result); +$num = $db->num_rows($resql); $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { @@ -429,7 +429,7 @@ print ''; $i = 0; $totalarray = array(); while ($i < min($num, $limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); $tva_static->id = $obj->rowid; $tva_static->ref = $obj->rowid; @@ -549,11 +549,27 @@ $totalarray['nbfield']++; // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; -print ''; -print ''; -print ''; +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; +} -$db->free($result); +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ''."\n"; +print ''."\n"; + +print ''."\n"; // End of page llxFooter(); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index ee1d10181ca..1cef1901917 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -316,8 +316,9 @@ if (empty($reshook)) { $result = $object->delete(); // TODO Add $user as first param if ($result > 0) { - if ($backtopage) { - header("Location: ".$backtopage); + setEventMessages("RecordDeleted", null, 'mesgs'); + if ($backurlforlist) { + header("Location: ".$backurlforlist); exit; } else { header("Location: ".DOL_URL_ROOT.'/contact/list.php'); @@ -856,7 +857,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!empty($value['icon'])) { print ''; } - print ''; + print ''; print ''; print ''; } elseif (!empty($object->socialnetworks[$key])) { @@ -1550,7 +1551,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $MAXEVENT = 10; - $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id); + $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 487c075b3a1..587972fa83b 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -181,6 +181,12 @@ class Contact extends CommonObject */ public $email; + /** + * URL + * @var string + */ + public $url; + /** * Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings * @var int @@ -315,6 +321,7 @@ class Contact extends CommonObject */ public $stcomm_picto; + /** * Constructor * diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 631bf932640..7f1d9bdc64b 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -355,7 +355,7 @@ if (empty($elementTypeArray) && !$object->thirdparty->client && !$object->thirdp // Define type of elements $typeElementString = $form->selectarray("type_element", $elementTypeArray, GETPOST('type_element'), $showempty, 0, 0, '', 0, 0, $disabled, '', 'maxwidth150onsmartphone'); -$button = ''; +$button = ''; $param = ''; $param .= "&sref=".urlencode($sref); @@ -410,7 +410,7 @@ if ($sql_select) { print ''; print ''; // date print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); - $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); + print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 1); print ''; print ''; print ''; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 31b2153c2c8..93d61f8a903 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -1309,19 +1309,31 @@ while ($i < min($num, $limit)) { $i++; } +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; +} + $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -print ""; -print ""; - -//if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit, 1); - -print ''; +print ''."\n"; +print ''."\n"; +print ''."\n"; +// End of page llxFooter(); $db->close(); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 7265a69d1af..7ad5ceedb85 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2161,7 +2161,7 @@ if ($action == 'create') { $MAXEVENT = 10; - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id); + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index d85ad51946a..79f2e8e9e15 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -232,8 +232,8 @@ class Contrat extends CommonObject 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>40), 'date_contrat' =>array('type'=>'datetime', 'label'=>'Date contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70), - 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>70), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>'$conf->projet->enabled', 'visible'=>-1, 'position'=>75), 'fk_commercial_signature' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative Signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80), 'fk_commercial_suivi' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative follower', 'enabled'=>1, 'visible'=>-1, 'position'=>85), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90), @@ -772,16 +772,6 @@ class Contrat extends CommonObject $now = dol_now(); - /* - if (!is_object($extrafields)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); - } - - $line = new ContratLigne($this->db); - $extrafields->fetch_name_optionals_label(ContratLigne::$table_element, true); - */ - $this->lines = array(); $pos = 0; @@ -875,15 +865,17 @@ class Contrat extends CommonObject $line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite); $line->date_fin_reel = $this->db->jdate($objp->date_cloture); - // Retrieve all extrafields for contract + // Retrieve all extrafields for contract line // fetch optionals attributes and labels $line->fetch_optionals(); // multilangs if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($objp->fk_product); + $tmpproduct->getMultiLangs(); + + $line->multilangs = $tmpproduct->multilangs; } $this->lines[$pos] = $line; @@ -2754,6 +2746,7 @@ class ContratLigne extends CommonObjectLine public $commentaire; + const STATUS_INITIAL = 0; const STATUS_OPEN = 4; const STATUS_CLOSED = 5; @@ -2998,7 +2991,6 @@ class ContratLigne extends CommonObjectLine $this->localtax2_type = $obj->localtax2_type; $this->qty = $obj->qty; $this->remise_percent = $obj->remise_percent; - $this->remise = $obj->remise; $this->fk_remise_except = $obj->fk_remise_except; $this->subprice = $obj->subprice; $this->price_ht = $obj->price_ht; @@ -3056,7 +3048,6 @@ class ContratLigne extends CommonObjectLine $this->localtax2_tx = trim($this->localtax2_tx); $this->qty = trim($this->qty); $this->remise_percent = trim($this->remise_percent); - $this->remise = trim($this->remise); $this->fk_remise_except = (int) $this->fk_remise_except; $this->subprice = price2num($this->subprice); $this->price_ht = price2num($this->price_ht); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 99739260b36..1b9ab289774 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -346,22 +346,28 @@ if ($result) { while ($i < $num) { $obj = $db->fetch_object($result); + $datem = $db->jdate($obj->tms); + + $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid); + $staticcontrat->id = $obj->cid; + + $staticcompany->id = $obj->socid; + $staticcompany->name = $obj->name; print ''; print ''; - $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->cid); - $staticcontrat->id = $obj->cid; print $staticcontrat->getNomUrl(1, 16); if ($obj->nb_late) { print img_warning($langs->trans("Late")); } print ''; - print ''; - $staticcompany->id = $obj->socid; - $staticcompany->name = $obj->name; + + print ''; print $staticcompany->getNomUrl(1, '', 20); print ''; - print ''.dol_print_date($db->jdate($obj->tms), 'dayhour').''; + print ''; + print dol_print_date($datem, 'dayhour'); + print ''; //print ''.$staticcontrat->LibStatut($obj->statut,2).''; print ''.($obj->nb_initial > 0 ? ''.$obj->nb_initial.''.$staticcontratligne->LibStatut(0, 3, -1, 'class="paddingleft"') : '').''; print ''.($obj->nb_running > 0 ? ''.$obj->nb_running.''.$staticcontratligne->LibStatut(4, 3, 0, 'class="marginleft"') : '').''; @@ -439,7 +445,7 @@ if ($resql) { } } print ''; - print ''; + print ''; $staticcompany->id = $obj->fk_soc; $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); @@ -451,7 +457,7 @@ if ($resql) { print "\n"; $i++; } - $db->free(); + $db->free($resql); print ""; } else { @@ -521,7 +527,7 @@ if ($resql) { } } print ''; - print ''; + print ''; $staticcompany->id = $obj->fk_soc; $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); @@ -532,7 +538,8 @@ if ($resql) { print "\n"; $i++; } - $db->free(); + + $db->free($resql); print ""; } else { @@ -603,7 +610,7 @@ if ($resql) { } } print ''; - print ''; + print ''; $staticcompany->id = $obj->fk_soc; $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); @@ -614,7 +621,7 @@ if ($resql) { print "\n"; $i++; } - $db->free(); + $db->free($resql); print ""; } else { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 57b4657eab4..e76261010da 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -693,7 +693,7 @@ if (!empty($arrayfields['lower_planned_end_date']['checked'])) { print '
'; print $formother->select_month($search_dfmonth, 'search_dfmonth', 1, 0); print ' '; - $formother->select_year($search_dfyear, 'search_dfyear', 1, 20, 5, 0, 0, ''); + print $formother->selectyear($search_dfyear, 'search_dfyear', 1, 20, 5, 0, 0, ''); print ''; } // Status diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index f97d4aa94ee..85b854f8ba7 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -101,10 +101,10 @@ if ($action == 'add' && !empty($permissiontoadd)) { //var_dump($key.' '.$value.' '.$object->fields[$key]['type']); $object->$key = $value; - if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') { + if (!empty($val['notnull']) && $val['notnull'] > 0 && $object->$key == '' && isset($val['default']) && $val['default'] == '(PROV)') { $object->$key = '(PROV)'; } - if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) { + if (!empty($val['notnull']) && $val['notnull'] > 0 && $object->$key == '' && !isset($val['default'])) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors'); } @@ -121,7 +121,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { // Fill array 'array_options' with data from add form if (!$error) { - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '', 1); if ($ret < 0) { $error++; } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 383684b377a..5acc6b22ee2 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -90,7 +90,7 @@ if (!$error && $massaction == 'confirm_presend') { if ($objecttmp->element == 'expensereport') { $thirdparty = new User($db); } - if ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdparty = new Adherent($db); } if ($objecttmp->element == 'holiday') { @@ -110,7 +110,7 @@ if (!$error && $massaction == 'confirm_presend') { if ($objecttmp->element == 'expensereport') { $thirdpartyid = $objecttmp->fk_user_author; } - if ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdpartyid = $objecttmp->fk_member; } if ($objecttmp->element == 'holiday') { @@ -264,7 +264,7 @@ if (!$error && $massaction == 'confirm_presend') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user_author); $sendto = $fuser->email; - } elseif ($objectobj->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + } elseif ($objectobj->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $fadherent = new Adherent($db); $fadherent->fetch($objectobj->fk_member); $sendto = $fadherent->email; @@ -1468,6 +1468,7 @@ if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $ $trackid = 'leav'.$objecttmp->id; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); // Sending email diff --git a/htdocs/core/ajax/ajaxcompanies.php b/htdocs/core/ajax/ajaxcompanies.php new file mode 100644 index 00000000000..350f03398aa --- /dev/null +++ b/htdocs/core/ajax/ajaxcompanies.php @@ -0,0 +1,122 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2010 Cyrille de Lambert + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/ajax/ajaxcompanies.php + * \brief File to return Ajax response on third parties request + */ + +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); + +require '../../main.inc.php'; + + +/* + * View + */ + +// Ajout directives pour resoudre bug IE +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); + +//print ''."\n"; + +dol_syslog(join(',', $_GET)); + + +// Generation liste des societes +if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { + $return_arr = array(); + + // Define filter on text typed + $socid = $_GET['newcompany'] ? $_GET['newcompany'] : ''; + if (!$socid) $socid = $_GET['socid'] ? $_GET['socid'] : ''; + if (!$socid) $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : ''; + + $sql = "SELECT s.rowid, s.nom, s.name_alias, s.code_client, s.code_fournisseur, s.address, s.zip, s.town, s.email, s.siren, s.siret, s.ape, s.idprof4, s.client, s.fournisseur, s.datec, s.logo"; + $sql .= " , c.label as country, d.nom as departement"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON d.rowid = s.fk_departement"; + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; + if ($socid) { + $sql .= " AND ("; + // Add criteria on name/code + if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) { // Can use index + $sql .= "s.nom LIKE '".$db->escape($socid)."%'"; + $sql .= " OR s.code_client LIKE '".$db->escape($socid)."%'"; + $sql .= " OR s.code_fournisseur LIKE '".$db->escape($socid)."%'"; + } else { + $sql .= "s.nom LIKE '%".$db->escape($socid)."%'"; + $sql .= " OR s.code_client LIKE '%".$db->escape($socid)."%'"; + $sql .= " OR s.code_fournisseur LIKE '%".$db->escape($socid)."%'"; + } + if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) $sql .= " OR s.rowid = '".$db->escape($socid)."'"; + $sql .= ")"; + } + //if (GETPOST("filter")) $sql.= " AND (".GETPOST("filter", "alpha").")"; // Add other filters + $sql .= " ORDER BY s.nom ASC"; + + //dol_syslog("ajaxcompanies", LOG_DEBUG); + $resql = $db->query($sql); + + if ($resql) { + while ($row = $db->fetch_array($resql)) { + $label = $row['nom']; + if ($socid) $label = $label; + $row_array['label'] = $label; + $row_array['value'] = $row['nom']; + $row_array['key'] = $row['rowid']; + $row_array['name_alias'] = $row['name_alias']; + $row_array['code_client'] = $row['code_client']; + $row_array['code_fournisseur'] = $row['code_fournisseur']; + $row_array['address'] = $row['address']; + $row_array['zip'] = $row['zip']; + $row_array['town'] = $row['town']; + $row_array['email'] = $row['email']; + $row_array['siren'] = $row['siren']; + $row_array['siret'] = $row['siret']; + $row_array['ape'] = $row['ape']; + $row_array['idprof4'] = $row['idprof4']; + $row_array['client'] = $row['client']; + $row_array['fournisseur'] = $row['fournisseur']; + $row_array['datec'] = $row['datec']; + $row_array['logo'] = $row['logo']; + $row_array['country'] = $row['country']; + $row_array['departement'] = $row['departement']; + + array_push($return_arr, $row_array); + } + + echo json_encode($return_arr); + } else { + echo json_encode(array('nom'=>'Error', 'label'=>'Error', 'key'=>'Error', 'value'=>'Error')); + } +} else { + echo json_encode(array('nom'=>'ErrorBadParameter', 'label'=>'ErrorBadParameter', 'key'=>'ErrorBadParameter', 'value'=>'ErrorBadParameter')); +} diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 383f9a0c041..fcc39e1aae1 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -48,7 +48,7 @@ if (!defined('NOREQUIRETRAN')) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; - +$hookmanager->initHooks(array('rowinterface')); // Security check // This is done later into view. @@ -120,7 +120,15 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) $perm = 1; } } - + $parameters = array('roworder'=> &$roworder, 'table_element_line' => &$table_element_line, 'fk_element' => &$fk_element, 'element_id' => &$element_id, 'perm' => &$perm); + $row = new GenericObject($db); + $row->table_element_line = $table_element_line; + $row->fk_element = $fk_element; + $row->id = $element_id; + $reshook = $hookmanager->executeHooks('checkRowPerms', $parameters, $row, $action); + if ($reshook > 0) { + $perm = $hookmanager->resArray['perm']; + } if (! $perm) { // We should not be here. If we are not allowed to reorder rows, feature should not be visible on script. // If we are here, it is a hack attempt, so we report a warning. @@ -137,10 +145,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) } } - $row = new GenericObject($db); - $row->table_element_line = $table_element_line; - $row->fk_element = $fk_element; - $row->id = $element_id; + $row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 371a7a0dbed..02b5070a96c 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -329,7 +329,7 @@ class box_activity extends ModeleBoxes if (!empty($data)) { $j = 0; while ($j < count($data)) { - $billurl = "search_status=2&paye=1&year=".$data[$j]->annee; + $billurl = "search_status=2&paye=1"; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), @@ -339,7 +339,7 @@ class box_activity extends ModeleBoxes $this->info_box_contents[$line][1] = array( 'td' => '', - 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0)." ".$data[$j]->annee, + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), ); $this->info_box_contents[$line][2] = array( diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index d96fac8bc76..a9a4f8746da 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -147,7 +147,7 @@ class box_boms extends ModeleBoxes } $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, 'day', 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 2afa630860b..4a7ea965006 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -140,7 +140,7 @@ class box_clients extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, "day", 'tzuserrel') ); diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index b2ba608d689..ea35a080d0e 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -177,7 +177,7 @@ class box_contacts extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, "day", 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 8eeb1b93323..dddafffdc02 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -83,8 +83,8 @@ class box_contracts extends ModeleBoxes $thirdpartytmp = new Societe($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; - $sql .= ", c.ref_customer, c.ref_supplier"; + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.tms as date_modification, c.fin_validite, c.date_cloture,"; + $sql .= " c.ref_customer, c.ref_supplier"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -117,6 +117,7 @@ class box_contracts extends ModeleBoxes $objp = $this->db->fetch_object($resql); $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->date_modification); $dateterm = $this->db->jdate($objp->fin_validite); $dateclose = $this->db->jdate($objp->date_cloture); $late = ''; @@ -155,8 +156,8 @@ class box_contracts extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day', 'tzuserrel'), + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', + 'text' => dol_print_date($datem, 'day', 'tzuserrel'), ); $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index aff48328edb..2a04aa27803 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -127,7 +127,7 @@ class box_external_rss extends ModeleBoxes // Feed common fields $href = $item['link']; $title = urldecode($item['title']); - $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed + $date = empty($item['date_timestamp']) ? null : $item['date_timestamp']; // date will be empty if conversion into timestamp failed if ($rssparser->getFormat() == 'rss') { // If RSS if (!$date && isset($item['pubdate'])) { $date = $item['pubdate']; diff --git a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php index 5c8bd2c8555..b75d0752334 100644 --- a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php +++ b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; class box_graph_nb_ticket_last_x_days extends ModeleBoxes { - public $boxcode = "box_nb_ticket_last_x_days"; + public $boxcode = "box_graph_nb_ticket_last_x_days"; public $boximg = "ticket"; public $boxlabel; public $depends = array("ticket"); @@ -102,18 +102,17 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes 'text' => $text, 'limit' => dol_strlen($text) ); - $today = date_time_set(date_create(), 0, 0); - $todayformat = date('Y-m-d', date_timestamp_get($today)); - $intervaltosub = new DateInterval('P'.dol_escape_htmltag($days - 1).'D'); - $intervaltoadd = new DateInterval('P1D'); - $minimumdatec = date_sub($today, $intervaltosub); - $minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec)); + $today = dol_now(); + $intervaltoadd = 1; + $minimumdatec = dol_time_plus_duree($today, -1 * ($days - 1), 'd'); + $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); if ($user->rights->ticket->read) { $sql = "SELECT CAST(t.datec AS DATE) as datec, COUNT(t.datec) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; - $sql .= " WHERE CAST(t.datec AS DATE) > DATE_SUB(CURRENT_DATE, INTERVAL ".$days." DAY)"; + $sql .= " WHERE CAST(t.datec AS DATE) > '".$this->db->idate($minimumdatec)."'"; $sql .= " GROUP BY CAST(t.datec AS DATE)"; + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -122,18 +121,18 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes $objp = $this->db->fetch_object($resql); while ($minimumdatecformated < $objp->datec) { $dataseries[] = array('label' => dol_print_date($minimumdatecformated, 'day'), 'data' => 0); - $minimumdatec = date_add($minimumdatec, $intervaltoadd); - $minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec)); + $minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd'); + $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); } $dataseries[] = array('label' => dol_print_date($objp->datec, 'day'), 'data' => $objp->nb); - $minimumdatec = date_add($minimumdatec, $intervaltoadd); - $minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec)); + $minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd'); + $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); $i++; } while (count($dataseries) < $days) { $dataseries[] = array('label' => dol_print_date($minimumdatecformated, 'day'), 'data' => 0); - $minimumdatec = date_add($minimumdatec, $intervaltoadd); - $minimumdatecformated = date('Y-m-d', date_timestamp_get($minimumdatec)); + $minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd'); + $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); $i++; } } else { diff --git a/htdocs/core/boxes/box_graph_nb_tickets_type.php b/htdocs/core/boxes/box_graph_nb_tickets_type.php index 2da54d84e7a..88d930e9e27 100644 --- a/htdocs/core/boxes/box_graph_nb_tickets_type.php +++ b/htdocs/core/boxes/box_graph_nb_tickets_type.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; class box_graph_nb_tickets_type extends ModeleBoxes { - public $boxcode = "box_nb_tickets_type"; + public $boxcode = "box_graph_nb_tickets_type"; public $boximg = "ticket"; public $boxlabel; public $depends = array("ticket"); @@ -171,7 +171,7 @@ class box_graph_nb_tickets_type extends ModeleBoxes } $stringtoprint .= ''; $this->info_box_contents[][]=array( - 'td' => 'center', + 'td' => 'class="center"', 'text' => $stringtoprint ); } else { diff --git a/htdocs/core/boxes/box_graph_ticket_by_severity.php b/htdocs/core/boxes/box_graph_ticket_by_severity.php index 5e69a49e88e..3c8756cf544 100644 --- a/htdocs/core/boxes/box_graph_ticket_by_severity.php +++ b/htdocs/core/boxes/box_graph_ticket_by_severity.php @@ -191,19 +191,19 @@ class box_graph_ticket_by_severity extends ModeleBoxes } $stringtoprint .= ''; $this->info_box_contents[][]=array( - 'td' => 'center', + 'td' => 'class="center"', 'text' => $stringtoprint ); } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="center opacitymedium"', - 'text' => $langs->trans("BoxNoTicketSeverity") + 'td' => '', + 'text' => ''.$langs->trans("BoxNoTicketSeverity").'' ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => '', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'', ); } } diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index 300a13803c5..fd8ecd95eaf 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -177,15 +177,15 @@ class box_last_modified_ticket extends ModeleBoxes } if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); + $this->info_box_contents[$i][0] = array('td' => '', 'text'=>''.$langs->trans("BoxLastModifiedTicketNoRecordedTickets").''); } } else { dol_print_error($this->db); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed"), + 'td' => '', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'', ); } } diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 25cb353b268..41ac39c1239 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -85,9 +85,9 @@ class box_last_ticket extends ModeleBoxes ); if ($user->rights->ticket->read) { - $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; - $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; - $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; + $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut as status, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email,"; + $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label,"; + $sql .= " s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; @@ -113,6 +113,7 @@ class box_last_ticket extends ModeleBoxes while ($i < $num) { $objp = $this->db->fetch_object($resql); + $datec = $this->db->jdate($objp->datec); //$dateterm = $this->db->jdate($objp->fin_validite); //$dateclose = $this->db->jdate($objp->date_close); @@ -122,7 +123,8 @@ class box_last_ticket extends ModeleBoxes $ticket->id = $objp->id; $ticket->track_id = $objp->track_id; $ticket->ref = $objp->ref; - $ticket->fk_statut = $objp->fk_statut; + $ticket->fk_statut = $objp->status; + $ticket->status = $objp->status; $ticket->subject = $objp->subject; if ($objp->fk_soc > 0) { $thirdparty = new Societe($this->db); @@ -149,8 +151,8 @@ class box_last_ticket extends ModeleBoxes // Subject $this->info_box_contents[$i][$r] = array( 'td' => 'class="tdoverflowmax200"', - 'text' => ''.$objp->subject.'', // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, + 'text' => ''.dol_escape_htmltag($objp->subject).'', // Some event have no ref + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".urlencode($objp->track_id), ); $r++; @@ -180,14 +182,14 @@ class box_last_ticket extends ModeleBoxes } if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets")); + $this->info_box_contents[$i][0] = array('td' => '', 'text' => ''.$langs->trans("BoxLastTicketNoRecordedTickets").''); } } else { dol_print_error($this->db); } } else { - $this->info_box_contents[0][0] = array('td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed")); + $this->info_box_contents[0][0] = array('td' => '', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").''); } } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 5865cba2530..e091d58643b 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -145,7 +145,7 @@ class box_members extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, "day", 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index 6436fb8e34e..cff19388c17 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -144,7 +144,7 @@ class box_mos extends ModeleBoxes } $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"', 'text' => dol_print_date($datem, 'day', 'tzuserrel'), ); diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index f3f9496325f..97b7bd5fd51 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -165,7 +165,7 @@ class box_propales extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="center nowraponall"', + 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("Date").': '.dol_print_date($datem, 'day', 'tzuserrel')).'"', 'text' => dol_print_date($date, 'day', 'tzuserrel'), ); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index b6acbbbfbc9..94fb05d5346 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -597,7 +597,7 @@ class CMailFile } $sendingmode = $this->sendmode; - if ($this->context == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') { + if ($this->sendcontext == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') { // List of sending methods $listofmethods = array(); $listofmethods['mail'] = 'PHP mail function'; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a9536f410ca..e80eaa52b14 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -65,6 +65,26 @@ abstract class CommonDocGenerator */ public $scandir; + public $page_hauteur; + public $page_largeur; + public $marge_gauche; + public $marge_droite; + public $marge_haute; + public $marge_basse; + + public $option_logo; + public $option_tva; + public $option_multilang; + public $option_freetext; + public $option_draft_watermark; + + public $option_modereg; + public $option_condreg; + public $option_escompte; + public $option_credit_note; + + public $emetteur; + /** * Constructor diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index e49f8a6a728..e88b42950f3 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -93,12 +93,17 @@ abstract class CommonInvoice extends CommonObject const STATUS_ABANDONED = 3; + public $totalpaid; // duplicate with sumpayed + public $totaldeposits; // duplicate with sumdeposit + public $totalcreditnotes; // duplicate with sumcreditnote + public $sumpayed; public $sumpayed_multicurrency; public $sumdeposit; public $sumdeposit_multicurrency; public $sumcreditnote; public $sumcreditnote_multicurrency; + public $remaintopay; /** @@ -862,11 +867,11 @@ abstract class CommonInvoice extends CommonObject $pricewithtax = implode(unpack("H*", price2num($pricewithtaxstring, 2))); $pricetax = implode(unpack("H*", $pricetaxstring)); - var_dump(strlen($this->thirdparty->name)); - var_dump(str_pad(dechex('9'), 2, '0', STR_PAD_LEFT)); - var_dump($this->thirdparty->name); - var_dump(implode(unpack("H*", $this->thirdparty->name))); - var_dump(price($this->total_tva, 0, $tmplang, 0, -1, 2)); + //var_dump(strlen($this->thirdparty->name)); + //var_dump(str_pad(dechex('9'), 2, '0', STR_PAD_LEFT)); + //var_dump($this->thirdparty->name); + //var_dump(implode(unpack("H*", $this->thirdparty->name))); + //var_dump(price($this->total_tva, 0, $tmplang, 0, -1, 2)); $s = '01'.str_pad(dechex(strlen($this->thirdparty->name)), 2, '0', STR_PAD_LEFT).$name; $s .= '02'.str_pad(dechex(strlen($this->thirdparty->tva_intra)), 2, '0', STR_PAD_LEFT).$vatnumber; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cabb50520fb..14bca386018 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -115,6 +115,16 @@ abstract class CommonObject */ public $array_languages = null; // Value is array() when load already tried + /** + * @var array To store result of ->liste_contact() + */ + public $contacts_ids; + + /** + * @var mixed Array of linked objects, set and used when calling ->create() to be able to create links during the creation of object + */ + public $linked_objects; + /** * @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked */ @@ -201,7 +211,7 @@ abstract class CommonObject public $user; /** - * @var string The type of originating object ('commande', 'facture', ...) + * @var string The type of originating object ('commande', 'facture', ...). Note: on some object this field is called $origin_type * @see fetch_origin() */ public $origin; @@ -2236,10 +2246,14 @@ abstract class CommonObject * Link element with a project * * @param int $projectid Project id to link element to + * @param int $notrigger Disable the trigger * @return int <0 if KO, >0 if OK */ - public function setProject($projectid) + public function setProject($projectid, $notrigger = 0) { + global $user; + $error = 0; + if (!$this->table_element) { dol_syslog(get_class($this)."::setProject was called on objet with property table_element not defined", LOG_ERR); return -1; @@ -2270,13 +2284,33 @@ abstract class CommonObject $sql .= " WHERE rowid = ".((int) $this->id); } + $this->db->begin(); + dol_syslog(get_class($this)."::setProject", LOG_DEBUG); if ($this->db->query($sql)) { $this->fk_project = ((int) $projectid); - return 1; } else { dol_print_error($this->db); + $error++; + } + + // Triggers + if (!$error && !$notrigger) { + // Call triggers + $result = $this->call_trigger(strtoupper($this->element) . '_MODIFY', $user); + if ($result < 0) { + $error++; + } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); return -1; + } else { + $this->db->commit(); + return 1; } } @@ -2606,7 +2640,7 @@ abstract class CommonObject } if (empty($deposit_percent) || $deposit_percent < 0) { - $deposit_percent = getDictionaryValue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $id); + $deposit_percent = getDictionaryValue('c_payment_term', 'deposit_percent', $id); } if ($deposit_percent > 100) { @@ -4855,7 +4889,7 @@ abstract class CommonObject $product_static->fetch($line->fk_product); $product_static->ref = $line->ref; //can change ref in hook - $product_static->label = $line->label; //can change label in hook + $product_static->label = !empty($line->label) ? $line->label : ""; //can change label in hook $text = $product_static->getNomUrl(1); @@ -4891,7 +4925,7 @@ abstract class CommonObject $description .= (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($line->description)); // Description is what to show on popup. We shown nothing if already into desc. } - $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx / 100)), 'MU'); + $line->pu_ttc = price2num((!empty($line->subprice) ? $line->subprice : 0) * (1 + ((!empty($line->tva_tx) ? $line->tva_tx : 0) / 100)), 'MU'); // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer @@ -6813,7 +6847,7 @@ abstract class CommonObject if ((string) $key == '') { continue; } - list($val, $parent) = explode('|', $val); + if (strpos($val, "|") !== false) list($val, $parent) = explode('|', $val); $out .= '